pub struct HandleSpanExample { /* private fields */ }Expand description
✨ An example span handle.
📍 data/id/handle::HandleSpanExample
📦 size_of::<HandleSpanExample>() == 2 bytes / 16 bits
⚗️Option<T> 🟰 T
Generated by handle_span!.
Demonstrates a minimal span-handle using niche-aware u8 storage.
§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.
- Offset:
get_offset,get_offset_prim,get_offset_usize. - Length:
get_len,get_len_prim,get_len_usize,is_empty.
Implementations§
Source§impl HandleSpanExample
§Core handle methods
Construction, decomposition and const-compatible comparison.
impl HandleSpanExample
§Core handle methods
Construction, decomposition and const-compatible comparison.
Sourcepub const fn new(offset: NonMaxU8, len: NonMaxU8) -> Self
pub const fn new(offset: NonMaxU8, len: NonMaxU8) -> Self
Creates a new handle from its representation components.
Sourcepub const fn from_prim(offset: u8, len: u8) -> Result<Self, InvalidValue> ⓘ
pub const fn from_prim(offset: u8, len: u8) -> 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(
offset: usize,
len: usize,
) -> Result<Self, NicheValueError> ⓘ
pub const fn try_from_usize( offset: usize, len: 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) -> (NonMaxU8, NonMaxU8) ⓘ
pub const fn into_parts(self) -> (NonMaxU8, NonMaxU8) ⓘ
Returns the representation components in declaration order.
Source§impl HandleSpanExample
§Methods for offset
impl HandleSpanExample
§Methods for offset
Sourcepub const fn get_offset(self) -> NonMaxU8
pub const fn get_offset(self) -> NonMaxU8
Returns the offset component.
Sourcepub const fn get_offset_prim(self) -> u8
pub const fn get_offset_prim(self) -> u8
Returns the offset component as its primitive carrier.
Source§impl HandleSpanExample
§Methods for len
impl HandleSpanExample
§Methods for len
Sourcepub const fn get_len_prim(self) -> u8
pub const fn get_len_prim(self) -> u8
Returns the len component as its primitive carrier.
Source§impl HandleSpanExample
impl HandleSpanExample
Source§impl HandleSpanExample
§Scalar packing
Packs the primitive component bits into unsigned scalar carriers.
impl HandleSpanExample
§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 HandleSpanExample
impl Clone for HandleSpanExample
Source§fn clone(&self) -> HandleSpanExample
fn clone(&self) -> HandleSpanExample
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConstInit for HandleSpanExample
impl ConstInit for HandleSpanExample
impl Copy for HandleSpanExample
Source§impl Debug for HandleSpanExample
impl Debug for HandleSpanExample
Source§impl Default for HandleSpanExample
impl Default for HandleSpanExample
impl Eq for HandleSpanExample
Source§impl Hash for HandleSpanExample
impl Hash for HandleSpanExample
Source§impl PartialEq for HandleSpanExample
impl PartialEq for HandleSpanExample
impl StructuralPartialEq for HandleSpanExample
Source§impl WordTry for HandleSpanExample
impl WordTry for HandleSpanExample
Source§type Repr = (NonValueU8<{$IP::$XTR}>, NonValueU8<{$IP::$XTR}>)
type Repr = (NonValueU8<{$IP::$XTR}>, NonValueU8<{$IP::$XTR}>)
Auto Trait Implementations§
impl Freeze for HandleSpanExample
impl RefUnwindSafe for HandleSpanExample
impl Send for HandleSpanExample
impl Sync for HandleSpanExample
impl Unpin for HandleSpanExample
impl UnsafeUnpin for HandleSpanExample
impl UnwindSafe for HandleSpanExample
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.