Crates.io | proqnt |
lib.rs | proqnt |
version | 0.1.0 |
source | src |
created_at | 2023-05-07 12:08:11.858047 |
updated_at | 2023-05-07 12:08:11.858047 |
description | Zero-copy proquint encoding and decoding |
homepage | |
repository | https://github.com/imbrem/proqnt |
max_upload_size | |
id | 859110 |
size | 97,134 |
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
# 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!