Function decode_into

Source
pub fn decode_into<B>(bytes: B, output: &mut [u8]) -> Result<usize, Error>
where B: AsRef<[u8]>,
Expand description

Decodes Crockford Base32-encoded bytes 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 decoding process.

§Errors

§Examples

let bytes = b"1TQ6WBNCMG62S10CSMPWSBD";

// allocate a buffer with enough capacity
let mut buffer = [0; 32];

// decode bytes into the buffer
let written = c32::decode_into(bytes, &mut buffer)?;

let expected = b"usque ad finem";
assert_eq!(&buffer[..written], expected);