Skip to main content

Uuid

Struct Uuid 

Source
pub struct Uuid(/* private fields */);

Implementations§

Source§

impl Uuid

Source

pub fn encode_lower<'buf>(&self, buffer: &'buf mut [u8]) -> &'buf mut str

Source

pub const fn encode_buffer() -> [u8; 36]

Source§

impl Uuid

Source

pub fn new_v4() -> Uuid

Source§

impl Uuid

Source

pub fn new_v7() -> Uuid

Create a new version 7 UUID using a time value and random bytes.

When the std feature is enabled, you can also use Uuid::new_v7.

Note that usage of this method requires the v7 feature of this crate to be enabled.

§References
Source

pub fn new_v7_with_timestamp(unix_millis: u64) -> Self

Source§

impl Uuid

Source

pub fn new_v8(buf: [u8; 16]) -> Uuid

Source§

impl Uuid

Source

pub const fn nil() -> Uuid

The ‘nil UUID’ (all zeros).

The nil UUID is a special form of UUID that is specified to have all 128 bits set to zero.

§References
§Examples

Basic usage:

let uuid = Uuid::nil();

assert_eq!(
    "00000000-0000-0000-0000-000000000000",
    uuid.hyphenated().to_string(),
);
Source

pub const fn get_version(&self) -> Option<Version>

Source

pub const fn is_nil(&self) -> bool

Source

pub const fn as_u128(&self) -> u128

Source

pub const fn from_u128(v: u128) -> Self

Source

pub const fn from_bytes(bytes: [u8; 16]) -> Uuid

Source

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

Source

pub fn from_slice(b: &[u8]) -> Result<Uuid, Error>

Source

pub fn parse_str(input: &str) -> Result<Uuid, Error>

Source§

impl Uuid

Source

pub fn hyphenated(&self) -> String

Source

pub fn as_hyphenated(&self) -> String

Source

pub fn simple(&self) -> Self

Source

pub fn as_simple(&self) -> Self

Trait Implementations§

Source§

impl AsRef<Uuid> for Uuid

Source§

fn as_ref(&self) -> &Uuid

Converts this type into a shared reference of the (usually inferred) input type.
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 duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Uuid

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() -> Self

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

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

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

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

impl Eq for Uuid

Source§

impl From<Uuid> for String

Source§

fn from(uuid: Uuid) -> Self

Converts to this type from the input type.
Source§

impl From<Uuid> for Vec<u8>

Source§

fn from(value: Uuid) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Uuid

Source§

type Err = Error

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

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

Parses a string s to return a value of this type. Read more
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 LowerHex for Uuid

Source§

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

Formats the value using the given formatter. 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 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

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

impl PartialEq for Uuid

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 PartialOrd 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 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Uuid

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 StructuralPartialEq for Uuid

Source§

impl TryFrom<&str> for Uuid

Source§

type Error = Error

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

fn try_from(uuid_str: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Vec<u8>> for Uuid

Source§

type Error = Error

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

fn try_from(value: Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl UpperHex for Uuid

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Uuid

§

impl RefUnwindSafe for Uuid

§

impl Send for Uuid

§

impl Sync for Uuid

§

impl Unpin for Uuid

§

impl UnsafeUnpin for Uuid

§

impl UnwindSafe for Uuid

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
§

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

§

fn vzip(self) -> V