ExtractBitsFromVecU8

Trait ExtractBitsFromVecU8 

Source
pub trait ExtractBitsFromVecU8 {
    // Required methods
    fn get_u8(
        &self,
        byte_offset: u32,
        start: u32,
        length: u32,
    ) -> Result<u8, String>;
    fn get_i8(
        &self,
        byte_offset: u32,
        start: u32,
        length: u32,
    ) -> Result<i8, String>;
    fn get_u16(
        &self,
        byte_offset: u32,
        start: u32,
        length: u32,
    ) -> Result<u16, String>;
    fn get_i16(
        &self,
        byte_offset: u32,
        start: u32,
        length: u32,
    ) -> Result<i16, String>;
    fn get_u32(
        &self,
        byte_offset: u32,
        start: u32,
        length: u32,
    ) -> Result<u32, String>;
    fn get_i32(
        &self,
        byte_offset: u32,
        start: u32,
        length: u32,
    ) -> Result<i32, String>;
    fn get_u64(
        &self,
        byte_offset: u32,
        start: u32,
        length: u32,
    ) -> Result<u64, String>;
    fn get_i64(
        &self,
        byte_offset: u32,
        start: u32,
        length: u32,
    ) -> Result<i64, String>;
}
Expand description

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 vector are assumed to be big endian (network order)

Required Methods§

Source

fn get_u8( &self, byte_offset: u32, start: u32, length: u32, ) -> Result<u8, String>

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 (u32) the number of bytes to skip in source
  • bit_offset (u32) the start position of the bits to be extracted. Zero is the most significant bit
  • length (u32) the number of bits to be extracted.
Source

fn get_i8( &self, byte_offset: u32, start: u32, length: u32, ) -> Result<i8, String>

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 (u32) the number of bytes to skip in source
  • bit_offset (u32) the start position of the bits to be extracted. Zero is the most significant bit
  • length (u32) the number of bits to be extracted.
Source

fn get_u16( &self, byte_offset: u32, start: u32, length: u32, ) -> Result<u16, String>

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 (u32) the number of bytes to skip in source
  • bit_offset (u32) the start position of the bits to be extracted. Zero is the most significant bit
  • length (u32) the number of bits to be extracted.
Source

fn get_i16( &self, byte_offset: u32, start: u32, length: u32, ) -> Result<i16, String>

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 (u32) the number of bytes to skip in source
  • bit_offset (u32) the start position of the bits to be extracted. Zero is the most significant bit
  • length (u32) the number of bits to be extracted.
Source

fn get_u32( &self, byte_offset: u32, start: u32, length: u32, ) -> Result<u32, String>

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 (u32) the number of bytes to skip in source
  • bit_offset (u32) the start position of the bits to be extracted. Zero is the most significant bit
  • length (u32) the number of bits to be extracted.
Source

fn get_i32( &self, byte_offset: u32, start: u32, length: u32, ) -> Result<i32, String>

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 (u32) the number of bytes to skip in source
  • bit_offset (u32) the start position of the bits to be extracted. Zero is the most significant bit
  • length (u32) the number of bits to be extracted.
Source

fn get_u64( &self, byte_offset: u32, start: u32, length: u32, ) -> Result<u64, String>

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

Parameters:

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

fn get_i64( &self, byte_offset: u32, start: u32, length: u32, ) -> Result<i64, String>

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

Parameters:

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

Implementations on Foreign Types§

Source§

impl ExtractBitsFromVecU8 for Vec<u8>

Source§

fn get_u8( &self, byte_offset: u32, bit_offset: u32, length: u32, ) -> Result<u8, String>

Source§

fn get_i8( &self, byte_offset: u32, bit_offset: u32, length: u32, ) -> Result<i8, String>

Source§

fn get_u16( &self, byte_offset: u32, bit_offset: u32, length: u32, ) -> Result<u16, String>

Source§

fn get_i16( &self, byte_offset: u32, bit_offset: u32, length: u32, ) -> Result<i16, String>

Source§

fn get_u32( &self, byte_offset: u32, bit_offset: u32, length: u32, ) -> Result<u32, String>

Source§

fn get_i32( &self, byte_offset: u32, bit_offset: u32, length: u32, ) -> Result<i32, String>

Source§

fn get_u64( &self, byte_offset: u32, bit_offset: u32, length: u32, ) -> Result<u64, String>

Source§

fn get_i64( &self, byte_offset: u32, bit_offset: u32, length: u32, ) -> Result<i64, String>

Implementors§