Trait bitlab::ExtractBitsFromVecU8 [] [src]

pub trait ExtractBitsFromVecU8 {
    fn get_u8(
        &self,
        byte_offset: usize,
        start: usize,
        length: usize
    ) -> Result<u8, String>;
fn get_i8(
        &self,
        byte_offset: usize,
        start: usize,
        length: usize
    ) -> Result<i8, String>;
fn get_u16(
        &self,
        byte_offset: usize,
        start: usize,
        length: usize
    ) -> Result<u16, String>;
fn get_i16(
        &self,
        byte_offset: usize,
        start: usize,
        length: usize
    ) -> Result<i16, String>;
fn get_u32(
        &self,
        byte_offset: usize,
        start: usize,
        length: usize
    ) -> Result<u32, String>;
fn get_i32(
        &self,
        byte_offset: usize,
        start: usize,
        length: usize
    ) -> Result<i32, String>; }

Defines a number of functions, which extract a range of bits from a Vec There is one function for each variable type to be returned Important: the contents of the vectored are assumed to be in big endian (network) order

Required Methods

Extracts a range of bits from a Vec and returns a Result object containing a 8 bit unsigned integer or an error message.

Parameters:

  • byte_offset (usize) the number of bytes to skip in source
  • bit_offset (usize) the start position of the bits to be extracted. Zero is the most significant bit
  • length (usize) the number of bits to be extracted.

Extracts a range of bits from a Vec and returns a Result object containing a signed 8 bit integer or an error message.

Parameters:

  • byte_offset (usize) the number of bytes to skip in source
  • bit_offset (usize) the start position of the bits to be extracted. Zero is the most significant bit
  • length (usize) the number of bits to be extracted.

Extracts a range of bits from a Vec and returns a Result object containing a 16 bit unsigned integer or an error message.

Parameters:

  • byte_offset (usize) the number of bytes to skip in source
  • bit_offset (usize) the start position of the bits to be extracted. Zero is the most significant bit
  • length (usize) the number of bits to be extracted.

Extracts a range of bits from a Vec and returns a Result object containing a signed 16 bit integer or an error message.

Parameters:

  • byte_offset (usize) the number of bytes to skip in source
  • bit_offset (usize) the start position of the bits to be extracted. Zero is the most significant bit
  • length (usize) the number of bits to be extracted.

Extracts a range of bits from a Vec and returns a Result object containing a 32 bit unsigned integer or an error message.

Parameters:

  • byte_offset (usize) the number of bytes to skip in source
  • bit_offset (usize) the start position of the bits to be extracted. Zero is the most significant bit
  • length (usize) the number of bits to be extracted.

Extracts a range of bits from a Vec and returns a Result object containing a signed 32 bit integer or an error message.

Parameters:

  • byte_offset (usize) the number of bytes to skip in source
  • bit_offset (usize) the start position of the bits to be extracted. Zero is the most significant bit
  • length (usize) the number of bits to be extracted.

Implementations on Foreign Types

impl ExtractBitsFromVecU8 for Vec<u8>
[src]

[src]

[src]

[src]

[src]

[src]

[src]

Implementors