pub fn decode(&self, data: &[u8; 20]) -> Result<SparsnasPacket, SparsnasDecodeError> {
        let crc = ikeacrc::crc(&data[0..18]);

        if u16::from_be_bytes([data[18], data[19]]) != crc {
            return Err(SparsnasDecodeError::BadCRC);
        }

        self.decode_nocrc(data[0..18].try_into().unwrap())
    }
/// Decode a packet. Expecting that the buffer contains a length field in the beginning and CRC at the end.
Decode a packet. Expecting that the buffer contains a length field in the beginning and CRC at the end.
Decode a packet . Expecting that the buffer contains a length field in the beginning and CRC at the end .
pub fn decode(&self, data: &[u8; 20]) -> Result<SparsnasPacket, SparsnasDecodeError> {
        let crc = ikeacrc::crc(&data[0..18]);
        if u16::from_be_bytes([data[18], data[19]]) != crc {
            return Err(SparsnasDecodeError::BadCRC);
        }
        self.decode_nocrc(data[0..18].try_into().unwrap())
    }
pub fn decode ( & self , data : & [ u8 ; 20 ] ) -> Result < SparsnasPacket , SparsnasDecodeError > { let crc = ikeacrc :: crc ( & data [ 0 .. 18 ] ) ; if u16 :: from_be_bytes ( [ data [ 18 ] , data [ 19 ] ] ) != crc { return Err ( SparsnasDecodeError :: BadCRC ) ; } self . decode_nocrc ( data [ 0 .. 18 ] . try_into ( ) . unwrap ( ) ) }
Decode a packet.
Decode a packet .
&self
data
&[u8; 20]
&self
data
&[u8; 20]