pub fn read_u16(data: &[u8]) -> Result<(u16, &[u8]), crate::ModbusSerializationError> {
    if let [Some(dhi), Some(dlo)] = [data.get(0), data.get(1)] {
        Ok((u16::from_be_bytes([*dhi, *dlo]), &data[2..]))
    } else {
        Err(ModbusSerializationError::UnexpectedEOF {
            expected: 2,
            got: data.len(),
        })
    }
}
/// Reads an u16 from the given modbus data. The data is considered to be big endian with msB first
/// 
/// # Errors 
/// If the data slice contains less than 2 bytes a [ModbusSerializationError::UnexpectedEOF] will be returned 
/// with its expected field set to 2 and its got field set to data.len().
Reads an u16 from the given modbus data. The data is considered to be big endian with msB first
Reads an u16 from the given modbus data . The data is considered to be big endian with msB first
pub fn read_u16(data: &[u8]) -> Result<(u16, &[u8]), crate::ModbusSerializationError> {
    if let [Some(dhi), Some(dlo)] = [data.get(0), data.get(1)] {
        Ok((u16::from_be_bytes([*dhi, *dlo]), &data[2..]))
    } else {
        Err(ModbusSerializationError::UnexpectedEOF {
            expected: 2,
            got: data.len(),
        })
    }
}
pub fn read_u16 ( data : & [ u8 ] ) -> Result < ( u16 , & [ u8 ] ) , crate :: ModbusSerializationError > { if let [ Some ( dhi ) , Some ( dlo ) ] = [ data . get ( 0 ) , data . get ( 1 ) ] { Ok ( ( u16 :: from_be_bytes ( [ * dhi , * dlo ] ) , & data [ 2 .. ] ) ) } else { Err ( ModbusSerializationError :: UnexpectedEOF { expected : 2 , got : data . len ( ) , } ) } }
Reads an u16 from the given modbus data.
Reads an u16 from the given modbus data .
data
&[u8]
data
&[u8]
errors 
If the data slice contains less than 2 bytes a [ModbusSerializationError::UnexpectedEOF] will be returned
with its expected field set to 2 and its got field set to data.len().
If the data slice contains less than 2 bytes a [ ModbusSerializationError :: UnexpectedEOF ] will be returned with its expected field set to 2 and its got field set to data . len () .