Function decode_bytes_fixed

Source
pub fn decode_bytes_fixed<const N: usize>(
    buffer: &[u8],
) -> Result<([u8; N], &[u8]), EncodingError>
Expand description

Decode a fixed sized array from a buffer. Return the array and the remainder of the buffer. Errors when buffer.len() < N;

let mut buffer = vec![1, 2, 3];
let (arr, rest) = decode_bytes_fixed::<2>(&mut buffer)?;
assert_eq!(arr, [1, 2]);
assert_eq!(rest, &[3]);