Skip to main content

id_forge/
lib.rs

1//! # id-forge
2//!
3//! Typed, high-performance unique ID generation for Rust. Every common
4//! ID scheme in one zero-dependency library:
5//!
6//! - **[`uuid`]**: UUID v4 (random) and v7 (time-ordered)
7//! - **[`ulid`]**: Universally Unique Lexicographically Sortable ID
8//! - **[`snowflake`]**: Twitter Snowflake-style 64-bit IDs (epoch + worker + sequence)
9//! - **[`nanoid`]**: URL-safe random strings of any length
10//!
11//! ## Quick example
12//!
13//! ```
14//! use id_forge::uuid::Uuid;
15//!
16//! let id = Uuid::v4();
17//! println!("{id}");
18//! ```
19//!
20//! ## Why this library exists
21//!
22//! Today's options are fragmented: `uuid` for UUIDs, `ulid` for ULIDs,
23//! `snowflake-rs` for snowflakes, `nanoid` for NanoIDs. Each has its
24//! own quirks, MSRV, and dependencies. `id-forge` is one zero-dep
25//! crate at MSRV 1.75 covering every scheme.
26//!
27//! ## Status
28//!
29//! `v0.9.1` ships the real ULID implementation: spec-compliant
30//! Crockford base32, 80-bit monotonic factory inside a millisecond,
31//! and a case-insensitive parser. UUID v4/v7 (from `0.9.0`) and ULID
32//! now share an inline xoshiro256\*\* random source. Snowflake and
33//! NanoID remain placeholders until `0.9.2` and `0.9.3`.
34
35#![cfg_attr(docsrs, feature(doc_cfg))]
36#![cfg_attr(not(feature = "std"), no_std)]
37#![warn(missing_docs)]
38#![warn(rust_2018_idioms)]
39
40#[cfg(any(feature = "uuid", feature = "ulid", feature = "nanoid"))]
41mod rng;
42
43#[cfg(feature = "uuid")]
44pub mod uuid;
45
46#[cfg(feature = "ulid")]
47pub mod ulid;
48
49#[cfg(feature = "snowflake")]
50pub mod snowflake;
51
52#[cfg(feature = "nanoid")]
53pub mod nanoid;