pub struct BytesBitsConverter { /* private fields */ }Implementations§
source§impl BytesBitsConverter
impl BytesBitsConverter
sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/example.rs (line 23)
22 23 24 25 26 27 28 29 30 31 32 33
fn example_data_bin_conversion() {
let converter = BytesBitsConverter::new();
let bytes = vec![0, 1, 2, 255];
let bits = vec![
0, 0, 0, 0, 0, 0, 0, 0, // 0
0, 0, 0, 0, 0, 0, 0, 1, // 1
0, 0, 0, 0, 0, 0, 1, 0, // 2
1, 1, 1, 1, 1, 1, 1, 1, // 255
];
assert_eq!(converter.bytes_to_bits(&bytes), bits);
assert_eq!(converter.bits_to_bytes(&bits), bytes);
}sourcepub fn bytes_to_bits(&self, bytes1: &[u8]) -> Vec<u8>
pub fn bytes_to_bits(&self, bytes1: &[u8]) -> Vec<u8>
Examples found in repository?
examples/example.rs (line 31)
22 23 24 25 26 27 28 29 30 31 32 33
fn example_data_bin_conversion() {
let converter = BytesBitsConverter::new();
let bytes = vec![0, 1, 2, 255];
let bits = vec![
0, 0, 0, 0, 0, 0, 0, 0, // 0
0, 0, 0, 0, 0, 0, 0, 1, // 1
0, 0, 0, 0, 0, 0, 1, 0, // 2
1, 1, 1, 1, 1, 1, 1, 1, // 255
];
assert_eq!(converter.bytes_to_bits(&bytes), bits);
assert_eq!(converter.bits_to_bytes(&bits), bytes);
}sourcepub fn bits_to_bytes(&self, bin1: &[u8]) -> Vec<u8>
pub fn bits_to_bytes(&self, bin1: &[u8]) -> Vec<u8>
Examples found in repository?
examples/example.rs (line 32)
22 23 24 25 26 27 28 29 30 31 32 33
fn example_data_bin_conversion() {
let converter = BytesBitsConverter::new();
let bytes = vec![0, 1, 2, 255];
let bits = vec![
0, 0, 0, 0, 0, 0, 0, 0, // 0
0, 0, 0, 0, 0, 0, 0, 1, // 1
0, 0, 0, 0, 0, 0, 1, 0, // 2
1, 1, 1, 1, 1, 1, 1, 1, // 255
];
assert_eq!(converter.bytes_to_bits(&bytes), bits);
assert_eq!(converter.bits_to_bytes(&bits), bytes);
}Auto Trait Implementations§
impl Freeze for BytesBitsConverter
impl RefUnwindSafe for BytesBitsConverter
impl Send for BytesBitsConverter
impl Sync for BytesBitsConverter
impl Unpin for BytesBitsConverter
impl UnwindSafe for BytesBitsConverter
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more