Skip to main content

ParseEvent

Enum ParseEvent 

Source
pub enum ParseEvent<'a> {
    NeedData {
        min_bytes: usize,
    },
    Entry {
        consumed: usize,
        entry: ParsedEntry<'a>,
    },
    SparseEntry {
        consumed: usize,
        entry: ParsedEntry<'a>,
        sparse_map: Vec<SparseEntry>,
        real_size: u64,
    },
    GlobalExtensions {
        consumed: usize,
        pax_data: &'a [u8],
    },
    End {
        consumed: usize,
    },
}
Expand description

Events emitted by the sans-IO parser.

Variants§

§

NeedData

Need more data to continue parsing.

No bytes are consumed from the input when this event is returned. The caller should ensure at least min_bytes bytes are available before calling parse again with the same (or larger) buffer.

Fields

§min_bytes: usize

Minimum number of bytes needed to make progress.

§

Entry

A complete entry header has been parsed.

The entry contains resolved metadata (path, link target, etc.) with GNU long name/link and PAX extensions applied.

After this event, the caller must read or skip entry.size bytes of content plus padding to the next 512-byte boundary before calling parse() again with the next header bytes.

Fields

§consumed: usize

Number of bytes consumed from the input for this entry’s header(s).

§entry: ParsedEntry<'a>

The parsed entry with resolved metadata.

§

SparseEntry

A GNU sparse file entry has been parsed.

This is emitted instead of Entry when the entry type is GnuSparse (type ‘S’). The sparse map describes which regions of the logical file contain real data; gaps are implicitly zero-filled.

After this event, the caller must read or skip entry.size bytes of content (the on-disk data for the sparse regions) plus padding to the next 512-byte boundary before calling parse() again. The consumed count already includes any GNU sparse extension blocks that followed the header.

Fields

§consumed: usize

Number of bytes consumed from the input for this entry’s header(s), including any GNU sparse extension blocks.

§entry: ParsedEntry<'a>

The parsed entry with resolved metadata. entry.size is the on-disk content size (sum of sparse chunk lengths). The logical file size is real_size.

§sparse_map: Vec<SparseEntry>

The sparse data map: regions of real data within the logical file.

§real_size: u64

The logical (uncompressed) size of the file, from the GNU header’s realsize field.

§

GlobalExtensions

A PAX global extended header (type ‘g’) has been parsed.

Per POSIX, global headers apply default attributes to all subsequent entries in the archive. However, this parser does not apply them automatically — it surfaces the raw data so the caller can decide how to handle it (e.g., merge into a defaults table, ignore, etc.).

The pax_data can be parsed with PaxExtensions::new.

Fields

§consumed: usize

Number of bytes consumed from the input (header + padded content).

§pax_data: &'a [u8]

The raw PAX key-value data from the global header.

§

End

Archive end marker reached (two consecutive zero blocks, or clean EOF).

Fields

§consumed: usize

Number of bytes consumed from the input.

Trait Implementations§

Source§

impl<'a> Debug for ParseEvent<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ParseEvent<'a>

§

impl<'a> RefUnwindSafe for ParseEvent<'a>

§

impl<'a> Send for ParseEvent<'a>

§

impl<'a> Sync for ParseEvent<'a>

§

impl<'a> Unpin for ParseEvent<'a>

§

impl<'a> UnsafeUnpin for ParseEvent<'a>

§

impl<'a> UnwindSafe for ParseEvent<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.