pub struct EntryFsm { /* private fields */ }
Expand description
A state machine that can parse a zip entry
Implementations§
source§impl EntryFsm
impl EntryFsm
sourcepub fn new(entry: Option<Entry>, buffer: Option<Buffer>) -> Self
pub fn new(entry: Option<Entry>, buffer: Option<Buffer>) -> Self
Create a new state machine for decompressing a zip entry
sourcepub fn wants_read(&self) -> bool
pub fn wants_read(&self) -> bool
If this returns true, the caller should read data from into Self::space — without forgetting to call Self::fill with the number of bytes written.
sourcepub fn process_till_header(&mut self) -> Result<Option<&Entry>, Error>
pub fn process_till_header(&mut self) -> Result<Option<&Entry>, Error>
Like process
, but only processes the header. If this returns
Ok(None)
, the caller should read more data and call this function
again.
sourcepub fn process(
self,
out: &mut [u8],
) -> Result<FsmResult<(Self, DecompressOutcome), Buffer>, Error>
pub fn process( self, out: &mut [u8], ) -> Result<FsmResult<(Self, DecompressOutcome), Buffer>, Error>
Process the input and write the output to the given buffer
This function will return FsmResult::Continue
if it needs more input
to continue, or if it needs more space to write to. It will return
FsmResult::Done
when all the input has been decompressed and all
the output has been written.
Also, after writing all the output, process will read the data descriptor (if any), and make sur the CRC32 hash and the uncompressed size match the expected values.
sourcepub fn space(&mut self) -> &mut [u8] ⓘ
pub fn space(&mut self) -> &mut [u8] ⓘ
Returns a mutable slice with all the available space to write to.
After writing to this, call Self::fill with the number of bytes written.
sourcepub fn fill(&mut self, count: usize) -> usize
pub fn fill(&mut self, count: usize) -> usize
After having written data to Self::space, call this to indicate how many bytes were written.