TnidVariant

Enum TnidVariant 

Source
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

Source

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);
Source

pub fn as_u8(&self) -> u8

Returns the u8 representation of this variant.

§Examples
use tnid::TnidVariant;

assert_eq!(TnidVariant::V0.as_u8(), 0);
assert_eq!(TnidVariant::V1.as_u8(), 1);
assert_eq!(TnidVariant::V2.as_u8(), 2);
assert_eq!(TnidVariant::V3.as_u8(), 3);

Trait Implementations§

Source§

impl Debug for TnidVariant

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for TnidVariant

Source§

fn eq(&self, other: &TnidVariant) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for TnidVariant

Source§

impl StructuralPartialEq for TnidVariant

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V