Function cookie_factory::combinator::hex

source ·
pub fn hex<S: UpperHex, W: Write>(data: S) -> impl SerializeFn<W>
Expand description

Writes an hex string to the output

use cookie_factory::{gen, combinator::hex};

let mut buf = [0u8; 100];

{
  let (buf, pos) = gen(hex(0x2A), &mut buf[..]).unwrap();
  assert_eq!(pos, 2);
  assert_eq!(buf.len(), 100 - 2);
}

assert_eq!(&buf[..2], &b"2A"[..]);