pub struct Id { /* private fields */ }Expand description
A generational id: a slot index and a generation.
Ids order by index, then generation. to_bits packs one
into a u64 (generation in the high half), for storage or for passing
across an FFI boundary.
§Layout
An Id has size 8 and alignment 8 (at least the alignment of u64 on
every target), and its bytes are exactly those of
to_bits in native byte order. FFI
code may therefore view a [Id] as a [u64] of bits without copying.
(The reverse is not sound: a u64 with a zero high half is not an Id.)
Implementations§
Source§impl Id
impl Id
Sourcepub const fn new(index: u32, generation: NonZeroU32) -> Self
pub const fn new(index: u32, generation: NonZeroU32) -> Self
An id from its parts. An allocator treats it as alive only if it currently has a live id with this index and generation (see the module docs on the scope of that check).
Sourcepub const fn generation(self) -> NonZeroU32
pub const fn generation(self) -> NonZeroU32
The generation, starting at 1 for the first id at an index.
Trait Implementations§
impl Copy for Id
Source§impl<'de> Deserialize<'de> for Id
Available on crate feature serde only.Deserializes from its bits; rejects a zero generation.
impl<'de> Deserialize<'de> for Id
serde only.Deserializes from its bits; rejects a zero generation.
Source§fn deserialize<De: Deserializer<'de>>(
deserializer: De,
) -> Result<Self, De::Error>
fn deserialize<De: Deserializer<'de>>( deserializer: De, ) -> Result<Self, De::Error>
Source§impl DirectKey for Id
A direct map stores only the generation; its NonZeroU32 niche keeps
Option<(NonZeroU32, V)> as small as (u32, V).
impl DirectKey for Id
A direct map stores only the generation; its NonZeroU32 niche keeps
Option<(NonZeroU32, V)> as small as (u32, V).
Source§type Tag = NonZero<u32>
type Tag = NonZero<u32>
Source§fn tag(self) -> NonZeroU32
fn tag(self) -> NonZeroU32
Source§fn from_parts(index: usize, generation: NonZeroU32) -> Self
fn from_parts(index: usize, generation: NonZeroU32) -> Self
index and tag tag.impl Eq for Id
Source§impl<T, const PAGE: usize> Index<Id> for ConcurrentAppendHive<T, PAGE>
Available on crate feature concurrent only.
impl<T, const PAGE: usize> Index<Id> for ConcurrentAppendHive<T, PAGE>
concurrent only.Source§impl Ord for Id
impl Ord for Id
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 Id
impl PartialOrd for Id
Source§impl Serialize for Id
Available on crate feature serde only.Serializes as its bits (Id::to_bits).
impl Serialize for Id
serde only.Serializes as its bits (Id::to_bits).
impl StructuralPartialEq for Id
Auto Trait Implementations§
impl Forget for Id
impl Freeze for Id
impl Move for Id
impl RefUnwindSafe for Id
impl Send for Id
impl Sync for Id
impl Unpin for Id
impl UnsafeUnpin for Id
impl UnwindSafe for Id
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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