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 data.len() * 2 long or a compile-time panic is raised.

ยงExample

const HASH: [u8; 4] = [0xDE, 0xAD, 0xBE, 0xEF];
const HEX: [u8; 8] = hex::encode_array::<8>(&HASH, hex::Alphabet::Lower);
assert_eq!(&HEX, b"deadbeef");