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//! ## Stability
28//!
29//! `v1.0.0` is the API freeze. Every public item visible from this
30//! crate is committed under strict SemVer per
31//! [`docs/STABILITY.md`](https://github.com/jamesgober/id-forge/blob/main/docs/STABILITY.md).
32//! Within the `1.x` line, additive changes are minor releases; any
33//! breaking change requires a `2.0`. MSRV is Rust 1.75.
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;