TNID
UUID-compatible IDs with names and compile-time type safety.
TNIDs are UUIDv8-compatible identifiers that include a human-readable name and can be strictly typed at compile time.
use ;
;
// Create a time-ordered ID (like UUIDv7)
let user_id = new_time_ordered;
println!; // user.Br2flcNDfF6LYICnT
// Or a high-entropy ID (like UUIDv4)
let session_id = new_high_entropy;
Why TNIDs?
- Type-safe:
Tnid<User>andTnid<Post>are different types. Accidentally passing a post ID to auserfunction? Compile error. - Named: IDs include a human-readable name prefix. See
user.Br2flcNDfF6LYICnTin your logs and instantly know what it is. - UUID-compatible: TNIDs are valid UUIDv8s that work directly with Postgres UUID columns and UUID-expecting APIs.
- Compile-time validated: Try to create a TNID with name "INVALID"? Your code won't even compile.
- Sortable strings: Unlike UUID hex (case-insensitive mess), TNID strings sort correctly and have exactly one representation.
Status
Beta: The TNID spec is still being finalized and shouldn't be relied on for production use yet. This implementation tracks the evolving spec.
A full specification site will be available at tnid.info.
Installation
Documentation
See the API documentation for complete details, examples, and feature flags.
License
MIT