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.
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
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: usizeNumber 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.
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
End
Archive end marker reached (two consecutive zero blocks, or clean EOF).