pub struct NodeId(/* private fields */);Expand description
A versioned identifier for a node in a Blitz DOM tree.
A NodeId packs a 32-bit slot index (low bits) and a 32-bit version
(high bits). Node storage bumps a slot’s version when the slot is
reused, so ids referring to a dropped node no longer resolve (lookups
return None rather than aliasing the new node occupying the slot).
The Default value is a null id which never resolves to a node.
Implementations§
Source§impl NodeId
impl NodeId
Sourcepub fn as_u64(self) -> u64
pub fn as_u64(self) -> u64
Convert this id to its raw u64 representation (index + version).
The value round-trips through NodeId::from_u64. This is useful for
interop with APIs which use integer ids (e.g. Taffy or AccessKit).
Sourcepub fn from_u64(raw: u64) -> Self
pub fn from_u64(raw: u64) -> Self
Reconstruct a NodeId from the raw u64 representation produced by
NodeId::as_u64.
Passing a value that did not come from as_u64 will produce an id
which fails to resolve (it will not alias an unrelated live node).
Trait Implementations§
impl Copy for NodeId
Source§impl<'de> Deserialize<'de> for NodeId
impl<'de> Deserialize<'de> for NodeId
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for NodeId
Source§impl Ord for NodeId
Ordered by slot index first, then by version, so that ordering roughly
matches node creation order (as with the previous Slab-backed storage)
rather than being dominated by the version bits.
impl Ord for NodeId
Ordered by slot index first, then by version, so that ordering roughly
matches node creation order (as with the previous Slab-backed storage)
rather than being dominated by the version bits.
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for NodeId
impl PartialOrd for NodeId
Source§impl Serialize for NodeId
Serialized as the raw u64, so it round-trips through
NodeId::from_u64 and stays an integer on the wire.
impl Serialize for NodeId
Serialized as the raw u64, so it round-trips through
NodeId::from_u64 and stays an integer on the wire.
It is deliberately not the slot index: a reference handed to an out-of- process client and echoed back later has to fail rather than resolve to whatever node took over the slot, and the version bits are what make that possible.