pub struct BitWriter { /* private fields */ }Expand description
Writes a bitstream for output. Takes the blocks packed by BitPacker and assembles them with the stream header and footer, calculating the stream CRC as it processes the blocks.
Implementations§
Source§impl BitWriter
impl BitWriter
Sourcepub fn new(filepath: &str, block_size: u8) -> Self
pub fn new(filepath: &str, block_size: u8) -> Self
Create a new Bitwriter with an output buffer of size specified. We need the block size. to create the header. Use add_block() to add each block to the stream.
Sourcepub fn add_block(
&mut self,
last: bool,
data: &[u8],
padding: u8,
) -> Result<usize, Error>
pub fn add_block( &mut self, last: bool, data: &[u8], padding: u8, ) -> Result<usize, Error>
Add a block of data to the output. The block is assumed to be packed by BitPacker. “last” indicates if the block is the last block in the file. “padding” indicates how many trailing zeros were added to the last byte of the block to make it a multiple of 8 bits.
Auto Trait Implementations§
impl Freeze for BitWriter
impl !RefUnwindSafe for BitWriter
impl Send for BitWriter
impl Sync for BitWriter
impl Unpin for BitWriter
impl !UnwindSafe for BitWriter
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