pub fn slice<S: AsRef<[u8]>, W: Write>(data: S) -> impl SerializeFn<W>
Expand description

Writes a byte slice to the output

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

let mut buf = [0u8; 100];

{
  let (buf, pos) = gen(slice(&b"abcd"[..]), &mut buf[..]).unwrap();
  assert_eq!(pos, 4);
  assert_eq!(buf.len(), 100 - 4);
}

assert_eq!(&buf[..4], &b"abcd"[..]);