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