Function cookie_factory::bytes::ne_i16
source · pub fn ne_i16<W: Write>(i: i16) -> impl SerializeFn<W>
Expand description
Writes an i16
in native byte order to the output
use cookie_factory::{gen, bytes::ne_i16};
let mut buf = [0u8; 100];
{
let (buf, pos) = gen(ne_i16(1i16), &mut buf[..]).unwrap();
assert_eq!(pos, 2);
assert_eq!(buf.len(), 100 - 2);
}
#[cfg(target_endian = "big")]
assert_eq!(&buf[..2], &[0u8, 1u8][..]);
#[cfg(target_endian = "litte")]
assert_eq!(&buf[..2], &[1u8, 0u8][..]);