decode_ref_iter

Function decode_ref_iter 

Source
pub fn decode_ref_iter<'a, I>(i: I) -> impl Iterator<Item = u8> + 'a
where I: Iterator<Item = &'a u8> + 'a,
Expand description

Decode COBS/R-encoded data, getting data from a &u8 iterator, and providing the output as an iterator.

The input data should be COBS/R-encoded, containing no zero-bytes.

The caller must provide a &u8 iterator.

The return value is a u8 iterator. This is suitable to collect() into a byte container.

Unlike the other decode functions, no errors are returned by this function. Rather, decoding is best-effort. In the event of any zero in the input, this will be regarded as end-of-data.

let data_cobs = b"\x04ABC\x05ghijzxy".to_vec();
let decode_data: Vec<u8> = cobs2::cobsr::decode_ref_iter(data_cobs.iter()).collect();
assert_eq!(decode_data, b"ABC\0ghij\0xyz");