pub struct Uuid(/* private fields */);Expand description
A 128-bit UUID, stored big-endian (RFC 9562 byte order).
Implementations§
Source§impl Uuid
impl Uuid
Sourcepub const MAX: Uuid
pub const MAX: Uuid
The max UUID — all 128 bits one (ffffffff-ffff-ffff-ffff-ffffffffffff), RFC 9562 §5.10.
Sourcepub const NAMESPACE_DNS: Uuid
pub const NAMESPACE_DNS: Uuid
Namespace ID for fully-qualified domain names (RFC 9562 Appendix A).
Sourcepub const NAMESPACE_URL: Uuid
pub const NAMESPACE_URL: Uuid
Namespace ID for URLs.
Sourcepub const NAMESPACE_OID: Uuid
pub const NAMESPACE_OID: Uuid
Namespace ID for ISO OIDs.
Sourcepub const NAMESPACE_X500: Uuid
pub const NAMESPACE_X500: Uuid
Namespace ID for X.500 DNs.
Sourcepub const fn from_bytes(bytes: [u8; 16]) -> Uuid
pub const fn from_bytes(bytes: [u8; 16]) -> Uuid
Wrap raw big-endian bytes verbatim (no version/variant stamping).
Sourcepub fn version(&self) -> u8
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.
Sourcepub fn variant(&self) -> Variant
pub fn variant(&self) -> Variant
The variant (the high bits of byte 8). Everything we generate is Variant::Rfc4122.
Sourcepub fn new_v1(timestamp_100ns: u64, clock_seq: u16, node: [u8; 6]) -> Uuid
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).
Sourcepub fn new_v6(timestamp_100ns: u64, clock_seq: u16, node: [u8; 6]) -> Uuid
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.
Sourcepub fn new_v3(namespace: Uuid, name: &[u8]) -> Uuid
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.
Sourcepub fn new_v5(namespace: Uuid, name: &[u8]) -> Uuid
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.
Sourcepub fn new_v4(random: [u8; 16]) -> Uuid
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.
Sourcepub fn new_v7(unix_ms: u64, random: [u8; 10]) -> Uuid
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.
Sourcepub fn new_v8(bytes: [u8; 16]) -> Uuid
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).
Sourcepub fn parse(input: &str) -> Option<Uuid>
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.
Sourcepub fn parse_many(packed: &[u8]) -> Option<Vec<Uuid>>
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).