# Sigid
[](https://crates.io/crates/sigid-core)
[](https://docs.rs/sigid-core)
[](LICENSE)
[](https://www.rust-lang.org)
[](https://docs.rs/sigid-core)
> **Sig**il + **ID** β Zero-dependency unique identifiers.
---
## Table of Contents
- [Features](#-features)
- [Quick Start](#-quick-start)
- [Modules](#-modules)
- [Architecture](#-architecture)
- [Installation](#-installation)
- [License](#-license)
---
## Features
- **π° Three Layers**: Core β Flexible β Enterprise. Choose only the abstraction level you need.
- **β‘ Zero Dependencies**: The `Core` crate has zero external dependencies and works natively in `no_std`.
- **π― 26 Characters**: Encoded in human-readable **Crockford Base32** format.
- **π¦ 128 Bits**: Layout consists of Timestamp (48) + Worker ID (16) + Counter (14) + Random (50).
- **π Chronologically Sortable**: Lexicographically sortable by time of creation (database index friendly).
- **π Thread-Safe**: Lock-free architecture utilizing atomic operations for extreme throughput.
- **π WASM Ready**: Works out-of-the-box in browser environments via `getrandom/js`.
- **π Type-Safe**: Wrapped in a specialized `SigId26` type instead of unsafe raw strings.
- **β
Checksum Protection**: Optional validation using ISO 7064 Mod 37,36 with auto-correction for human typing typos (`O` β `0`, `I`/`L` β `1`).
- **π¨ Highly Customizable**: Fine-tune length, custom alphabets, static/dynamic text prefixes, and raw layout components.
---
## Architecture
### Bit Layout (128 bits)
```text
ββββββββββββββββββββββββββ¬βββββββββββββββββββ¬βββββββββββββββ¬βββββββββββββββββ
β Timestamp (48) β Worker ID (16) β Counter (14) β Random (50) β
ββββββββββββββββββββββββββ΄βββββββββββββββββββ΄βββββββββββββββ΄βββββββββββββββββ
β
βΌ
Crockford Base32 (26 characters)
β
βΌ
"01GJ8X9Z000000000000000000"
```
### Directory Structure
```text
sigid/
βββ core/ # Zero-dependency, no_std core state machine
βββ flexible/ # Layout customizer (alphabets, prefixes, checksums)
βββ enterprise/ # Distributed cluster-scale engine with cloud scaling
```
---
## Quick Start
Add the unified umbrella crate to your `Cargo.toml`:
```toml
[dependencies]
sigid = "1.0.0"
```
### 1. Simple (Core)
```rust
use sigid::core::{Generator, SigId26};
fn main() {
let mut gen = Generator::new(0x123456789abcdef);
let id = gen.generate(1234567890).unwrap();
println!("{}", id); // Outputs: 0004K5G2T8000FS803B5D7G1PG
}
```
### 2. Flexible (Flexible)
```rust
use sigid::flexible::{Generator, Alphabet};
fn main() {
let mut gen = Generator::new()
.length(24)
.alphabet(Alphabet::Base64)
.prefix("user_")
.build();
let id = gen.generate(1234567890).unwrap();
println!("{}", id); // Outputs: user_...
}
```
### 3. Industrial (Enterprise)
```rust
use sigid::enterprise::{Generator, WorkerId, SigIdUuidExt};
fn main() {
let mut gen = Generator::new()
.with_worker_id(WorkerId::new(42).unwrap())
.build();
let id = gen.generate(1234567890).unwrap();
// Zero-cost conversion to standard UUIDv7 layout
let uuid = id.to_uuid();
}
```
---
## Module Specification
| **`sigid-core`** | Minimalistic, ultra-fast core machine | **0** | `no_std` / `WASM` |
| **`sigid-flexible`** | Custom alphabets and text prefix builder | Optional (`serde`) | `std` / `no_std` |
| **`sigid-enterprise`** | Cloud-native clustered engine | Optional (`uuid`) | `std` |
---
## Layer Installation
### Core-Only (Absolute minimalism):
```toml
[dependencies]
sigid-core = "1.0.0"
```
### Customization and Serialization features:
```toml
[dependencies]
sigid-flexible = { version = "1.0.0", features = ["serde"] }
```
### Enterprise Clustered Infrastructure:
```toml
[dependencies]
sigid-enterprise = { version = "1.0.0", features = ["full"] }
```
---
## License
This project is dually licensed under your choice of:
* **MIT License** ([LICENSE-MIT](LICENSE-MIT))
* **Apache License, Version 2.0** ([LICENSE-APACHE](LICENSE-APACHE))
---
## Translations
* [Π ΡΡΡΠΊΠΈΠΉ](README.md)
* [EspaΓ±ol](README_ES.md)
* [δΈζ](README_ZH.md)
---
If you like this project, please give it a star on GitHub: [github.com/dmitrymarison/sigid](https://github.com/dmitrymarison/sigid)