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.3` closes the 0.9.x algorithm cycle: NanoID now uses the
30//! shared xoshiro256\*\* generator with bias-free power-of-two
31//! rejection sampling and grows a `try_custom` strict entry point
32//! plus an `AlphabetError` type. UUID v4/v7 (`0.9.0`), ULID (`0.9.1`),
33//! and Snowflake (`0.9.2`) are unchanged. The next release is the
34//! 1.0.0 API freeze.
35
36#![cfg_attr(docsrs, feature(doc_cfg))]
37#![cfg_attr(not(feature = "std"), no_std)]
38#![warn(missing_docs)]
39#![warn(rust_2018_idioms)]
40
41#[cfg(any(feature = "uuid", feature = "ulid", feature = "nanoid"))]
42mod rng;
43
44#[cfg(feature = "uuid")]
45pub mod uuid;
46
47#[cfg(feature = "ulid")]
48pub mod ulid;
49
50#[cfg(feature = "snowflake")]
51pub mod snowflake;
52
53#[cfg(feature = "nanoid")]
54pub mod nanoid;