Trait bitlab::InsertBitsIntoIntegralTypes
[−]
[src]
pub trait InsertBitsIntoIntegralTypes { fn set_u8(
self,
start: usize,
length: usize,
value: u8
) -> Result<Self, String>
where
Self: Sized; fn set_i8(
self,
start: usize,
length: usize,
value: i8
) -> Result<Self, String>
where
Self: Sized; fn set_u16(
self,
start: usize,
length: usize,
value: u16
) -> Result<Self, String>
where
Self: Sized; fn set_i16(
self,
start: usize,
length: usize,
value: i16
) -> Result<Self, String>
where
Self: Sized; fn set_u32(
self,
start: usize,
length: usize,
value: u32
) -> Result<Self, String>
where
Self: Sized; fn set_i32(
self,
start: usize,
length: usize,
value: i32
) -> Result<Self, String>
where
Self: Sized; fn set_u64(
self,
start: usize,
length: usize,
value: u64
) -> Result<Self, String>
where
Self: Sized; fn set_i64(
self,
start: usize,
length: usize,
value: i64
) -> Result<Self, String>
where
Self: Sized; }
Defines a number of functions, which insert any integer value into any integer type (u8, u16, u32 and u64, i8, i16, i32 and i64) and return the result as the same type.
E.g. a.set_u8(1, 2, b) inserts the last two bits of b into a, starting at the bit offset 1, where the bit offset zero is defined as the most significant bit. All other bits of a, remain untouched.
Example1: let a : u8 = 0; let b : u16 = 3; assert_eq!(a.set_u8(1, 2, b).unwrap(), 0b0110_0000);
Example2: let a : u8 = 0b0110_0011; let b : u8 = 2; assert_eq!(a.set_u8(5, 2, b).unwrap(), 0b0110_0101);
Required Methods
fn set_u8(self, start: usize, length: usize, value: u8) -> Result<Self, String> where
Self: Sized,
Self: Sized,
Inserts a range of bits and returns a Result object.
Parameters:
- start (usize) the start position of the bits to be overwritten. Zero is the most significant bit
- length (usize) the number of bits to be overwritten.
- value (u8) the value to be inserted.
fn set_i8(self, start: usize, length: usize, value: i8) -> Result<Self, String> where
Self: Sized,
Self: Sized,
Inserts a range of bits and returns a Result object.
Parameters:
- start (usize) the start position of the bits to be overwritten. Zero is the most significant bit
- length (usize) the number of bits to be overwritten.
- value (i8) the value to be inserted.
fn set_u16(
self,
start: usize,
length: usize,
value: u16
) -> Result<Self, String> where
Self: Sized,
self,
start: usize,
length: usize,
value: u16
) -> Result<Self, String> where
Self: Sized,
Inserts a range of bits and returns a Result object.
Parameters:
- start (usize) the start position of the bits to be overwritten. Zero is the most significant bit
- length (usize) the number of bits to be overwritten.
- value (u16) the value to be inserted.
fn set_i16(
self,
start: usize,
length: usize,
value: i16
) -> Result<Self, String> where
Self: Sized,
self,
start: usize,
length: usize,
value: i16
) -> Result<Self, String> where
Self: Sized,
Inserts a range of bits and returns a Result object.
Parameters:
- start (usize) the start position of the bits to be overwritten. Zero is the most significant bit
- length (usize) the number of bits to be overwritten.
- value (i16) the value to be inserted.
fn set_u32(
self,
start: usize,
length: usize,
value: u32
) -> Result<Self, String> where
Self: Sized,
self,
start: usize,
length: usize,
value: u32
) -> Result<Self, String> where
Self: Sized,
Inserts a range of bits and returns a Result object.
Parameters:
- start (usize) the start position of the bits to be overwritten. Zero is the most significant bit
- length (usize) the number of bits to be overwritten.
- value (u32) the value to be inserted.
fn set_i32(
self,
start: usize,
length: usize,
value: i32
) -> Result<Self, String> where
Self: Sized,
self,
start: usize,
length: usize,
value: i32
) -> Result<Self, String> where
Self: Sized,
Inserts a range of bits and returns a Result object.
Parameters:
- start (usize) the start position of the bits to be overwritten. Zero is the most significant bit
- length (usize) the number of bits to be overwritten.
- value (i32) the value to be inserted.
fn set_u64(
self,
start: usize,
length: usize,
value: u64
) -> Result<Self, String> where
Self: Sized,
self,
start: usize,
length: usize,
value: u64
) -> Result<Self, String> where
Self: Sized,
Inserts a range of bits and returns a Result object.
Parameters:
- start (usize) the start position of the bits to be overwritten. Zero is the most significant bit
- length (usize) the number of bits to be overwritten.
- value (u64) the value to be inserted.
fn set_i64(
self,
start: usize,
length: usize,
value: i64
) -> Result<Self, String> where
Self: Sized,
self,
start: usize,
length: usize,
value: i64
) -> Result<Self, String> where
Self: Sized,
Inserts a range of bits and returns a Result object.
Parameters:
- start (usize) the start position of the bits to be overwritten. Zero is the most significant bit
- length (usize) the number of bits to be overwritten.
- value (i64) the value to be inserted.
Implementations on Foreign Types
impl InsertBitsIntoIntegralTypes for u8
[src]
fn set_u8(self, start: usize, length: usize, value: u8) -> Result<Self, String>
[src]
fn set_u16(
self,
start: usize,
length: usize,
value: u16
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: u16
) -> Result<Self, String>
fn set_u32(
self,
start: usize,
length: usize,
value: u32
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: u32
) -> Result<Self, String>
fn set_u64(
self,
start: usize,
length: usize,
value: u64
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: u64
) -> Result<Self, String>
fn set_i8(self, start: usize, length: usize, value: i8) -> Result<Self, String>
[src]
fn set_i16(
self,
start: usize,
length: usize,
value: i16
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: i16
) -> Result<Self, String>
fn set_i32(
self,
start: usize,
length: usize,
value: i32
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: i32
) -> Result<Self, String>
fn set_i64(
self,
start: usize,
length: usize,
value: i64
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: i64
) -> Result<Self, String>
impl InsertBitsIntoIntegralTypes for u16
[src]
fn set_u8(self, start: usize, length: usize, value: u8) -> Result<Self, String>
[src]
fn set_u16(
self,
start: usize,
length: usize,
value: u16
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: u16
) -> Result<Self, String>
fn set_u32(
self,
start: usize,
length: usize,
value: u32
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: u32
) -> Result<Self, String>
fn set_u64(
self,
start: usize,
length: usize,
value: u64
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: u64
) -> Result<Self, String>
fn set_i8(self, start: usize, length: usize, value: i8) -> Result<Self, String>
[src]
fn set_i16(
self,
start: usize,
length: usize,
value: i16
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: i16
) -> Result<Self, String>
fn set_i32(
self,
start: usize,
length: usize,
value: i32
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: i32
) -> Result<Self, String>
fn set_i64(
self,
start: usize,
length: usize,
value: i64
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: i64
) -> Result<Self, String>
impl InsertBitsIntoIntegralTypes for u32
[src]
fn set_u8(self, start: usize, length: usize, value: u8) -> Result<Self, String>
[src]
fn set_u16(
self,
start: usize,
length: usize,
value: u16
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: u16
) -> Result<Self, String>
fn set_u32(
self,
start: usize,
length: usize,
value: u32
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: u32
) -> Result<Self, String>
fn set_u64(
self,
start: usize,
length: usize,
value: u64
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: u64
) -> Result<Self, String>
fn set_i8(self, start: usize, length: usize, value: i8) -> Result<Self, String>
[src]
fn set_i16(
self,
start: usize,
length: usize,
value: i16
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: i16
) -> Result<Self, String>
fn set_i32(
self,
start: usize,
length: usize,
value: i32
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: i32
) -> Result<Self, String>
fn set_i64(
self,
start: usize,
length: usize,
value: i64
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: i64
) -> Result<Self, String>
impl InsertBitsIntoIntegralTypes for u64
[src]
fn set_u8(self, start: usize, length: usize, value: u8) -> Result<Self, String>
[src]
fn set_u16(
self,
start: usize,
length: usize,
value: u16
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: u16
) -> Result<Self, String>
fn set_u32(
self,
start: usize,
length: usize,
value: u32
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: u32
) -> Result<Self, String>
fn set_u64(
self,
start: usize,
length: usize,
value: u64
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: u64
) -> Result<Self, String>
fn set_i8(self, start: usize, length: usize, value: i8) -> Result<Self, String>
[src]
fn set_i16(
self,
start: usize,
length: usize,
value: i16
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: i16
) -> Result<Self, String>
fn set_i32(
self,
start: usize,
length: usize,
value: i32
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: i32
) -> Result<Self, String>
fn set_i64(
self,
start: usize,
length: usize,
value: i64
) -> Result<Self, String>
[src]
self,
start: usize,
length: usize,
value: i64
) -> Result<Self, String>