Function cookie_factory::bytes::be_i24

source ·
pub fn be_i24<W: Write>(i: i32) -> impl SerializeFn<W>
Expand description

Writes the lower 24 bit of an i32 in big endian byte order to the output

use cookie_factory::{gen, bytes::be_i24};

let mut buf = [0u8; 100];

{
  let (buf, pos) = gen(be_i24(1i32), &mut buf[..]).unwrap();
  assert_eq!(pos, 3);
  assert_eq!(buf.len(), 100 - 3);
}

assert_eq!(&buf[..3], &[0u8, 0u8, 1u8][..]);