proqnt

Crates.ioproqnt
lib.rsproqnt
version0.1.0
sourcesrc
created_at2023-05-07 12:08:11.858047
updated_at2023-05-07 12:08:11.858047
descriptionZero-copy proquint encoding and decoding
homepage
repositoryhttps://github.com/imbrem/proqnt
max_upload_size
id859110
size97,134
Jad Ghalayini (imbrem)

documentation

README

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 std::net::Ipv4Addr;
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!
Commit count: 8

cargo fmt