std/uuid
On this page
Index
- type
Uuid- method
Uuid.version - method
Uuid.bytes - method
Uuid.display - method
Uuid.debug
- method
- type
UuidErr- method
UuidErr.display
- method
- fn
v4 - fn
v7 - fn
parse - fn
from_bytes - fn
nil
Types
Uuid
struct Uuid {
hi: Int
lo: Int
} derive OrdA UUID: its 16 bytes as two words. u.display() (or "${u}") is its
canonical text, u.bytes() its bytes, u < v the order of its bytes.
@internal: use u.bytes() and uuid.from_bytes(b), u.display() and uuid.parse(s), or u < v
Uuid.version
fn (u: Uuid) version() -> IntUuid.bytes
fn (u: Uuid) bytes() -> BytesUuid.display
fn (u: Uuid) display() -> StrUuid.debug
fn (u: Uuid) debug() -> StrUuid("<its text>"), as when a Uuid was its text.
UuidErr
struct UuidErr {
msg: Str
}Displays as google/uuid’s texts: invalid UUID length: 35,
invalid UUID format, invalid urn prefix: "urn:uid::".
UuidErr.display
fn (e: UuidErr) display() -> StrFunctions
v4
fn v4(r: Rand) -> Uuid uses randA random UUID (version 4): 122 random bits.
v7
fn v7(r: Rand, c: Clock) -> Uuid uses (rand, clock)A time ordered UUID (version 7): the Unix time in milliseconds, then 74 random bits, so keys made later sort later (to the millisecond).
parse
fn parse(s: Str) -> Uuid ! UuidErrxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, urn:uuid:…, {…}, or 32 hex digits (google/uuid’s Parse), in either case.
from_bytes
fn from_bytes(b: Bytes) -> Uuid ! UuidErrThe 16 bytes.
nil
fn nil() -> Uuid00000000-0000-0000-0000-000000000000.
↑ index