pub struct Reader<R, D> {
reader: R,
operation: D,
state: State,
single_frame: bool,
finished_frame: bool,
}Expand description
Fields§
§reader: R§operation: D§state: State§single_frame: bool§finished_frame: boolImplementations§
Source§impl<R, D> Reader<R, D>
impl<R, D> Reader<R, D>
Sourcepub fn new(reader: R, operation: D) -> Self
pub fn new(reader: R, operation: D) -> Self
Creates a new Reader.
reader will be used to pull input data for the given operation.
Sourcepub fn set_single_frame(&mut self)
pub fn set_single_frame(&mut self)
Sets self to stop after the first decoded frame.
Sourcepub fn operation_mut(&mut self) -> &mut D
pub fn operation_mut(&mut self) -> &mut D
Returns a mutable reference to the underlying operation.
Sourcepub fn reader_mut(&mut self) -> &mut R
pub fn reader_mut(&mut self) -> &mut R
Returns a mutable reference to the underlying reader.
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Returns the inner reader.
Source§impl<R, D> Reader<R, D>
impl<R, D> Reader<R, D>
Sourcepub fn finish_frame(&mut self) -> Result<()>
pub fn finish_frame(&mut self) -> Result<()>
Consume the rest of the current frame from the underlying reader.
Once all the decoded data has been read, zstd may still not have consumed the tail of the frame: it can produce the last of the output before reading the frame epilogue. The underlying reader is then left pointing somewhere inside the frame rather than just after it.
This feeds zstd the input it still needs, with no room for output, so the reader ends up positioned exactly at the end of the frame.
It stops there: it will not start decoding whatever follows, so a stream of concatenated frames keeps its remaining frames, and trailing non-zstd data is left untouched.
This is a no-op if the current frame is already complete, so it will not read from the underlying reader in that case.
Trait Implementations§
Source§impl<R, D> Read for Reader<R, D>
impl<R, D> Read for Reader<R, D>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read more