[][src]Function cookie_factory::bytes::be_u16

pub fn be_u16<W: Write>(i: u16) -> impl SerializeFn<W>

Writes an u16 in big endian byte order to the output

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

let mut buf = [0u8; 100];

{
  let (buf, pos) = gen(be_u16(1u16), &mut buf[..]).unwrap();
  assert_eq!(pos, 2);
  assert_eq!(buf.len(), 100 - 2);
}

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