Struct cmprsd::huffman::CompressedData
source · pub struct CompressedData {
pub bits: Vec<u8>,
pub meaningful_bits: u8,
}Expand description
Struct that represents compressed data.
Fields§
§bits: Vec<u8>Vector of compressed bytes. each compressed block is stored at a bit level.
TODO: allow to use u8, u16, u32, u64 :
meaningful_bits: u8As we store blocks of 8 bits, not all 8 bits are used at all times. We therefore need a way to store how many bits are used or not used in the last byte. Currently I store how many of these bits are used.
Implementations§
source§impl CompressedData
impl CompressedData
sourcepub fn get_empty() -> CompressedData
pub fn get_empty() -> CompressedData
Returns a compressed data entity which stores 0 bits.
sourcepub fn from_bits_as_u8(bits_as_u8: &[u8]) -> CompressedData
pub fn from_bits_as_u8(bits_as_u8: &[u8]) -> CompressedData
Take as input a vector of 0s and 1s and store them as bits.
pub fn is_empty(&self) -> bool
sourcepub fn pad(&mut self, padding_size: u8)
pub fn pad(&mut self, padding_size: u8)
Helper function to pad a block of bits. Usefull when combining blocks.
sourcepub fn add(&mut self, other: &CompressedData)
pub fn add(&mut self, other: &CompressedData)
Append bits of the other compressed data to self.
Trait Implementations§
source§impl Clone for CompressedData
impl Clone for CompressedData
source§fn clone(&self) -> CompressedData
fn clone(&self) -> CompressedData
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 moreAuto Trait Implementations§
impl Freeze for CompressedData
impl RefUnwindSafe for CompressedData
impl Send for CompressedData
impl Sync for CompressedData
impl Unpin for CompressedData
impl UnwindSafe for CompressedData
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