tag | b1a84f641fd387be87381be0cb83ad997450a9de | |
---|---|---|
tagger | The Android Open Source Project <[email protected]> | Wed Nov 01 17:06:50 2023 -0700 |
object | 631b22dfc848ccb7b7073fbf97d64c5fec451fee |
frc_340819190 (10894928,com.google.android.healthfitness)
commit | 631b22dfc848ccb7b7073fbf97d64c5fec451fee | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Tue Apr 11 17:57:36 2023 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Tue Apr 11 17:57:36 2023 +0000 |
tree | 7442a329d612499cdc5be0c9b778eae0c2dc76d4 | |
parent | 3ed2ce34ba25224315e624338b6ba897a21b3ad9 [diff] | |
parent | 99b6890a0b908852988a336f327604d36a08184e [diff] |
Snap for 9912757 from 99b6890a0b908852988a336f327604d36a08184e to aml-frc-release Change-Id: I1bb8969f78e107688210128dd921db00dc537ee6
BitReader is a helper type to extract strings of bits from a slice of bytes.
Here is how you read first a single bit, then three bits and finally four bits from a byte buffer:
use bitreader::BitReader; let slice_of_u8 = &[0b1000_1111]; let mut reader = BitReader::new(slice_of_u8); // You obviously should use try! or some other error handling mechanism here let a_single_bit = reader.read_u8(1).unwrap(); // 1 let more_bits = reader.read_u8(3).unwrap(); // 0 let last_bits_of_byte = reader.read_u8(4).unwrap(); // 0b1111
You can naturally read bits from longer buffer of data than just a single byte.
As you read bits, the internal cursor of BitReader moves on along the stream of bits. Big endian format is assumed when reading the multi-byte values. BitReader supports reading maximum of 64 bits at a time (with read_u64).
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.