feat: finalize the Hemx 0.4 core
CI / test (push) Has been cancelled

This commit is contained in:
tmk241
2026-09-02 17:28:40 +02:00
parent 1dc9734f16
commit a3c72e21db
15 changed files with 96 additions and 231 deletions
-65
View File
@@ -14,27 +14,6 @@ pub const RUNTIME_ABI_VERSION: u32 = 1;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct BuildFingerprint(pub u64);
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct AtomSnapshot {
pub id: u32,
pub bytes: Vec<u8>,
}
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
pub struct AtomState {
pub atoms: Vec<AtomSnapshot>,
}
impl AtomState {
pub fn to_postcard(&self) -> Result<Vec<u8>, postcard::Error> {
postcard::to_allocvec(self)
}
pub fn from_postcard(bytes: &[u8]) -> Result<Self, postcard::Error> {
postcard::from_bytes(bytes)
}
}
impl BuildFingerprint {
pub const fn from_parts(parts: &[u32]) -> Self {
let mut hash = 0xcbf29ce484222325u64;
@@ -51,7 +30,6 @@ impl BuildFingerprint {
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub enum ResourceKind {
Slot,
Atom,
Handle,
Form,
}
@@ -669,7 +647,6 @@ fn write_ref(reference: &ResourceRef, out: &mut Vec<u8>) {
write_u8(
match reference.resource.kind {
ResourceKind::Slot => 0,
ResourceKind::Atom => 1,
ResourceKind::Handle => 2,
ResourceKind::Form => 3,
},
@@ -866,7 +843,6 @@ fn read_position(reader: &mut WireReader<'_>) -> Result<InsertPosition, WireErro
fn read_ref(reader: &mut WireReader<'_>) -> Result<ResourceRef, WireError> {
let kind = match reader.read_u8()? {
0 => ResourceKind::Slot,
1 => ResourceKind::Atom,
2 => ResourceKind::Handle,
3 => ResourceKind::Form,
_ => return Err(WireError::UnknownTag),
@@ -1126,47 +1102,6 @@ where
}
}
#[derive(Debug, Eq, PartialEq, Hash)]
pub struct Atom<T> {
id: ResourceId,
_marker: PhantomData<fn() -> T>,
}
impl<T> Clone for Atom<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> Copy for Atom<T> {}
impl<T> core::fmt::Display for Atom<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
self.id.id.fmt(f)
}
}
impl<T> Atom<T> {
pub const fn new(id: u32) -> Self {
Self {
id: ResourceId::new(ResourceKind::Atom, id),
_marker: PhantomData,
}
}
pub const fn id(self) -> ResourceId {
self.id
}
pub fn set(self, value: impl ToString) -> Effect {
Effect::Patch {
target: ResourceRef::unscoped(self.id),
mode: PatchMode::Morph,
html: SafeHtml::trusted(value.to_string()),
}
}
}
#[derive(Debug, Eq, PartialEq, Hash)]
pub struct Handle<I> {
id: ResourceId,