o192 0.2.2

ORION-192: ordered, resilient, independent, URL-safe 192-bit IDs for distributed systems.
Documentation

o192 — Rust

Crates.io docs.rs License: MIT MSRV Spec: v0

Rust reference implementation of ORION-192Ordered, 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 serde feature for Serialize / Deserialize on ParsedOrionId.
  • 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

cargo add o192

With the optional serde feature:

cargo add o192 --features serde

Quick start

use o192::OrionIdGenerator;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // 1. Long-lived generator (recommended for sustained throughput)
    let mut gen = OrionIdGenerator::new();
    let a = gen.next()?;
    let b = gen.next()?;
    assert!(a < b); // strictly monotonic per generator

    println!("{a}");
    Ok(())
}

Private epoch

use o192::OrionIdGenerator;

let mut gen = OrionIdGenerator::with_epoch_ms(1_735_689_600_000)?; // 2025-01-01 UTC
let id = gen.next()?;

Parsing

use o192::{is_valid, parse};

let id = "0Pu_iDKVO9012BwIEM28oFojPMWLWeLU";
assert!(is_valid(id));

let view = parse(id, 0)?;
println!("{} {}", view.relative_ms, view.counter);

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:

cargo run --release --example bench

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

License

Licensed under the MIT License — Copyright © 2026 Lam Hieu and contributors.