id-forge 1.0.0

Typed, high-performance unique ID generation for Rust. UUID v4/v7, ULID, Snowflake, NanoID, and custom epoch-based schemes in one zero-dependency library. Monotonic, distributed-safe, sortable variants.
Documentation

What it does

Every project needs unique identifiers. Today's options force you to mix and match crates: uuid for UUIDs, ulid for ULIDs, snowflake-rs for Snowflakes, nanoid for NanoIDs. Each has its own conventions, MSRV, and dependency tree.

id-forge puts every common ID scheme in one crate with zero runtime dependencies and MSRV 1.75.

Quick start

use id_forge::{uuid::Uuid, ulid::Ulid, snowflake::Snowflake, nanoid};

let id = Uuid::v4();                     // "f47ac10b-58cc-4372-..."
let id = Uuid::v7();                     // time-ordered UUID
let id = Ulid::new();                    // "01H6X3VPK..."
let gen = Snowflake::new(1);             // worker ID = 1
let id: u64 = gen.next_id();             // 64-bit snowflake
let id = nanoid::generate();             // "VNqJgL1..."
let id = nanoid::with_length(8);         // shorter NanoID

Schemes supported

Scheme Size Sortable Distributed-safe Use case
UUID v4 128 bits No Yes Random identifiers, no time component needed
UUID v7 128 bits Yes Yes Time-ordered random ID (preferred over v4 for DB primary keys)
ULID 128 bits Yes Yes Sortable, URL-friendly identifiers
Snowflake 64 bits Yes Yes (with worker ID) Fits in u64, time-ordered, suited for high-throughput
NanoID configurable No Yes URL-safe short IDs, configurable alphabet

Feature flags

[dependencies]
id-forge = "1"                                          # all schemes (default)
id-forge = { version = "1", default-features = false } # nothing (compile errors if you use anything)
id-forge = { version = "1", default-features = false, features = ["uuid"] }  # just UUIDs

Minimum supported Rust version

1.75 — pinned in Cargo.toml and verified by CI.

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.