Expand description
OdoID — Deterministic mixed-radix ID encoding.
Maps a non-negative integer to a 6, 7, or 8-character alphanumeric string
with a serial-number aesthetic. All ambiguous characters (I, L, O) are
excluded from all positions to prevent transcription errors.
§Quick start
use odoid::{encode, decode, OdoIDGenerator, GeneratorConfig};
assert_eq!(encode(0, 6).unwrap(), "0A0000");
assert_eq!(encode(1234567, 6).unwrap(), "0D7NM7");
assert_eq!(encode(1234567, 7).unwrap(), "0A15NM7");
assert_eq!(encode(236223201279, 8).unwrap(), "ZZ9ZZZZZ");
assert_eq!(decode("0D7NM7").unwrap(), 1234567);
let mut g = OdoIDGenerator::new(GeneratorConfig {
namespace: "orders".into(),
length: 7,
..Default::default()
}).unwrap();
let result = g.next().unwrap();
assert_eq!(result.length, 7);Structs§
- Generator
Config - Configuration for
OdoIDGenerator. - Invalid
Character Error - Returned when a character absent from the positional charset is encountered during decoding.
- OdoID
Generator - A distributed monotonic generator that produces OdoID strings driven by a namespace-scoped, time-seeded pseudo-random integer.
- OdoID
Result - Value returned by
OdoIDGenerator::next. - Overflow
Error - Returned when
n >= MAX[length]for the chosen OdoID length. - Unsupported
Length Error - Returned when a length other than 6, 7, or 8 is requested.
Enums§
Constants§
- ALL
- Full hybrid set — NUM concatenated with ALPHA — radix 32.
- ALPHA
- Alpha characters (ambiguous chars I, L, O excluded) — radix 22.
- MAX
- Maximum exclusive value for each supported length. Formula: 32 × 22 × 10 × 32^(L-3) = 220 × 32^(L-2)
- NUM
- Numeric characters — radix 10.