pub fn new<R: io::Read>(reader: &mut R) -> Result<Self, Error> {
    let mut length: u16 = DataType::parse_two_byte_int(reader)?.into();
    let mut properties = BTreeMap::new();

    while length > 0 {
      let identifier = Self::parse_identifier(reader)?;
      length -= 1;

      let data_type = Self::parse_type(identifier, reader)?;
      let data_length = data_type.byte_len()?;

      // something is wrong if the total length of properties doesn't match
      if data_length > length {
        return Err(Error::MalformedPacket);
      } else {
        length -= data_type.byte_len()?;
      }

      properties.insert(identifier, data_type);
    }

    Ok(Self { values: properties })
  }
/// Parse property identifiers and values from a reader.
Parse property identifiers and values from a reader.
Parse property identifiers and values from a reader .
pub fn new<R: io::Read>(reader: &mut R) -> Result<Self, Error> {
    let mut length: u16 = DataType::parse_two_byte_int(reader)?.into();
    let mut properties = BTreeMap::new();
    while length > 0 {
      let identifier = Self::parse_identifier(reader)?;
      length -= 1;
      let data_type = Self::parse_type(identifier, reader)?;
      let data_length = data_type.byte_len()?;
      // something is wrong if the total length of properties doesn't match
      if data_length > length {
        return Err(Error::MalformedPacket);
      } else {
        length -= data_type.byte_len()?;
      }
      properties.insert(identifier, data_type);
    }
    Ok(Self { values: properties })
  }
pub fn new < R : io :: Read > ( reader : & mut R ) -> Result < Self , Error > { let mut length : u16 = DataType :: parse_two_byte_int ( reader ) ? . into ( ) ; let mut properties = BTreeMap :: new ( ) ; while length > 0 { let identifier = Self :: parse_identifier ( reader ) ? ; length -= 1 ; let data_type = Self :: parse_type ( identifier , reader ) ? ; let data_length = data_type . byte_len ( ) ? ; // something is wrong if the total length of properties doesn't match if data_length > length { return Err ( Error :: MalformedPacket ) ; } else { length -= data_type . byte_len ( ) ? ; } properties . insert ( identifier , data_type ) ; } Ok ( Self { values : properties } ) }
Parse property identifiers and values from a reader.
Parse property identifiers and values from a reader .
reader
&mut R
reader
&mut R