pub fn encode(src: &[u8], out: &mut WriteBuf<'_>) -> Result<()>Expand description
COBS-encode src into out. The output contains no 0x00 bytes and
does not include a trailing delimiter.
A full 254-byte block at the end of the input is not followed by an
empty block, so the output is never longer than
max_encoded_len(src.len()). This matches the reference encoder of
Cheshire and Baker and the cobs and postcard crates.
§Errors
Returns Error::BufferFull if out has insufficient room. Nothing is
written on error.
§Example
use wire_codec::{cobs, WriteBuf};
let mut out = [0u8; 8];
let mut buf = WriteBuf::new(&mut out);
cobs::encode(&[0x00], &mut buf).unwrap();
assert_eq!(buf.written(), &[0x01, 0x01]);