pub enum TnidVariant {
V0,
V1,
V2,
V3,
}Expand description
The 4 possible TNID variants.
Similar to UUID variants, TNID variants have different construction that makes them useful for different situations.
Variants§
V0
V0 is most like UUIDv7, and is meant to be time-sortable. See Tnid::new_v0.
V1
V1 is most like UUIDv4, and is meant to maximize entropy (randomness). See Tnid::new_v1.
V2
V2 is undefined but reserved for future use.
V3
V3 is undefined but reserved for future use.
Implementations§
Source§impl TnidVariant
impl TnidVariant
Sourcepub fn from_u8(variant_bits: u8) -> TnidVariant
pub fn from_u8(variant_bits: u8) -> TnidVariant
Converts a u8 to a TnidVariant.
Only the bottom 2 bits are used to determine the variant (ignores the top 6 bits).
For example, 0b0000_0000, 0b0000_0100, and 0b1111_1100 all have bottom 2 bits of 00,
so they all map to V0.
§Examples
use tnid::TnidVariant;
// Bottom 2 bits are 0b00 -> V0
assert_eq!(TnidVariant::from_u8(0b00000000), TnidVariant::V0);
assert_eq!(TnidVariant::from_u8(0b11111100), TnidVariant::V0);
// Bottom 2 bits are 0b01 -> V1
assert_eq!(TnidVariant::from_u8(0b00000001), TnidVariant::V1);
assert_eq!(TnidVariant::from_u8(0b11111101), TnidVariant::V1);Trait Implementations§
Source§impl Debug for TnidVariant
impl Debug for TnidVariant
Source§impl PartialEq for TnidVariant
impl PartialEq for TnidVariant
impl Eq for TnidVariant
impl StructuralPartialEq for TnidVariant
Auto Trait Implementations§
impl Freeze for TnidVariant
impl RefUnwindSafe for TnidVariant
impl Send for TnidVariant
impl Sync for TnidVariant
impl Unpin for TnidVariant
impl UnwindSafe for TnidVariant
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
Mutably borrows from an owned value. Read more