Skip to content
/ xid-rs Public
forked from kazk/xid-rs

Globally unique sortable id generator. A Rust port of https://github.com/rs/xid.

License

Notifications You must be signed in to change notification settings

J3A/xid-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xid

CI Crates.io API reference

Globally unique sortable id generator. A Rust port of https://github.com/rs/xid.

The binary representation is compatible with the Mongo DB 12-byte ObjectId. The value consists of:

  • a 4-byte timestamp value in seconds since the Unix epoch
  • a 3-byte value based on the machine identifier
  • a 2-byte value based on the process id
  • a 3-byte incrementing counter, initialized to a random value

The string representation is 20 bytes, using a base32 hex variant with characters [0-9a-v] to retain the sortable property of the id.

See the original xid project for more details.

Usage

println!("{}", xid::new().to_string()); //=> bva9lbqn1bt68k8mj62g

Examples

Packages

No packages published

Languages

  • Rust 100.0%