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.
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.

Traits§

ToCodeId
Identifier inputs accepted by to_code.

Functions§

baseh_heavy_p_v1
baseh-heavy with 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-light with 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-medium with 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-minimum with feistel-v1 permutation. 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.
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.