Expand description
§ORION-192
Rust reference implementation of the ORION-192 distributed identifier algorithm — Ordered, Resilient, Independent, Opaque-ish, Non-coordinated 192-bit identifiers for distributed systems.
§Quick start
use o192::OrionIdGenerator;
let mut gen = OrionIdGenerator::new();
let a = gen.next().expect("CSPRNG should succeed");
let b = gen.next().expect("CSPRNG should succeed");
assert!(a < b, "IDs from one generator are strictly monotonic");§Cross-language compatibility
This crate is wire-compatible with the JavaScript / TypeScript and
Python implementations published in the same repository. All three
implementations pass the shared conformance vectors at
vectors/orion192.vectors.json.
§Cargo features
serde— enablesserde::{Serialize, Deserialize}for the public types (ParsedOrionId,OrionIdError). Disabled by default.
§Specification
See SPEC.md
for the normative algorithm and wire-format definition.
Structs§
- Orion
IdGenerator - Stateful ORION-192 generator.
- Parsed
Orion Id - Structured view of a parsed ORION-192 identifier.
Enums§
- Orion
IdError - All errors produced by this crate.
Constants§
- ALPHABET
- The sortable64 alphabet used by ORION-192.
- DEFAULT_
RANDOM_ POOL_ BYTES - Default CSPRNG pool size in bytes.
- ID_
SIZE_ BYTES - Size in bytes of an ORION-192 binary identifier.
- ID_
SIZE_ CHARS - Size in characters of the canonical ORION-192 string.
- MAX_
COUNTER - Maximum value for the 20-bit per-generator counter.
- MAX_
RANDOM_ POOL_ BYTES - Hard upper bound on the random pool: 16 MiB.
- MAX_
RELATIVE_ MS - Maximum value for the 48-bit
relative_msfield. - MIN_
RANDOM_ POOL_ BYTES - Hard lower bound on the random pool (must fit one random tail).
- RANDOM_
SIZE_ BYTES - Size in bytes of the cryptographic random tail.
Functions§
- decode_
sortable64 - Decode a canonical 32-character ORION-192 string into 24 bytes.
- encode_
sortable64 - Encode exactly 24 bytes into the canonical 32-character sortable64 string.
- is_
valid - Return
trueifidis a syntactically valid canonical ORION-192 string. - parse
- Parse a canonical ORION-192 string.
Type Aliases§
- Result
- Convenient
Resultalias used throughout the crate.