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.
- Inspect
Result - Live as-you-type inspection result (spec 12.5).
inspectnever panics on user input and never reportsInspectResult::Validfor an incomplete code. There is deliberately nosuggestvariant: the frozen profiles alias confusable characters during normalization. - Mode
- Codec mode (spec 2.1/19.9). Profiles that predate the mode field are fixed: the shared frozen vectors pin their byte-for-byte behaviour, so a missing mode is prepared as fixed.
- 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.
- FROZEN_
KEY_ BYTES - The frozen published permutation key. Public by design: it makes issued
codes look non-sequential but offers no secrecy, since anyone can read it
here. Never swap it on a live namespace; codes only decode with the key
they were issued under. Use the
_p_variants to supply private key material.
Functions§
- baseh_
expandable_ p_ v1 baseh-expandablepermuted with caller-supplied key material. Key material is required; pass an emptykey_idor0rounds for the defaults (“default”, 8).- baseh_
expandable_ v1 - The frozen expandable tier
baseh-expandable-v1; the recommended starting point for new namespaces. - baseh_
heavy_ p_ v1 baseh-heavypermuted with caller-supplied key material. Key material is required.- baseh_
heavy_ v1 - Tier
baseh-heavy-v1: conservative alphabet plus spoken heavy, two checksum symbols, hyphen-delimited. - baseh_
light_ p_ v1 baseh-lightpermuted with caller-supplied key material. Key material is required.- baseh_
light_ v1 - Tier
baseh-light-v1: visual light plus spoken light, two checksum symbols, hyphen-delimited. - baseh_
medium_ p_ v1 baseh-mediumpermuted with caller-supplied key material. Key material is required.- baseh_
medium_ v1 - Tier
baseh-medium-v1: visual medium plus spoken medium, two checksum symbols, hyphen-delimited. The default. - baseh_
minimum_ p_ v1 baseh-minimumpermuted with caller-supplied key material instead of the frozen key. 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. - decode
- Decode a code from the default expandable v1 profile.
- encode
- Encode an identifier with the default expandable v1 profile.
- expandable_
grouping - Spec 19.5. Group sizes for a total length under the balanced rule:
g = max(2, ceil(L / 5))groups whose sizes differ by at most one, the larger groups on the left. - inspect
- Live as-you-type inspection (spec 12.5) with the default expandable v1 profile. Never panics on user input.
- validate
- Validate a code from the default expandable v1 profile.