Crate puid

source ·
Expand description

A unique ID generator using a given prefix with ch_-style.

The ID is a composition of:

  • Prefix.
  • Underscore character.
  • Timestamp turned into Base-36.
  • A u8 type counter.
  • The OS-assigned process identifier turned into Base-36.
  • Sequence the random characters.

Examples

Using the default random length

use puid::Puid;

fn main() {
    let id = Puid::builder().prefix("foo").unwrap().build().unwrap(); // foo_l2ok01bl0yq2i2ElC7zWaCR8
}

Using custom random length

use puid::Puid;

fn main() {
    let id = Puid::builder().prefix("bar").unwrap().entropy(24).build().unwrap(); // bar_l2ok1yvk1z4aOz1P7kecCTaqUGq1wgKfHGZC
}

Modules

The types error.

Macros

puidDeprecated
Abstract the ID generation for easy usage.

Structs

The exposed struct for generate Puids.