Function bitconv::to_uint16[][src]

pub fn to_uint16<T: BitConvEndian>(data: &[u8], start_index: usize) -> u16

Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array.

The to_uint16 function converts the bytes from index start_index to start_index + 1 to a u16 value.

Example

use bitconv::{
    endian::{Big, Little}, to_uint16
};

let buffer = [15, 0, 0, 255, 3, 16, 39, 255, 255, 127];
assert_eq!(65280, to_uint16::<Little>(&buffer, 2));
assert_eq!(255, to_uint16::<Big>(&buffer, 2));