pub fn from_slice<'a>(buffer: &'a [u8]) -> Result<&'a Packet> {
        ensure!(
            buffer.len() == mem::size_of::<Packet>(),
            "Requre the slice length to be {}, but get {}",
            mem::size_of::<Packet>(),
            buffer.len(),
        );
        let packet = unsafe { &*(buffer.as_ptr() as *const Packet) };
        Ok(packet)
    }
/// Construct packet from slice of bytes. Error if the slice size is not correct.
Construct packet from slice of bytes. Error if the slice size is not correct.
Construct packet from slice of bytes . Error if the slice size is not correct .
pub fn from_slice<'a>(buffer: &'a [u8]) -> Result<&'a Packet> {
        ensure!(
            buffer.len() == mem::size_of::<Packet>(),
            "Requre the slice length to be {}, but get {}",
            mem::size_of::<Packet>(),
            buffer.len(),
        );
        let packet = unsafe { &*(buffer.as_ptr() as *const Packet) };
        Ok(packet)
    }
pub fn from_slice < ' a > ( buffer : & ' a [ u8 ] ) -> Result < & ' a Packet > { ensure ! ( buffer len ( ) mem size_of Packet ( ) " " mem size_of Packet ( ) buffer len ( ) ) ; let packet = unsafe { & * ( buffer . as_ptr ( ) as * const Packet ) } ; Ok ( packet ) }
Construct packet from slice of bytes.
Construct packet from slice of bytes .
buffer
&'a [u8]
buffer
&'a [u8]