pub fn new<R: io::Read>(reader: &mut R) -> Result<Self, Error> {
    let byte = DataType::parse_byte(reader);
    if let Ok(DataType::Byte(value)) = byte {
      let type_number: u8 = (value & 0xF0) >> 4;
      PacketType::try_from(type_number)
    } else {
      Err(Error::ParseError)
    }
  }
/// Parse property values from a reader into DataType variants.
///
/// # Examples
/// ```rust
/// use mqtt_packet::PacketType;
/// use mqtt_packet::Error;
/// use std::io;
///
/// let bytes: Vec<u8> = vec![0x10];
/// let mut reader = io::BufReader::new(&bytes[..]);
///
/// let packet_type = PacketType::new(&mut reader).unwrap();
/// assert_eq!(packet_type, PacketType::CONNECT);
/// ```
///
/// Error:
///
/// ```rust
/// use mqtt_packet::PacketType;
/// use mqtt_packet::Error;
/// use std::io;
///
/// let err_bytes: Vec<u8> = vec![0x00];
/// let mut err_reader = io::BufReader::new(&err_bytes[..]);
///
/// let err = PacketType::new(&mut err_reader).unwrap_err();
/// assert_eq!(err, Error::ParseError)
/// ```
Parse property values from a reader into DataType variants.
Parse property values from a reader into DataType variants .
pub fn new<R: io::Read>(reader: &mut R) -> Result<Self, Error> {
    let byte = DataType::parse_byte(reader);
    if let Ok(DataType::Byte(value)) = byte {
      let type_number: u8 = (value & 0xF0) >> 4;
      PacketType::try_from(type_number)
    } else {
      Err(Error::ParseError)
    }
  }
pub fn new < R : io :: Read > ( reader : & mut R ) -> Result < Self , Error > { let byte = DataType :: parse_byte ( reader ) ; if let Ok ( DataType :: Byte ( value ) ) = byte { let type_number : u8 = ( value & 0xF0 ) >> 4 ; PacketType :: try_from ( type_number ) } else { Err ( Error :: ParseError ) } }
Parse property values from a reader into DataType variants.
Parse property values from a reader into DataType variants .
reader
&mut R
reader
&mut R
examples


let bytes: Vec = vec![0x10];
let mut reader = io::BufReader::new(&bytes[..]).

let packet_type = PacketType::new(&mut reader).unwrap();
assert_eq!(packet_type, PacketType::CONNECT);
```





let err_bytes: Vec = vec![0x00];
let mut err_reader = io::BufReader::new(&err_bytes[..]).

let err = PacketType::new(&mut err_reader).unwrap_err();
assert_eq!(err, Error::ParseError)
```
let bytes : Vec = vec! [ 0x10 ] ; let mut reader = io :: BufReader :: new ( &bytes [ .. ] ) . let packet_type = PacketType :: new ( &mut reader ) . unwrap () ; assert_eq! ( packet_type PacketType :: CONNECT ) ; ` ` ` let err_bytes : Vec = vec! [ 0x00 ] ; let mut err_reader = io :: BufReader :: new ( &err_bytes [ .. ] ) . let err = PacketType :: new ( &mut err_reader ) . unwrap_err () ; assert_eq! ( err Error :: ParseError ) ` ` `