Function postcard::to_stdvec_cobs
source · [−]Expand description
Serialize and COBS encode a T
to an alloc::vec::Vec<u8>
. Requires the alloc
feature.
The terminating sentinel 0x00
byte is included in the output.
Example
use postcard::to_allocvec_cobs;
let ser: Vec<u8> = to_allocvec_cobs(&true).unwrap();
assert_eq!(ser.as_slice(), &[0x02, 0x01, 0x00]);
let ser: Vec<u8> = to_allocvec_cobs("Hi!").unwrap();
assert_eq!(ser.as_slice(), &[0x05, 0x03, b'H', b'i', b'!', 0x00]);