Function cookie_factory::gen_simple
source · pub fn gen_simple<W: Write, F: SerializeFn<W>>(
f: F,
w: W
) -> Result<W, GenError>
Expand description
Runs the given serializer f
with the Write
impl w
and returns the updated w
This internally wraps w
in a WriteContext
, starting at position 0.
use cookie_factory::{gen_simple, combinator::slice};
let mut buf = [0u8; 100];
{
let buf = gen_simple(slice(&b"abcd"[..]), &mut buf[..]).unwrap();
assert_eq!(buf.len(), 100 - 4);
}
assert_eq!(&buf[..4], &b"abcd"[..]);