pub struct EntryExtractor<'target> { /* private fields */ }Expand description
Extracts the first regular file whose path exactly matches target.
The extractor does not allocate. It buffers one 512-byte tar header and
passes matching file contents directly to the callback supplied to
push. Input can be split at arbitrary byte boundaries.
Paths are compared as raw bytes. POSIX ustar prefix/name paths are
supported; extension records such as GNU long names and PAX path overrides
are intentionally not interpreted.
Implementations§
Source§impl<'target> EntryExtractor<'target>
impl<'target> EntryExtractor<'target>
Sourcepub const fn new(target: &'target [u8]) -> Self
pub const fn new(target: &'target [u8]) -> Self
Creates an extractor for an exact archive path.
Sourcepub fn push<E>(
&mut self,
input: &[u8],
output: impl FnMut(&[u8]) -> Result<(), E>,
) -> Result<(), ExtractError<E>>
pub fn push<E>( &mut self, input: &[u8], output: impl FnMut(&[u8]) -> Result<(), E>, ) -> Result<(), ExtractError<E>>
Consumes another fragment of the tar byte stream.
output is called only with bytes belonging to the selected regular
file. Once a match has been seen, later entries with the same path are
skipped.
Sourcepub const fn found(&self) -> bool
pub const fn found(&self) -> bool
Reports whether the requested entry has already been encountered.
Sourcepub fn finish(&self) -> Result<(), FinishError>
pub fn finish(&self) -> Result<(), FinishError>
Validates that the complete archive and requested entry were observed.