pub struct NodeId {
index: u32,
generation: u32,
}Expand description
The slot a node occupies in a Dag, with the generation it was in.
A handle is only valid while the node it names lives: once the node is removed and its slot is reused, the generation no longer matches and the handle stops resolving (see the module documentation).
Fields§
§index: u32The slot the node occupies.
generation: u32The generation the slot was in when the node was inserted. A reused slot carries a higher generation, so old handles do not resolve.
Implementations§
Source§impl NodeId
impl NodeId
Sourcepub const fn index(self) -> usize
pub const fn index(self) -> usize
The slot this handle names.
Only meaningful while the node lives, but stable across the node’s lifetime, so callers can group or sort by it without holding a borrow. Two handles can share an index and still differ: the generation is what tells a live handle from a stale one.
Sourcepub const fn to_bits(self) -> u64
pub const fn to_bits(self) -> u64
The handle as plain bits, for an API that stores handles but does not know the type — an inspector that reports one, or a transport that carries it.
The slot index is the low 32 bits and the generation the high 32, the
same layout as unlit_ecs::Entity. Rebuild the handle with
NodeId::from_bits.
Sourcepub const fn from_bits(bits: u64) -> Self
pub const fn from_bits(bits: u64) -> Self
Rebuild a handle from the bits NodeId::to_bits produced.
The bits say nothing about whether the node still lives; resolving them through the graph is what decides that.
Trait Implementations§
impl Copy for NodeId
impl Eq for NodeId
Source§impl Ord for NodeId
impl Ord for NodeId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for NodeId
impl PartialOrd for NodeId
impl StructuralPartialEq for NodeId
Auto Trait Implementations§
impl Forget for NodeId
impl Freeze for NodeId
impl RefUnwindSafe for NodeId
impl Send for NodeId
impl Sync for NodeId
impl Unpin for NodeId
impl UnsafeUnpin for NodeId
impl UnwindSafe for NodeId
Blanket Implementations§
impl<T> AsId for T
impl<T> AsIdSalt for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more