Skip to main content

decode_array

Function decode_array 

Source
pub const fn decode_array<const OUT: usize>(
    encoded_data: &[u8],
    alphabet: Alphabet,
) -> Result<[u8; OUT], DecodeError>
Expand description

Decodes a base32 string into a fixed-size array at compile time.

The generic parameter OUT is the output array length. It must be exactly the decoded length of the input or an error is returned.

ยงExample

const RESULT: Result<[u8; 5], base32::DecodeError> =
    base32::decode_array::<5>(b"NBSWY3DP", base32::Alphabet::Rfc4648);
assert_eq!(RESULT.unwrap(), *b"hello");