pub trait ExtractBitsFromIntegralTypes {
// Required methods
fn get_u8(self, bit_offset: u32, length: u32) -> Result<u8, String>;
fn get_u16(self, bit_offset: u32, length: u32) -> Result<u16, String>;
fn get_u32(self, bit_offset: u32, length: u32) -> Result<u32, String>;
fn get_u64(self, bit_offset: u32, length: u32) -> Result<u64, String>;
fn get_i8(self, bit_offset: u32, length: u32) -> Result<i8, String>;
fn get_i16(self, bit_offset: u32, length: u32) -> Result<i16, String>;
fn get_i32(self, bit_offset: u32, length: u32) -> Result<i32, String>;
fn get_i64(self, bit_offset: u32, length: u32) -> Result<i64, String>;
}Expand description
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§
Sourcefn get_u8(self, bit_offset: u32, length: u32) -> Result<u8, String>
fn get_u8(self, bit_offset: u32, length: u32) -> Result<u8, String>
Extracts a range of bits and returns a Result object.
Parameters:
- 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.
Sourcefn get_u16(self, bit_offset: u32, length: u32) -> Result<u16, String>
fn get_u16(self, bit_offset: u32, length: u32) -> Result<u16, String>
Extracts a range of bits and returns a Result object.
Parameters:
- 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.
Sourcefn get_u32(self, bit_offset: u32, length: u32) -> Result<u32, String>
fn get_u32(self, bit_offset: u32, length: u32) -> Result<u32, String>
Extracts a range of bits and returns a Result object.
Parameters:
- 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.
Sourcefn get_u64(self, bit_offset: u32, length: u32) -> Result<u64, String>
fn get_u64(self, bit_offset: u32, length: u32) -> Result<u64, String>
Extracts a range of bits and returns a Result object.
Parameters:
- 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.
Sourcefn get_i8(self, bit_offset: u32, length: u32) -> Result<i8, String>
fn get_i8(self, bit_offset: u32, length: u32) -> Result<i8, String>
Extracts a range of bits and returns a Result object.
Parameters:
- 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.
Sourcefn get_i16(self, bit_offset: u32, length: u32) -> Result<i16, String>
fn get_i16(self, bit_offset: u32, length: u32) -> Result<i16, String>
Extracts a range of bits and returns a Result object.
Parameters:
- 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.