pub struct BitwiseData {
pub data: Vec<u8>,
pub total_bits: usize,
}
Expand description
- A utility for you to manipulate data bitwise, mainly to concatenate data in bits or to split data from a specific bit position.
- A utility for you to manipulate data bitwise, mainly to concatenate data in bits or to split data from a specific bit position.
- This is mainly used for Vorbis data parsing.
Fields§
§data: Vec<u8>
- Store as bytes
total_bits: usize
- The total bits of the books
Implementations§
Source§impl BitwiseData
impl BitwiseData
pub fn new(data: &[u8], total_bits: usize) -> BitwiseData
Sourcepub fn from_bytes(data: &[u8]) -> BitwiseData
pub fn from_bytes(data: &[u8]) -> BitwiseData
- Construct from bytes
Sourcepub fn get_total_bits(&self) -> usize
pub fn get_total_bits(&self) -> usize
- Get the number of total bits in the
data
field
Sourcepub fn get_total_bytes(&self) -> usize
pub fn get_total_bytes(&self) -> usize
- Get the number of bytes that are just enough to contain all of the bits.
Sourcepub fn calc_total_bytes(total_bits: usize) -> usize
pub fn calc_total_bytes(total_bits: usize) -> usize
- Get the number of bytes that are just enough to contain all of the bits.
Sourcepub fn fit_to_aligned_size(&mut self)
pub fn fit_to_aligned_size(&mut self)
- Resize to the aligned size. Doing this is for
shift_data_to_front()
andshift_data_to_back()
to manipulate bits efficiently.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
- Resize to the number of bytes that are just enough to contain all of the bits.
Sourcepub fn is_aligned_size(&self) -> bool
pub fn is_aligned_size(&self) -> bool
- Check if the data length is just the aligned size.
Sourcepub fn split(&self, split_at_bit: usize) -> (BitwiseData, BitwiseData)
pub fn split(&self, split_at_bit: usize) -> (BitwiseData, BitwiseData)
- Breakdown to 2 parts of the data at the specific bitvise position.
Sourcepub fn concat(&mut self, rhs: &BitwiseData)
pub fn concat(&mut self, rhs: &BitwiseData)
- Concat another
BitwiseData
to the bitstream, without the gap.
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
- Turn to byte array
Trait Implementations§
Source§impl Clone for BitwiseData
impl Clone for BitwiseData
Source§fn clone(&self) -> BitwiseData
fn clone(&self) -> BitwiseData
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for BitwiseData
impl Debug for BitwiseData
Source§impl Default for BitwiseData
impl Default for BitwiseData
Source§fn default() -> BitwiseData
fn default() -> BitwiseData
Returns the “default value” for a type. Read more
Source§impl PartialEq for BitwiseData
impl PartialEq for BitwiseData
impl Eq for BitwiseData
impl StructuralPartialEq for BitwiseData
Auto Trait Implementations§
impl Freeze for BitwiseData
impl RefUnwindSafe for BitwiseData
impl Send for BitwiseData
impl Sync for BitwiseData
impl Unpin for BitwiseData
impl UnwindSafe for BitwiseData
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