Function cookie_factory::bytes::be_u32

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

Writes an u32 in big endian byte order to the output

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

let mut buf = [0u8; 100];

{
  let (buf, pos) = gen(be_u32(1u32), &mut buf[..]).unwrap();
  assert_eq!(pos, 4);
  assert_eq!(buf.len(), 100 - 4);
}

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