pub struct Decoder(/* private fields */);Expand description
Implementations§
Source§impl Decoder
impl Decoder
Sourcepub fn new(format: Format) -> Self
pub fn new(format: Format) -> Self
A decoder for format with the default limits.
§Examples
let dec = compress_lib::Decoder::new(compress_lib::Format::Zlib);
assert_eq!(dec.format(), compress_lib::Format::Zlib);Sourcepub fn with_limits(self, limits: Limits) -> Self
pub fn with_limits(self, limits: Limits) -> Self
Sets the limits checked while decoding.
§Examples
use compress_lib::{Decoder, Format, Limits};
let dec = Decoder::new(Format::Gzip).with_limits(Limits::new().with_max_output(1 << 20));Sourcepub fn format(&self) -> Format
pub fn format(&self) -> Format
The format decoded.
§Examples
use compress_lib::{Decoder, Format};
assert_eq!(Decoder::new(Format::Raw).format(), Format::Raw);Sourcepub fn decompress(
&mut self,
input: &[u8],
output: &mut [u8],
) -> Result<Progress, Error>
pub fn decompress( &mut self, input: &[u8], output: &mut [u8], ) -> Result<Progress, Error>
Sourcepub fn finish(
&mut self,
input: &[u8],
output: &mut [u8],
) -> Result<Progress, Error>
pub fn finish( &mut self, input: &[u8], output: &mut [u8], ) -> Result<Progress, Error>
As Inflater::finish.
§Errors
The errors of the format’s decoder, plus UnexpectedEnd.
§Examples
use compress_lib::{Decoder, Format, gzip};
let mut out = [0u8; 16];
let p = Decoder::new(Format::Gzip).finish(&gzip::compress(b"abc"), &mut out)?;
assert_eq!(&out[..p.produced], b"abc");Sourcepub fn decompress_vec(
&mut self,
input: &[u8],
out: &mut Vec<u8>,
) -> Result<Progress, Error>
pub fn decompress_vec( &mut self, input: &[u8], out: &mut Vec<u8>, ) -> Result<Progress, Error>
Sourcepub fn finish_vec(
&mut self,
input: &[u8],
out: &mut Vec<u8>,
) -> Result<Progress, Error>
pub fn finish_vec( &mut self, input: &[u8], out: &mut Vec<u8>, ) -> Result<Progress, Error>
Sourcepub fn is_done(&self) -> bool
pub fn is_done(&self) -> bool
true once the stream ended.
§Examples
assert!(!compress_lib::Decoder::new(compress_lib::Format::Gzip).is_done());Sourcepub fn total_in(&self) -> u64
pub fn total_in(&self) -> u64
Compressed bytes consumed.
§Examples
assert_eq!(compress_lib::Decoder::new(compress_lib::Format::Gzip).total_in(), 0);Trait Implementations§
Auto Trait Implementations§
impl Forget for Decoder
impl Freeze for Decoder
impl RefUnwindSafe for Decoder
impl Send for Decoder
impl Sync for Decoder
impl Unpin for Decoder
impl UnsafeUnpin for Decoder
impl UnwindSafe for Decoder
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