Trait bitlab::ExtractBitsFromIntegralTypes [] [src]

pub trait ExtractBitsFromIntegralTypes {
    fn get_u8(self, start: usize, length: usize) -> Result<u8, String>;
fn get_u16(self, start: usize, length: usize) -> Result<u16, String>;
fn get_u32(self, start: usize, length: usize) -> Result<u32, String>;
fn get_u64(self, start: usize, length: usize) -> Result<u64, String>;
fn get_i8(self, start: usize, length: usize) -> Result<i8, String>;
fn get_i16(self, start: usize, length: usize) -> Result<i16, String>;
fn get_i32(self, start: usize, length: usize) -> Result<i32, String>;
fn get_i64(self, start: usize, length: usize) -> Result<i64, String>; }

Defines a number of functions, which extract a range of bits from primitive numeric types (u8, u16, u32 and u64, i8, i16, i32 and i64) and return the result as one of the following types (u8, u16, u32 and u64, i8, i16, i32 and i64) E.g. the a.get_u8(5,3) function extracts the bits 5,6 and 7 of the variable a and returns the result as a u8 variable

Required Methods

Extracts a range of bits and returns a Result object.

On success, the Result contains the desired value as a u8

On error, the Result contains an error message. This may happen if the range is larger than the data source (start + length > 8)

Parameters:

  • start (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 and returns a Result object.

On success, the Result contains the desired value as a u16

On error, the Result contains an error message. This may happen if the range is larger than the data source (start + length > 16)

Parameters:

  • start (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 and returns a Result object.

On success, the Result contains the desired value as a u32

On error, the Result contains an error message. This may happen if the range is larger than the data source (start + length > 32)

Parameters:

  • start (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 and returns a Result object.

On success, the Result contains the desired value as a u64

On error, the Result contains an error message. This may happen if the range is larger than the data source (start + length > 64)

Parameters:

  • start (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 and returns a Result object.

On success, the Result contains the desired value as a i8

On error, the Result contains an error message. This may happen if the range is larger than the data source (start + length > 8)

Parameters:

  • start (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 and returns a Result object.

On success, the Result contains the desired value as a i16

On error, the Result contains an error message. This may happen if the range is larger than the data source (start + length > 16)

Parameters:

  • start (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 and returns a Result object.

On success, the Result contains the desired value as a i32

On error, the Result contains an error message. This may happen if the range is larger than the data source (start + length > 32)

Parameters:

  • start (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 and returns a Result object.

On success, the Result contains the desired value as a i64

On error, the Result contains an error message. This may happen if the range is larger than the data source (start + length > 64)

Parameters:

  • start (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 ExtractBitsFromIntegralTypes for u8
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl ExtractBitsFromIntegralTypes for i8
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl ExtractBitsFromIntegralTypes for u16
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl ExtractBitsFromIntegralTypes for i16
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl ExtractBitsFromIntegralTypes for u32
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl ExtractBitsFromIntegralTypes for i32
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl ExtractBitsFromIntegralTypes for u64
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl ExtractBitsFromIntegralTypes for i64
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

Implementors