pub fn to_io<T, W>(value: &T, writer: W) -> Result<W>
Expand description
Serialize a T
to a std::io::Write,
§Example
use postcard::to_io;
let mut buf: [u8; 32] = [0; 32];
let mut writer: &mut [u8] = &mut buf;
let ser = to_io(&true, &mut writer).unwrap();
to_io("Hi!", ser).unwrap();
assert_eq!(&buf[0..5], &[0x01, 0x03, b'H', b'i', b'!']);