Expand description
§baseh
Rust implementation of the baseH codec:
fixed-length, checksummed, optionally permuted human-readable
identifiers. Mirrors the normative specification in
spec/IMPLEMENTATION_CODEC.md at the repository root.
use num_bigint::BigUint;
let profile = baseh::baseh_medium_v1();
let baseh = baseh::Baseh::new(profile).unwrap();
let code = baseh.encode(&BigUint::from(42u64)).unwrap();
let result = baseh.decode(&code, &baseh::DecodeOptions::default()).unwrap();
assert_eq!(result.id, BigUint::from(42u64));Modules§
- feistel
- Feistel-v1 reversible permutation (spec section 7.3).
Structs§
- Baseh
- A baseH codec bound to a validated profile. Pure and stateless; safe to share across threads.
- Baseh
Error - The error type returned by every fallible codec operation.
- Decode
Options - Decode options (spec 12.2). Defaults: strict input, no correction.
- Decode
Result - Successful decode result (spec 12.2).
- Profanity
- Optional profanity safety configuration (spec 18). It never changes decode behavior for issued codes and never changes identifier capacity accounting: blocked codes are simply never issued by the encoder.
- Profile
- A baseH profile. Construct one, pass it to
crate::Baseh::newand keep the resulting codec. Profiles are validated at construction per spec 2.2. - Validate
Outcome - Non-throwing validation result (spec 12.4). Never carries an internal ID.
Enums§
- Confusion
Profile - Built-in spoken-confusion candidate maps (spec 3.3).
- Error
Code - The error codes defined by the specification.
- Permutation
- Reversible permutation configuration for a profile.
- Profanity
Mode - Profanity handling mode (spec 18.1).
Constants§
- DEFAULT_
BLOCKLIST - Spec 18.2 default list. Deliberately small; applications extend it.
Traits§
Functions§
- baseh_
heavy_ p_ v1 baseh-heavywith feistel-v1 permutation. Key material is required.- baseh_
heavy_ v1 - Tier
baseh-heavy-v1: conservative alphabet plus spoken heavy, one checksum symbol. - baseh_
light_ p_ v1 baseh-lightwith feistel-v1 permutation. Key material is required.- baseh_
light_ v1 - Tier
baseh-light-v1: visual light plus spoken light, one checksum symbol. - baseh_
medium_ p_ v1 baseh-mediumwith feistel-v1 permutation. Key material is required.- baseh_
medium_ v1 - Tier
baseh-medium-v1: visual medium plus spoken medium, one checksum symbol. The default. - baseh_
minimum_ p_ v1 baseh-minimumwith feistel-v1 permutation. Key material is required; pass an emptykey_idor0rounds for the defaults (“default”, 8).- baseh_
minimum_ v1 - Tier
baseh-minimum-v1: alphanumeric, no safety strips, no checksum, hyphen-delimited XXX-XXX. - from_
code - Decode a code from the zero-config Medium profile back to its identifier.
- to_code
- Encode an identifier with the zero-config Medium profile.