bitlab
Extracting a range of bits from binary data
Objective:
To help developing applications, which extract bit level data from a binary source such as spacecraft telemetry
Status
Experimental
Documentation
This crate is published at crates.io. The detailed documentation is available at docs.rs/bitlab
Version
0.3.0
Installation
Just add the following line under [dependencies] to your Cargo.toml file
bitlab = "0.3.0"
Examples
Example 1:
Start at bit offset 1, extract 3 bits and interpret the result as u8
use *;
let a: i8 = -33; // = 0b1101_1111;
let b = a.get_u8.unwrap; // 1 --> 101 <-- 1111
// = 5
assert_eq!;
Example 2:
The data source is a vector of u8 types. We want to go to byte offset 1, bit offset 7 and starting from there extract 3 bits as an u16
use *;
let v: = vec!; // = "Hallo"
let bar = v.get_u16; // relevant bytes = 0x616C = 0b0110_000 --> 1_01 <-- 10_1100
// = 5
assert_eq!;