pub struct HandleGenExample { /* private fields */ }Expand description
✨ An example generational handle.
📍 data/id/handle::HandleGenExample
📦 size_of::<HandleGenExample>() == 4 bytes / 32 bits
⚗️Option<T> 🟰 T
Generated by handle_gen!.
Demonstrates a generational handle with an index and niche-aware generation.
§Methods
- Core handle methods:
new,from_prim,try_from_usize,into_parts,into_prim,eq. - Component access:
each field exposes
get_<field>,get_<field>_prim, andget_<field>_usize. - Canonical
Wordrepresentation:raw,from_raw,try_from_raw. - Scalar packing:
PACK_BITS,try_pack_u8…try_pack_u128,try_unpack_u8…try_unpack_u128.
- Index:
get_index,get_index_prim,get_index_usize. - Generation:
get_generation,get_generation_prim,get_generation_usize.
Implementations§
Source§impl HandleGenExample
§Core handle methods
Construction, decomposition and const-compatible comparison.
impl HandleGenExample
§Core handle methods
Construction, decomposition and const-compatible comparison.
Sourcepub const fn new(index: u8, generation: NonMaxU16) -> Self
pub const fn new(index: u8, generation: NonMaxU16) -> Self
Creates a new handle from its representation components.
Sourcepub const fn from_prim(index: u8, generation: u16) -> Result<Self, InvalidValue> ⓘ
pub const fn from_prim(index: u8, generation: u16) -> Result<Self, InvalidValue> ⓘ
Creates a new handle from primitive carrier components.
Returns an error if any component violates its representation invariant.
Sourcepub const fn try_from_usize(
index: usize,
generation: usize,
) -> Result<Self, NicheValueError> ⓘ
pub const fn try_from_usize( index: usize, generation: usize, ) -> Result<Self, NicheValueError> ⓘ
Creates a new handle from usize components.
Returns an error if any value does not fit its primitive carrier or violates its representation invariant.
Sourcepub const fn into_parts(self) -> (u8, NonMaxU16) ⓘ
pub const fn into_parts(self) -> (u8, NonMaxU16) ⓘ
Returns the representation components in declaration order.
Source§impl HandleGenExample
§Methods for index
impl HandleGenExample
§Methods for index
Sourcepub const fn get_index_prim(self) -> u8
pub const fn get_index_prim(self) -> u8
Returns the index component as its primitive carrier.
Source§impl HandleGenExample
§Methods for generation
impl HandleGenExample
§Methods for generation
Sourcepub const fn get_generation(self) -> NonMaxU16
pub const fn get_generation(self) -> NonMaxU16
Returns the generation component.
Sourcepub const fn get_generation_prim(self) -> u16
pub const fn get_generation_prim(self) -> u16
Returns the generation component as its primitive carrier.
Source§impl HandleGenExample
impl HandleGenExample
Source§impl HandleGenExample
§Scalar packing
Packs the primitive component bits into unsigned scalar carriers.
impl HandleGenExample
§Scalar packing
Packs the primitive component bits into unsigned scalar carriers.
Sourcepub const PACK_BITS: u32
pub const PACK_BITS: u32
The total bit width of all primitive components.
Components occupy bits from low to high in declaration order.
Sourcepub const fn try_pack_u8(self) -> Option<u8> ⓘ
pub const fn try_pack_u8(self) -> Option<u8> ⓘ
Tries to pack this handle into a u8.
Primitive component bits are placed from low to high in declaration order.
Returns None if the complete value cannot be represented
by the target scalar.
Sourcepub const fn try_unpack_u8(packed: u8) -> Result<Self, InvalidValue> ⓘ
pub const fn try_unpack_u8(packed: u8) -> Result<Self, InvalidValue> ⓘ
Tries to reconstruct this handle from a packed u8.
Primitive component bits are read from low to high in declaration order.
§Errors
Returns an error if extra bits are set or a component violates its invariant.
Sourcepub const fn try_pack_u16(self) -> Option<u16> ⓘ
pub const fn try_pack_u16(self) -> Option<u16> ⓘ
Tries to pack this handle into a u16.
Primitive component bits are placed from low to high in declaration order.
Returns None if the complete value cannot be represented
by the target scalar.
Sourcepub const fn try_unpack_u16(packed: u16) -> Result<Self, InvalidValue> ⓘ
pub const fn try_unpack_u16(packed: u16) -> Result<Self, InvalidValue> ⓘ
Tries to reconstruct this handle from a packed u16.
Primitive component bits are read from low to high in declaration order.
§Errors
Returns an error if extra bits are set or a component violates its invariant.
Sourcepub const fn try_pack_u32(self) -> Option<u32> ⓘ
pub const fn try_pack_u32(self) -> Option<u32> ⓘ
Tries to pack this handle into a u32.
Primitive component bits are placed from low to high in declaration order.
Returns None if the complete value cannot be represented
by the target scalar.
Sourcepub const fn try_unpack_u32(packed: u32) -> Result<Self, InvalidValue> ⓘ
pub const fn try_unpack_u32(packed: u32) -> Result<Self, InvalidValue> ⓘ
Tries to reconstruct this handle from a packed u32.
Primitive component bits are read from low to high in declaration order.
§Errors
Returns an error if extra bits are set or a component violates its invariant.
Sourcepub const fn try_pack_u64(self) -> Option<u64> ⓘ
pub const fn try_pack_u64(self) -> Option<u64> ⓘ
Tries to pack this handle into a u64.
Primitive component bits are placed from low to high in declaration order.
Returns None if the complete value cannot be represented
by the target scalar.
Sourcepub const fn try_unpack_u64(packed: u64) -> Result<Self, InvalidValue> ⓘ
pub const fn try_unpack_u64(packed: u64) -> Result<Self, InvalidValue> ⓘ
Tries to reconstruct this handle from a packed u64.
Primitive component bits are read from low to high in declaration order.
§Errors
Returns an error if extra bits are set or a component violates its invariant.
Sourcepub const fn try_pack_u128(self) -> Option<u128> ⓘ
pub const fn try_pack_u128(self) -> Option<u128> ⓘ
Tries to pack this handle into a u128.
Primitive component bits are placed from low to high in declaration order.
Returns None if the complete value cannot be represented
by the target scalar.
Sourcepub const fn try_unpack_u128(packed: u128) -> Result<Self, InvalidValue> ⓘ
pub const fn try_unpack_u128(packed: u128) -> Result<Self, InvalidValue> ⓘ
Tries to reconstruct this handle from a packed u128.
Primitive component bits are read from low to high in declaration order.
§Errors
Returns an error if extra bits are set or a component violates its invariant.
Trait Implementations§
Source§impl Clone for HandleGenExample
impl Clone for HandleGenExample
Source§fn clone(&self) -> HandleGenExample
fn clone(&self) -> HandleGenExample
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for HandleGenExample
Source§impl Debug for HandleGenExample
impl Debug for HandleGenExample
impl Eq for HandleGenExample
Source§impl Hash for HandleGenExample
impl Hash for HandleGenExample
Source§impl Ord for HandleGenExample
impl Ord for HandleGenExample
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 PartialEq for HandleGenExample
impl PartialEq for HandleGenExample
Source§impl PartialOrd for HandleGenExample
impl PartialOrd for HandleGenExample
impl StructuralPartialEq for HandleGenExample
Source§impl WordTry for HandleGenExample
impl WordTry for HandleGenExample
Source§type Repr = (u8, NonValueU16<{$IP::$XTR}>)
type Repr = (u8, NonValueU16<{$IP::$XTR}>)
Auto Trait Implementations§
impl Freeze for HandleGenExample
impl RefUnwindSafe for HandleGenExample
impl Send for HandleGenExample
impl Sync for HandleGenExample
impl Unpin for HandleGenExample
impl UnsafeUnpin for HandleGenExample
impl UnwindSafe for HandleGenExample
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId of Self using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
alloc only.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> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> MemExt for Twhere
T: ?Sized,
impl<T> MemExt for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice only.