pub fn encode_check_into<B>(
bytes: B,
version: u8,
output: &mut [u8],
) -> Result<usize, Error>Available on crate feature
check only.Expand description
Encodes bytes as Crockford Base32Check into a provided output buffer.
§Returns
Ok(usize): The number of bytes written to the output buffer.Err(Error): If any errors occur during the encoding process.
§Errors
Error::InvalidVersionif the version >= 32.
Error::InvalidBufferSizeif the output buffer is too small.
§Examples
let bytes = b"usque ad finem";
let version = 22;
// allocate a buffer with enough capacity
let mut buffer = [0; 32];
// encode bytes into the buffer
let written = c32::encode_check_into(bytes, version, &mut buffer)?;
let expected = b"P7AWVHENJJ0RB441K6JVK5DNJ7J3V5";
assert_eq!(&buffer[..written], expected);