Expand description
§XUID
XUID (eXtended Unique IDentifier) enhances UUIDs with a short type prefix while keeping the standard 128-bit UUID size. XUIDs are encoded in base32 (rather than base16), so they never exceed 36 characters and are more human-readable.
This is a Rust port of the Go library KarpelesLab/xuid. The string format is
byte-for-byte compatible: an XUID produced by either implementation parses cleanly
in the other.
use xuid::Xuid;
// Time-ordered (UUIDv7) by default — sortable and index-friendly.
let id = Xuid::new("user");
println!("{id}"); // e.g. user-h4nu2n-zu3f-dmnn-kguv-6f643nei
// Parse back, including from a plain UUID string.
let parsed: Xuid = "user-h4nu2n-zu3f-dmnn-kguv-6f643nei".parse().unwrap();
assert_eq!(parsed.prefix(), "user");
// Deterministic IDs from a key.
let a = Xuid::from_key_prefix("specific-resource-name", "res");
let b = Xuid::from_key_prefix("specific-resource-name", "res");
assert_eq!(a, b);Structs§
Enums§
- Error
- Errors returned by the xuid library.