xid

Crates.ioxid
lib.rsxid
version1.1.1
sourcesrc
created_at2020-12-13 00:52:32.026911
updated_at2024-04-23 19:03:45.811312
descriptionGlobally unique sortable id generator. A Rust port of https://github.com/rs/xid.
homepagehttps://github.com/kazk/xid-rs
repositoryhttps://github.com/kazk/xid-rs
max_upload_size
id322289
size42,496
kazk (kazk)

documentation

README

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()); //=> bva9lbqn1bt68k8mj62g

Examples

Commit count: 35

cargo fmt