pub fn parse_binary_data<R: io::Read>(reader: &mut R) -> Result<Self, Error> {
    // determine the length of the binary data
    let mut length_buffer = [0; 2];
    reader.read_exact(&mut length_buffer)?;
    let length = u16::from_be_bytes(length_buffer);

    // read the data
    let mut handle = reader.take(u64::from(length));
    let mut buffer = vec![];
    handle.read_to_end(&mut buffer)?;

    Ok(Self::BinaryData(buffer))
  }
/// Reads bytes from the reader and attempts to convert the bytes to DataType::BinaryData (Vec<u8>).
///
/// [1.5.6 Binary Data](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901012)
///
/// Binary Data is represented by a Two Byte Integer length which indicates the
/// number of data bytes, followed by that number of bytes. Thus, the length of
/// Binary Data is limited to the range of 0 to 65,535 Bytes.
///
/// # Examples
///
/// ```rust
/// use mqtt_packet::DataType;
/// use std::io;
///
/// let data: Vec<u8> = vec![
///   0, 10, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
/// ];
///
/// let mut reader = io::BufReader::new(&data[..]);
/// let result = DataType::parse_binary_data(&mut reader).unwrap();
///
/// let expected: Vec<u8> = vec![0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09];
/// assert_eq!(result, DataType::BinaryData(expected));
/// ```
Reads bytes from the reader and attempts to convert the bytes to DataType::BinaryData (Vec).

Binary Data is represented by a Two Byte Integer length which indicates the
number of data bytes, followed by that number of bytes. Thus, the length of
Binary Data is limited to the range of 0 to 65,535 Bytes.
Reads bytes from the reader and attempts to convert the bytes to DataType :: BinaryData ( Vec ) . Binary Data is represented by a Two Byte Integer length which indicates the number of data bytes followed by that number of bytes . Thus the length of Binary Data is limited to the range of 0 to 65 535 Bytes .
pub fn parse_binary_data<R: io::Read>(reader: &mut R) -> Result<Self, Error> {
    // determine the length of the binary data
    let mut length_buffer = [0; 2];
    reader.read_exact(&mut length_buffer)?;
    let length = u16::from_be_bytes(length_buffer);
    // read the data
    let mut handle = reader.take(u64::from(length));
    let mut buffer = vec![];
    handle.read_to_end(&mut buffer)?;
    Ok(Self::BinaryData(buffer))
  }
pub fn parse_binary_data < R : io :: Read > ( reader : & mut R ) -> Result < Self , Error > { // determine the length of the binary data let mut length_buffer = [ 0 ; 2 ] ; reader . read_exact ( & mut length_buffer ) ? ; let length = u16 :: from_be_bytes ( length_buffer ) ; // read the data let mut handle = reader . take ( u64 :: from ( length ) ) ; let mut buffer = vec ! [ ] ; handle . read_to_end ( & mut buffer ) ? ; Ok ( Self :: BinaryData ( buffer ) ) }
Reads bytes from the reader and attempts to convert the bytes to DataType::BinaryData (Vec<u8>).
Reads bytes from the reader and attempts to convert the bytes to DataType :: BinaryData ( Vec<u8 > ) .
reader
&mut R
reader
&mut R
examples
```rust
use mqtt_packet::DataType;
use std::io.



let mut reader = io::BufReader::new(&data[..]);
let result = DataType::parse_binary_data(&mut reader).unwrap().


` ` ` rust use mqtt_packet :: DataType ; use std :: io . let mut reader = io :: BufReader :: new ( &data [ .. ] ) ; let result = DataType :: parse_binary_data ( &mut reader ) . unwrap () .