[−][src]Struct compu::compressor::memory::Compressor
Compressor
It stores compressed data in its internal buffer.
Once last chunk is pushed, by calling push
with op
equal to EncoderOp::FINISH
Result can be retrieved using output
or take
.
Usage
use compu::encoder::{Encoder, EncoderOp, BrotliEncoder}; let data = vec![5; 5]; let mut encoder = compu::compressor::memory::Compressor::new(BrotliEncoder::default()); let result = encoder.push(&data, EncoderOp::Finish); assert!(result); assert!(encoder.encoder().is_finished());
Methods
impl<E: Encoder> Compressor<E>
[src]
pub fn new(encoder: E) -> Self
[src]
Creates new instance
pub fn with_capacity(capacity: usize, encoder: E) -> Self
[src]
Creates new instance with provided capacity
pub fn encoder(&self) -> &E
[src]
Returns reference to underlying encoder
pub fn push(&mut self, data: &[u8], op: EncoderOp) -> bool
[src]
Pushes chunk to compressor
Specify op
as EncoderOp::Finish
when last chunk is being pushed
Returns whether operation is successful.
pub fn output<'a>(&'a self) -> &'a [u8]
[src]
Returns slice of currently compressed data
pub fn consume_output<'a>(&'a mut self) -> &'a [u8]
[src]
Returns slice of currently decompressed data and marks it as consumed
After calling this function, the underlying buffer basically sets length equal to 0 allowing to overwrite already written data with further pushes.
pub fn take(self) -> Vec<u8>
[src]
Consumes self and returns underlying data.
Auto Trait Implementations
impl<E> Send for Compressor<E> where
E: Send,
E: Send,
impl<E> Sync for Compressor<E> where
E: Sync,
E: Sync,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,