pub fn encode<B>(bytes: B) -> StringAvailable on crate feature
alloc only.Expand description
Encodes bytes into a Crockford Base32-encoded string.
§Panics
This function can panic in two cases:
- If encoding fails despite sufficient buffer capacity.
- If the encoded output contains non-UTF8 bytes.
All panics indicate implementation issues and should never occur.
§Examples
let bytes = b"usque ad finem";
// encode bytes into a string
let encoded = c32::encode(bytes);
let expected = "1TQ6WBNCMG62S10CSMPWSBD";
assert_eq!(encoded, expected);