odoid 1.0.0

Deterministic mixed-radix ID encoding — maps integers to 6, 7, or 8-character alphanumeric strings. Ambiguous characters I, L, O are excluded.
Documentation
  • Coverage
  • 55.88%
    19 out of 34 items documented3 out of 3 items with examples
  • Size
  • Source code size: 28.32 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 769.85 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 27s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Webictbyleo/odoid
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Webictbyleo

odoid

Deterministic mixed-radix ID encoding. Maps a u64 to a 6, 7, or 8-character alphanumeric string with a serial-number aesthetic.

encode(0,            6)  →  "0A0000"
encode(1234567,      6)  →  "0D7NM7"
encode(1234567,      7)  →  "0A15NM7"
encode(236223201279, 8)  →  "ZZ9ZZZZZ"

Features

  • Deterministic — same integer + length always produces the same string, and vice-versa.
  • Human-readable — ambiguous characters I, L, O are excluded from all positions.
  • Fixed positional structure — position 1 is always a letter, position 2 is always a digit.
  • Zero dependencies — pure Rust standard library only.

Install

[dependencies]
odoid = "1.0.0"

Usage

Encode

use odoid::encode;

encode(0,            6).unwrap(); // "0A0000"
encode(1234567,      6).unwrap(); // "0D7NM7"
encode(1234567,      7).unwrap(); // "0A15NM7"
encode(236223201279, 8).unwrap(); // "ZZ9ZZZZZ"

Decode

use odoid::decode;

decode("0A0000").unwrap(); // 0u64
decode("0D7NM7").unwrap(); // 1234567u64
decode("0a0000").unwrap(); // 0u64  (lowercase accepted)

OdoIDGenerator

use odoid::{OdoIDGenerator, GeneratorConfig};

let mut g = OdoIDGenerator::new(GeneratorConfig {
    namespace: "orders".into(),
    length: 7,
    ..Default::default()
}).unwrap();

let result = g.next().unwrap();
// result.id        → e.g. "3H5NV2K"
// result.n         → the raw u64
// result.length    → 7
// result.namespace → "orders"

Lengths and Capacity

Length Max integer (exclusive)
6 230,686,720
7 7,381,975,040
8 236,223,201,280

Errors

All functions return Result<_, OdoError>. Variants:

Variant When
OdoError::Overflow n >= MAX[length]
OdoError::UnsupportedLength length is not 6, 7, or 8
OdoError::InvalidCharacter character not in positional charset during decode
OdoError::EmptyInput empty string passed to decode

Run tests

cargo test

Specification

See SPEC.md for the full processing instruction document.

License

MIT