Crate proqnt

Source
Expand description

§proqnt

Version Documentation Build License Downloads

A pronounceable quintuplet, or proquint, is a pronounceable 5-letter string encoding a unique 16-bit integer.

Proquints may be used to encode binary data such as IP addresses, public keys, and UUIDs in a more human-friendly way. For more information, check out the specification

§Basic Usage

use proqnt::{FromProquints, IntoProquints, Proquint};
assert_eq!(
    format!("{}", Ipv4Addr::new(127, 0, 0, 1).proquint_encode()),
    "lusab-babad"
);
assert!(
    Ipv4Addr::new(127, 0, 0, 1).proquint_digits().eq([
        u16::parse_proquints("lusab").unwrap(),
        u16::parse_proquints("babad").unwrap()
    ].into_iter())
);
assert_eq!(
    format!("{}", [127u8, 0, 0, 1].proquint_encode()),
    "lusab-babad"
);
assert!(
    Ipv4Addr::new(127, 0, 0, 1).proquint_encode().into_iter().eq([
        "lusab".parse::<Proquint>().unwrap(),
        "babad".parse::<Proquint>().unwrap()
    ].into_iter())
);
// NOTE: [127, 0, 0, 1] will yield an array of i32, which will give the wrong result!

Modules§

fractional
Encoding datatypes as fractional numbers of another datatype

Macros§

fractional_decode_from_big
Implement FromFraction<S> using IntoFraction<T> where multiple S are required to make one T
fractional_decode_from_small
Implement FromFraction<S> using IntoFraction<T> where one S produces multiple T

Structs§

ParseProquintDigits
Parse a buffer as a series of dash-separated proquint digits
ParseProquints
Parse a buffer as a series of dash-separated proquints
Proquint
A pronounceable quintuplet, or proquint
ProquintEncode
Encode data as proquints
ProquintEncodeIter
Iterate over some data’s proquint encoding
ProquintParseError
An error in parsing a proquint

Enums§

ProquintsParseError
An error which occurs in parsing a stream of proquints

Constants§

CONSONANT_MASK
A 4-bit mask for the data contained in a proquint consonant
FINAL_CONSONANT_MASK
The mask for the data contained in a proquint’s final consonant
FINAL_CONSONANT_SHIFT
The shift for the data contained in a proquint’s final consonant
FIRST_CONSONANT_MASK
The mask for the data contained in a proquint’s first consonant
FIRST_CONSONANT_SHIFT
The shift for the data contained in a proquint’s first consonant
FIRST_SYLLABLE_MASK
The mask for the data contained in a proquint’s first syllable
FIRST_SYLLABLE_SHIFT
The shift for the data contained in a proquint’s first syllable
FIRST_VOWEL_MASK
The mask for the data contained in a proquint’s first vowel
FIRST_VOWEL_SHIFT
The shift for the data contained in a proquint’s first vowel
PROQUINT_CONSONANTS
The consonants which may appear in a proquint, indexed by their 4-bit binary values
PROQUINT_SYLLABLES
The syllables which may appear in a proquint, indexed by their 6-bit binary values
PROQUINT_VOWELS
The vowels which may appear in a proquint, indexed by their 2-bit binary values
SECOND_CONSONANT_MASK
The mask for the data contained in a proquint’s second consonant
SECOND_CONSONANT_SHIFT
The shift for the data contained in a proquint’s second consonant
SECOND_SYLLABLE_MASK
The mask for the data contained in a proquint’s second syllable
SECOND_SYLLABLE_SHIFT
The shift for the data contained in a proquint’s second syllable
SECOND_VOWEL_MASK
The mask for the data contained in a proquint’s second vowel
SECOND_VOWEL_SHIFT
The shift for the data contained in a proquint’s second vowel
SYLLABLE_MASK
A 6-bit mask for the data contained in a proquint syllable
VOWEL_MASK
A 2-bit mask for the data contained in a proquint vowel

Traits§

FromProquints
Data which can be constructed from a series of proquints
IntoProquints
Data which can be converted to a series of proquints