#id
Xu 0.16.0 API
import: #id
counts: 5 functions, 1 methods, 1 types, 0 constants, 0 method sets
Sortable identifiers for messages / files / sessions. ULID (Crockford base32, 26 chars): 48-bit ms timestamp + 80-bit random. UUIDv7 (RFC 9562): 48-bit unix ms + version/variant + 62-bit random, canonical 8-4-4-4-12 lowercase hex. Monotonic ULID: same-millisecond ids increment the random field so lexicographic order matches issue order on one process. Xu forbids package mutable globals — keep a Monotonic generator per producer.
new_ulid
Purpose
new_ulid returns a 26-char Crockford ULID for the current wall clock. Throws on failure; handle the error or propagate it to the caller.
Parameters
No arguments are required.
Returns
string — result string
struct Monotonic
Purpose
Monotonic keeps the last ULID so same-ms ids stay ordered.
Public fields
This type has no public fields.
new_monotonic
pub fn new_monotonic() Monotonic
Purpose
Construct monotonic.
Parameters
No arguments are required.
Returns
Monotonic — a value of this type
($&Monotonic) next
pub fn (m $&Monotonic) next() string
Purpose
next returns a ULID >= the previous one from this generator (process-local). Throws on failure; handle the error or propagate it to the caller.
Parameters
m $&Monotonic- The
Monotonic instance used by this call (exclusive borrow).
Returns
string — result string
ulid_time_ms
pub fn ulid_time_ms(s string) int
Purpose
ulid_time_ms extracts the 48-bit timestamp from a 26-char ULID. Returns -1 on bad input.
Parameters
s string- source string (string)
Returns
int — a value of this type
new_uuid_v7
pub fn new_uuid_v7() string
Purpose
new_uuid_v7 returns a canonical UUIDv7 (8-4-4-4-12 lowercase hex). Throws on failure; handle the error or propagate it to the caller.
Parameters
No arguments are required.
Returns
string — result string
uuid_v7_time_ms
pub fn uuid_v7_time_ms(s string) int
Purpose
uuid_v7_time_ms extracts unix ms from a UUIDv7 string. -1 if invalid.
Parameters
s string- source string (string)
Returns
int — a value of this type