pub fn decode_in_place(buf: &mut [u8]) -> Result<usize>Expand description
Decode one COBS block in place and return the decoded length.
The decoded bytes occupy buf[..len]; the rest of buf is left in an
unspecified state. Decoding never needs more room than the input, so this
works on the receive buffer itself.
§Errors
Returns Error::InvalidEncoding under the same conditions as
decode. The block is validated before it is rewritten, so buf is
unchanged on error.
§Example
use wire_codec::cobs;
let mut block = [0x02, 0x11, 0x01, 0x01];
let len = cobs::decode_in_place(&mut block).unwrap();
assert_eq!(&block[..len], &[0x11, 0x00, 0x00]);