pub struct StreamDecoder { /* private fields */ }Expand description
A streaming decoder: feed it input in any pieces, get output in any
pieces. Handles concatenated and skippable frames. No std needed;
Decoder wraps it as a std::io::Read.
let mut d = zstd_native::StreamDecoder::new();
let mut out = [0u8; 2];
let mut got = Vec::new();
let mut input = compressed;
loop {
let p = d.decode(input, &mut out)?;
input = &input[p.read..];
got.extend_from_slice(&out[..p.written]);
if input.is_empty() && p.at_frame_boundary {
break;
}
}
assert_eq!(got, b"hello");Implementations§
Source§impl StreamDecoder
impl StreamDecoder
Sourcepub fn with_dictionary(dict: Dictionary) -> Self
pub fn with_dictionary(dict: Dictionary) -> Self
A decoder that uses dict for every frame.
Sourcepub fn set_window_log_max(&mut self, log: u32)
pub fn set_window_log_max(&mut self, log: u32)
Sets the largest window accepted (frames needing more fail with
Error::WindowTooLarge), as 1 << log, log 10 to 31 (30 on
32-bit targets, as libzstd); values outside are clamped. Frames
with a window log over 31 (30 on 32-bit) are rejected in every
mode, one-shot decoding included.
The default is 27 (128 MiB), libzstd’s.
Sourcepub fn at_frame_boundary(&self) -> bool
pub fn at_frame_boundary(&self) -> bool
True between frames with no output pending.
Trait Implementations§
Source§impl Debug for StreamDecoder
impl Debug for StreamDecoder
Auto Trait Implementations§
impl Freeze for StreamDecoder
impl RefUnwindSafe for StreamDecoder
impl Send for StreamDecoder
impl Sync for StreamDecoder
impl Unpin for StreamDecoder
impl UnsafeUnpin for StreamDecoder
impl UnwindSafe for StreamDecoder
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