Skip to main content

Crate baseh

Crate baseh 

Source
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.
BasehError
The error type returned by every fallible codec operation.
DecodeOptions
Decode options (spec 12.2). Defaults: strict input, no correction.
DecodeResult
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::new and keep the resulting codec. Profiles are validated at construction per spec 2.2.
ValidateOutcome
Non-throwing validation result (spec 12.4). Never carries an internal ID.

Enums§

ConfusionProfile
Built-in spoken-confusion candidate maps (spec 3.3).
ErrorCode
The error codes defined by the specification.
InspectResult
Live as-you-type inspection result (spec 12.5). inspect never panics on user input and never reports InspectResult::Valid for an incomplete code. There is deliberately no suggest variant: 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.
ProfanityMode
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-expandable permuted with caller-supplied key material. Key material is required; pass an empty key_id or 0 rounds 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-heavy permuted 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-light permuted 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-medium permuted 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-minimum permuted with caller-supplied key material instead of the frozen key. Key material is required; pass an empty key_id or 0 rounds 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.