1 unstable release

0.1.0-alpha.0 Nov 28, 2024
0.0.0 Nov 20, 2021

#648 in Algorithms

Download history 3/week @ 2024-09-30 146/week @ 2024-11-25 19/week @ 2024-12-02 10/week @ 2024-12-09

175 downloads per month

MPL-2.0 license

13KB
284 lines

tuid-rs

Sequential UUID generator.

This generator uses a time-based component as the shared prefix. The prefix is non-monotonic, and wraps around every once in a while to achieve a dense key space.

Installation

If using cargo-edit

cargo add tuid

or add it yourself to Cargo.toml

[dependencies]
tuid = "0.1.0-alpha"

Usage

fn main() {
  use rand::Rng;

  let mut rng = rand::thread_rng();
  let tid = tuid::gen::default(rng.gen(), rng.gen());
  let uid = tid.as_uuid();
  let hex = tid.as_hex();
}

Dependencies

~0.3–0.8MB
~15K SLoC