Skip to main content

encode_array

Function encode_array 

Source
pub const fn encode_array<const OUT: usize>(
    data: &[u8],
    alphabet: Alphabet,
) -> [u8; OUT]
Expand description

Encodes data into a fixed-size array at compile time.

The generic parameter OUT is the output array length. It must be exactly the encoded length of data or a compile-time panic is raised.

ยงExample

const DATA: [u8; 3] = [0x66, 0x6F, 0x6F];
const B64: [u8; 4] = base64::encode_array::<4>(&DATA, base64::Alphabet::Standard);
assert_eq!(&B64, b"Zm9v");