Skip to main content

EntryExtractor

Struct EntryExtractor 

Source
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>

Source

pub const fn new(target: &'target [u8]) -> Self

Creates an extractor for an exact archive path.

Source

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.

Source

pub const fn found(&self) -> bool

Reports whether the requested entry has already been encountered.

Source

pub fn finish(&self) -> Result<(), FinishError>

Validates that the complete archive and requested entry were observed.

Auto Trait Implementations§

§

impl<'target> Freeze for EntryExtractor<'target>

§

impl<'target> RefUnwindSafe for EntryExtractor<'target>

§

impl<'target> Send for EntryExtractor<'target>

§

impl<'target> Sync for EntryExtractor<'target>

§

impl<'target> Unpin for EntryExtractor<'target>

§

impl<'target> UnsafeUnpin for EntryExtractor<'target>

§

impl<'target> UnwindSafe for EntryExtractor<'target>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.