Skip to main content

Uuid

Struct Uuid 

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

A 128-bit UUID, stored big-endian (RFC 9562 byte order).

Implementations§

Source§

impl Uuid

Source

pub const NIL: Uuid

The nil UUID — all 128 bits zero (00000000-0000-0000-0000-000000000000).

Source

pub const MAX: Uuid

The max UUID — all 128 bits one (ffffffff-ffff-ffff-ffff-ffffffffffff), RFC 9562 §5.10.

Source

pub const NAMESPACE_DNS: Uuid

Namespace ID for fully-qualified domain names (RFC 9562 Appendix A).

Source

pub const NAMESPACE_URL: Uuid

Namespace ID for URLs.

Source

pub const NAMESPACE_OID: Uuid

Namespace ID for ISO OIDs.

Source

pub const NAMESPACE_X500: Uuid

Namespace ID for X.500 DNs.

Source

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

Wrap raw big-endian bytes verbatim (no version/variant stamping).

Source

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

The raw 16 big-endian bytes.

Source

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

Borrow the raw 16 big-endian bytes.

Source

pub fn is_nil(&self) -> bool

True for the all-zero nil UUID.

Source

pub fn is_max(&self) -> bool

True for the all-one max UUID.

Source

pub fn version(&self) -> u8

The version number (the high nibble of byte 6): 1–8 for the defined versions, 0 for nil, 0xF for max. A pure read of the field — it does not assert the id was generated correctly.

Source

pub fn variant(&self) -> Variant

The variant (the high bits of byte 8). Everything we generate is Variant::Rfc4122.

Source

pub fn new_v1(timestamp_100ns: u64, clock_seq: u16, node: [u8; 6]) -> Uuid

Version 1: a 60-bit gregorian timestamp (100-ns ticks since 1582-10-15), a 14-bit clock sequence, and a 48-bit node id. Layout is little-end-first on time (not time-sortable; that is what v6 fixes).

Source

pub fn new_v6(timestamp_100ns: u64, clock_seq: u16, node: [u8; 6]) -> Uuid

Version 6: the v1 fields with the timestamp reordered most-significant-first, so byte order sorts chronologically (RFC 9562 §5.6) — a drop-in, sortable replacement for v1.

Source

pub fn new_v3(namespace: Uuid, name: &[u8]) -> Uuid

Version 3: MD5 of namespace bytes followed by name (RFC 9562 §5.3). Name-based and stable — the same namespace+name always yields the same id. This is the native REFERENCE ORACLE: the language’s uuid_v3 is written in Logos (assets/std/uuid.lg, over the Logos md5Digest) and is proven byte-exact against this and the uuid/md-5 crates — it is not on any language path.

Source

pub fn new_v5(namespace: Uuid, name: &[u8]) -> Uuid

Version 5: SHA-1 of namespace bytes followed by name, truncated to 16 bytes (RFC 9562 §5.5). Name-based and stable; preferred over v3. The native REFERENCE ORACLE for the Logos uuid_v5 (uuid.lg, over sha1Digest) — see Uuid::new_v3.

Source

pub fn new_v4(random: [u8; 16]) -> Uuid

Version 4: 122 bits of supplied randomness (RFC 9562 §5.4). The 6 version/variant bits are overwritten, so all 16 bytes of entropy may be passed.

Source

pub fn new_v7(unix_ms: u64, random: [u8; 10]) -> Uuid

Version 7: a 48-bit big-endian Unix-millisecond timestamp followed by 74 bits of randomness (RFC 9562 §5.7). Time-ordered (byte order sorts by creation time) — the modern default.

Source

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

Version 8: vendor/experimental — the 16 bytes are taken as given, with only the version and variant bits stamped (RFC 9562 §5.8).

Source

pub fn parse(input: &str) -> Option<Uuid>

Parse a UUID from text. Accepts the canonical hyphenated form, the 32-hex simple form, the braced {…} form, and the urn:uuid:… form; case-insensitive. Returns None on any other shape, a bad length, or a non-hex digit — never panics.

Source

pub fn parse_many(packed: &[u8]) -> Option<Vec<Uuid>>

Parse many canonical 36-char UUIDs packed back-to-back (36·n bytes) into a Vec<Uuid> — the bulk read path (a DB column / log-ingest stream). Loops the SIMD decode core directly with no per-id trim/dispatch overhead, into a single pre-sized allocation. None if the length isn’t a multiple of 36 or any record is malformed. Pairs with encode_many (the bulk write path).

Trait Implementations§

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

Source§

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

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

impl Display for Uuid

Source§

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

Canonical lowercase hyphenated form, 8-4-4-4-12 (RFC 9562 §4).

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 (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 Copy for Uuid

Source§

impl Eq for Uuid

Source§

impl StructuralPartialEq for Uuid

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