pub fn decode_check_into<B>(
bytes: B,
output: &mut [u8],
) -> Result<(u8, usize), Error>Available on crate feature
check only.Expand description
Decodes Crockford Base32Check bytes into a provided output buffer.
§Returns
Ok((u8, usize)): The version byte and number of bytes written.Err(Error): If any errors occur during the decoding process.
§Errors
Error::InvalidStringif the input contains non-ASCII characters.Error::InvalidCharif the character is not found inC32_ALPHABET.Error::InvalidBufferSizeif the output buffer is too small.Error::InvalidDataSizewhen data requirements are not met.Error::TryFromIntwhen bit arithmetic operations exceeds bounds.
§Panics
This function can panic in two cases:
- If slice bounds are exceeded while computing the checksum.
- If the input bytes are empty when calling
split_first().
This panic indicates an implementation issue and should never occur.
§Examples
let bytes = b"P7AWVHENJJ0RB441K6JVK5DNJ7J3V5";
// allocate a buffer with enough capacity
let mut buffer = [0; 32];
// decode bytes with checksum into the buffer
let (version, written) = c32::decode_check_into(bytes, &mut buffer)?;
let expected = b"usque ad finem";
assert_eq!(&buffer[..written], expected);
assert_eq!(version, 22);