Function postcard::to_io

source ·
pub fn to_io<'b, T, W>(value: &'b T, writer: W) -> Result<W>
where T: Serialize + ?Sized, W: Write,
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'!']);