o192 — Rust
Rust reference implementation of ORION-192 — Ordered, Resilient, Independent, Opaque-ish, Non-coordinated 192-bit identifiers for distributed systems.
ORION-192 produces fixed-width, URL-safe, lexicographically sortable IDs without a central coordinator, worker ID, or machine identity in the wire format. This crate is byte-compatible with the JavaScript and Python reference implementations.
Highlights
- Single small dependency (
getrandom) for OS CSPRNG access; no transitive bloat. #![forbid(unsafe_code)]and#![warn(missing_docs)]enforced crate-wide.- Optional
serdefeature forSerialize/DeserializeonParsedOrionId. - Strictly monotonic within a generator instance, including across clock rollback.
- Wire-compatible with the JavaScript and Python packages — same 24-byte layout, same 32-character canonical form.
Install
With the optional serde feature:
Quick start
use OrionIdGenerator;
Private epoch
use OrionIdGenerator;
let mut gen = with_epoch_ms?; // 2025-01-01 UTC
let id = gen.next?;
Parsing
use ;
let id = "0Pu_iDKVO9012BwIEM28oFojPMWLWeLU";
assert!;
let view = parse?;
println!;
API
| Item | Purpose |
|---|---|
OrionIdGenerator |
Stateful generator with strict local monotonicity. |
encode_sortable64 / decode_sortable64 |
Wire-format codec. |
parse / is_valid |
Structured view and syntactic validation. |
ParsedOrionId |
Field-level view of a parsed ID. |
OrionIdError |
Single error enum covering every failure mode. |
Every public item is documented; run cargo doc --open for the full reference, or browse it on docs.rs.
Cargo features
| Feature | Default | Effect |
|---|---|---|
serde |
off | Implements serde::{Serialize, Deserialize} for ParsedOrionId. |
Minimum Supported Rust Version
This crate supports Rust 1.74 and newer. MSRV bumps are treated as minor-version releases and noted in the changelog.
Performance
A single OrionIdGenerator produces roughly 2–6 M IDs/second on a modern laptop. Numbers are indicative — run the bundled example on your target hardware:
Status
ORION-192 is at spec v0 — implementation-complete, cross-language conformant, and wire-frozen. See the project status for the full stability statement.
Specification & related
- Specification (
SPEC.md) — normative wire format and algorithm. - Design rationale (
docs/RATIONALE.md) — why 192 bits, why this layout. - Storage guide (
docs/DATABASE.md) — column types, collation, indexing. - Security policy (
SECURITY.md) — threat model and disclosure process. - Sibling implementations: JavaScript · Python.
License
Licensed under the MIT License — Copyright © 2026 Lam Hieu and contributors.