[][src]Function cookie_factory::length

pub fn length<'a, F>(
    f: F
) -> impl Fn(&'a mut [u8]) -> Result<(usize, &'a mut [u8]), GenError> where
    F: SerializeFn<&'a mut [u8]>, 

returns the length of the data that was written, along with the remaining data

use cookie_factory::{length,string};

let mut buf = [0u8; 100];

let len = {
  let (len, _) = length(string("abcd"))(&mut buf[..]).unwrap();
  len
};

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