Trait bitlab::ExtractBitsFromVecU8
[−]
[src]
pub trait ExtractBitsFromVecU8 { fn get_u8(
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<u8, &'static str>; fn get_i8(
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<i8, &'static str>; fn get_u16(
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<u16, &'static str>; fn get_i16(
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<i16, &'static str>; fn get_u32(
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<u32, &'static str>; fn get_i32(
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<i32, &'static str>; }
Defines a number of functions, which extract a range of bits from a Vec
Required Methods
fn get_u8(
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<u8, &'static str>
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<u8, &'static str>
Extracts a range of bits from a Vec
On success, the Result contains the desired value
On error, the Result contains an error message. This may happen if:
- bit_offset > 7
- length > 8
- byte_offset * 8 + bit_offset + length > vector (source data) size in bits
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.
fn get_i8(
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<i8, &'static str>
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<i8, &'static str>
Extracts a range of bits from a Vec
On success, the Result contains the desired value
On error, the Result contains an error message. This may happen if:
- bit_offset > 7
- length > 8
- byte_offset * 8 + bit_offset + length > vector (source data) size in bits
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.
fn get_u16(
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<u16, &'static str>
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<u16, &'static str>
Extracts a range of bits from a Vec
On success, the Result contains the desired value
On error, the Result contains an error message. This may happen if:
- bit_offset > 7
- length > 16
- byte_offset * 8 + bit_offset + length > vector (source data) size in bits
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.
fn get_i16(
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<i16, &'static str>
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<i16, &'static str>
Extracts a range of bits from a Vec
On success, the Result contains the desired value
On error, the Result contains an error message. This may happen if:
- bit_offset > 7
- length > 16
- byte_offset * 8 + bit_offset + length > vector (source data) size in bits
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.
fn get_u32(
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<u32, &'static str>
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<u32, &'static str>
Extracts a range of bits from a Vec
On success, the Result contains the desired value
On error, the Result contains an error message. This may happen if:
- bit_offset > 7
- length > 32
- byte_offset * 8 + bit_offset + length > vector (source data) size in bits
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.
fn get_i32(
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<i32, &'static str>
&self,
byte_offset: usize,
start: usize,
length: usize
) -> Result<i32, &'static str>
Extracts a range of bits from a Vec
On success, the Result contains the desired value
On error, the Result contains an error message. This may happen if:
- bit_offset > 7
- length > 32
- byte_offset * 8 + bit_offset + length > vector (source data) size in bits
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]
fn get_u8(
&self,
byte_offset: usize,
bit_offset: usize,
length: usize
) -> Result<u8, &'static str>
[src]
&self,
byte_offset: usize,
bit_offset: usize,
length: usize
) -> Result<u8, &'static str>
fn get_i8(
&self,
byte_offset: usize,
bit_offset: usize,
length: usize
) -> Result<i8, &'static str>
[src]
&self,
byte_offset: usize,
bit_offset: usize,
length: usize
) -> Result<i8, &'static str>
fn get_u16(
&self,
byte_offset: usize,
bit_offset: usize,
length: usize
) -> Result<u16, &'static str>
[src]
&self,
byte_offset: usize,
bit_offset: usize,
length: usize
) -> Result<u16, &'static str>
fn get_i16(
&self,
byte_offset: usize,
bit_offset: usize,
length: usize
) -> Result<i16, &'static str>
[src]
&self,
byte_offset: usize,
bit_offset: usize,
length: usize
) -> Result<i16, &'static str>
fn get_u32(
&self,
byte_offset: usize,
bit_offset: usize,
length: usize
) -> Result<u32, &'static str>
[src]
&self,
byte_offset: usize,
bit_offset: usize,
length: usize
) -> Result<u32, &'static str>
fn get_i32(
&self,
byte_offset: usize,
bit_offset: usize,
length: usize
) -> Result<i32, &'static str>
[src]
&self,
byte_offset: usize,
bit_offset: usize,
length: usize
) -> Result<i32, &'static str>