pub fn encode_check<B>(bytes: B, version: u8) -> Result<String, Error>Available on crate features
check and alloc only.Expand description
Encodes bytes into a Crockford Base32Check-encoded string.
§Errors
Error::InvalidVersionif the version >= 32.
Error::InvalidBufferSizeif the output buffer is too small.
§Panics
This function can panic in one cases:
- If the encoded output contains non-UTF8 bytes.
All panics indicate implementation issues and should never occur.
§Examples
let bytes = b"usque ad finem";
let version = 22;
// encode bytes with into a string
let encoded = c32::encode_check(bytes, version)?;
let expected = "P7AWVHENJJ0RB441K6JVK5DNJ7J3V5";
assert_eq!(encoded, expected);