fn byte_stuff(data: &Data) -> Data {
        // if data has STX, insert another STX
        let mut temp = Vec::<u8>::new();
        temp.push(data[0]);

        // we ignore the first byte, it should not be stuffed
        for byte in data[1..].iter() {
            if *byte == STX {
                temp.push(STX);
            }
            temp.push(*byte);
        }

        temp
    }
// should be called after CRC is calculated
should be called after CRC is calculated
should be called after CRC is calculated
fn byte_stuff(data: &Data) -> Data {
        // if data has STX, insert another STX
        let mut temp = Vec::<u8>::new();
        temp.push(data[0]);
        // we ignore the first byte, it should not be stuffed
        for byte in data[1..].iter() {
            if *byte == STX {
                temp.push(STX);
            }
            temp.push(*byte);
        }
        temp
    }
fn byte_stuff ( data : & Data ) -> Data { // if data has STX, insert another STX let mut temp = Vec :: < u8 > :: new ( ) ; temp . push ( data [ 0 ] ) ; // we ignore the first byte, it should not be stuffed for byte in data [ 1 .. ] . iter ( ) { if * byte == STX { temp . push ( STX ) ; } temp . push ( * byte ) ; } temp }
should be called after CRC is calculated
should be called after CRC is calculated
data
&Data
data
&Data