Struct uuid7::Uuid

source ·
#[repr(transparent)]
pub struct Uuid(/* private fields */);
Expand description

Represents a Universally Unique IDentifier.

Implementations§

source§

impl Uuid

source

pub const NIL: Self = _

The Nil UUID value (00000000-0000-0000-0000-000000000000).

source

pub const MAX: Self = _

The Max UUID value (ffffffff-ffff-ffff-ffff-ffffffffffff).

source

pub const fn as_bytes(&self) -> &[u8; 16]

Returns a reference to the underlying byte array.

source

pub const fn from_fields_v7(unix_ts_ms: u64, rand_a: u16, rand_b: u64) -> Self

Creates a UUID byte array from UUIDv7 field values.

source

pub const fn encode(&self) -> FStr<36>

Returns the 8-4-4-4-12 hexadecimal string representation stored in a stack-allocated string-like type that can be handled like String through Deref<Target = str> and other common traits.

Examples
use uuid7::Uuid;

let x = "01809424-3e59-7c05-9219-566f82fff672".parse::<Uuid>()?;
let y = x.encode();
assert_eq!(y, "01809424-3e59-7c05-9219-566f82fff672");
assert_eq!(format!("{}", y), "01809424-3e59-7c05-9219-566f82fff672");
source

pub const fn encode_hex(&self) -> FStr<32>

Returns the 32-digit hexadecimal string representation without hyphens stored in a stack-allocated string-like type that can be handled like String through Deref<Target = str> and other common traits.

Examples
use uuid7::Uuid;

let x = "01809424-3e59-7c05-9219-566f82fff672".parse::<Uuid>()?;
let y = x.encode_hex();
assert_eq!(y, "018094243e597c059219566f82fff672");
assert_eq!(format!("{}", y), "018094243e597c059219566f82fff672");
source

pub fn variant(&self) -> Variant

Reports the variant field value of the UUID or, if appropriate, Nil or Max.

For convenience, this function reports Variant::Nil or Variant::Max if self represents the Nil or Max UUID, although the Nil and Max UUIDs are technically subsumed under the variants 0b0 and 0b111, respectively.

source

pub fn version(&self) -> Option<u8>

Returns the version field value of the UUID or None if self does not have the variant field value of 0b10.

Trait Implementations§

source§

impl AsRef<[u8]> for Uuid

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Uuid

source§

fn clone(&self) -> Uuid

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Uuid

source§

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

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

impl Default for Uuid

source§

fn default() -> Uuid

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Uuid

Available on crate feature serde only.
source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Uuid

source§

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

Returns the 8-4-4-4-12 canonical hexadecimal string representation.

source§

impl From<[u8; 16]> for Uuid

source§

fn from(src: [u8; 16]) -> Self

Converts to this type from the input type.
source§

impl From<Uuid> for [u8; 16]

source§

fn from(src: Uuid) -> Self

Converts to this type from the input type.
source§

impl From<Uuid> for String

Available on crate feature std only.
source§

fn from(src: Uuid) -> Self

Converts to this type from the input type.
source§

impl From<Uuid> for Uuid

Available on crate feature uuid only.
source§

fn from(src: Uuid) -> Self

Converts to this type from the input type.
source§

impl From<Uuid> for Uuid

Available on crate feature uuid only.
source§

fn from(src: Uuid) -> Self

Converts to this type from the input type.
source§

impl From<Uuid> for u128

source§

fn from(src: Uuid) -> Self

Converts to this type from the input type.
source§

impl From<u128> for Uuid

source§

fn from(src: u128) -> Self

Converts to this type from the input type.
source§

impl FromStr for Uuid

source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Creates an object from the 8-4-4-4-12 hexadecimal string representation.

§

type Err = ParseError

The associated error which can be returned from parsing.
source§

impl Hash for Uuid

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Uuid

source§

fn cmp(&self, other: &Uuid) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Uuid> for Uuid

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Uuid> for Uuid

source§

fn partial_cmp(&self, other: &Uuid) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Uuid

Available on crate feature serde only.
source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
source§

impl TryFrom<String> for Uuid

Available on crate feature std only.
§

type Error = ParseError

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

fn try_from(src: String) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for Uuid

source§

impl Eq for Uuid

source§

impl StructuralEq for Uuid

source§

impl StructuralPartialEq for Uuid

Auto Trait Implementations§

§

impl RefUnwindSafe for Uuid

§

impl Send for Uuid

§

impl Sync for Uuid

§

impl Unpin for Uuid

§

impl UnwindSafe for Uuid

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,