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 ;
let id = v4; // "f47ac10b-58cc-4372-..."
let id = v7; // time-ordered UUID
let id = new; // "01H6X3VPK..."
let gen = new; // worker ID = 1
let id: u64 = gen.next_id; // 64-bit snowflake
let id = generate; // "VNqJgL1..."
let id = with_length; // 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
[]
= "0.9.3" # all schemes (default)
= { = "0.9.3", = false } # nothing (compile errors if you use anything)
= { = "0.9.3", = false, = ["uuid"] } # just UUIDs
Minimum supported Rust version
1.75 — pinned in Cargo.toml and verified by CI.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
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.