Skip to main content

Crate o192

Crate o192 

Source
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

§Specification

See SPEC.md for the normative algorithm and wire-format definition.

Structs§

OrionIdGenerator
Stateful ORION-192 generator.
ParsedOrionId
Structured view of a parsed ORION-192 identifier.

Enums§

OrionIdError
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_ms field.
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 true if id is a syntactically valid canonical ORION-192 string.
parse
Parse a canonical ORION-192 string.

Type Aliases§

Result
Convenient Result alias used throughout the crate.