Expand description
archive_core — a pure-Rust, forbid(unsafe), read-only archive layer
reader for forensics.
An archive is treated as a transparent optional archive layer: foo.E01.gz
resolves identically to foo.E01. peel_bytes removes one archive layer
when present, so a consumer can recurse until it reaches the real evidence.
Format determination follows the settled model: the content magic is the
authority for the compression codec actually applied (you cannot gzip-decode
bzip2 bytes), while the file name is a secondary hint used for aliases
(.tgz→gzip+tar) and the magic-absent formats. See sniff.
Codec coverage grows incrementally; gzip is wired first (the canonical
E01.gz archive layer). Large-member streaming / temp-spill (for multi-GB
inner evidence) is the next hardening step — today the peel is in-memory with
a hard output cap.
Structs§
- Archive
- A decoded, listable archive over an in-memory byte slice.
- Archive
Entry - One member of an archive.
- Concat
Source - One logical, seekable image reassembled by concatenating the ordered
per-segment handles of a raw split set (
.001/.002/.003). A logical offset maps to(segment, local offset); a singlereadnever crosses a segment boundary (the caller’sread_exactloops across it), andseekis bounded — a position past the end clamps to the total length. - Limits
- Bomb guards for
resolve. Every field is a hard cap that fails loud when tripped; the inflated-size cap is tracked cumulatively across all layers, not per layer. - Segment
- One member of an
AccessPlan::SegmentSet, carrying its own access strategy. - Segment
Sources - The ordered per-segment byte sources of a segmented image, each materialized
via its own
crate::Access(phase-2/3 executor) and ordered by segment number. ForSegmentKind::SplitRawthese concatenate (ConcatSource); forSegmentKind::Ewf/SegmentKind::SplitVmdkthey feed a container reader’s multi-segment backing (theSegmentBackingseam above). - SubRange
- A zero-copy, seekable window
[offset, offset + len)over a shared byte buffer. Reading never decompresses and never copies the member into a second buffer — the bytes come straight from the original archive image. The backing is anArcso several windows (e.g. every segment of a split set) share one copy of the archive rather than cloning it per window. - Temp
Backed - A seekable handle over a temp file holding a once-decoded stream. The temp
file lives under
std::env::temp_dirand is deleted when this value drops.
Enums§
- Access
- The access strategy for one member or segment, chosen from the archive’s member table without decompressing (ADR 0008, rule 4 — most-seekable first).
- Access
Plan - The classified, most-direct route from packed bytes to the evidence.
- Archive
Error - Codec
- The bare compression codec of an
AccessPlan::Wrapper. - Format
- A recognized packing format.
- Node
- A leaf of a fully-resolved packing tree.
- Peel
- The outcome of peeling a disk-image archive layer.
- Peel
Outcome - The result of attempting to peel one bare-compression layer.
- Peel
Source - The outcome of the seekable peel executor — the streaming twin of
crate::Peel. - Peeled
Source - The peeled inner evidence as a seekable handle: a zero-copy in-place window, a
zran checkpoint-indexed member, or a temp-backed decode. All implement
Read+Seek. - Reassembled
- The outcome of reassembling a segmented image (or the finding that the input is not a segment set).
- Segment
Kind - How a segmented set’s members reassemble into one logical image.
Traits§
- Read
Seek - A seekable byte source: the common capability every peeled handle exposes so
a consumer can take a
Box<dyn ReadSeek>without knowing the backing store.
Functions§
- detect
- Classify the most-direct access route to the evidence inside
data, content-authoritatively and name-free (ADR 0008, five rules): every decision is made from bytes plus the archive’s own internal member table; no payload is ever inflated to classify. - peel_
archive - Peel a bare gz/bz2 wrapper, OR extract the single member of a one-member
archive, to inner bytes. Multi-member archives (a collection, not a wrapped
image) return
Peel::NotPacked, as does anything unrecognized. - peel_
archive_ seekable - Peel a bare gz/bz2 wrapper, OR extract the single member of a one-member
archive, to a seekable handle — streaming to a temp file when a decode is
needed, or a zero-copy window when the member is stored verbatim. Multi-member
archives (a collection) and split sets return
PeelSource::NotPacked, as does anything unrecognized. - peel_
bytes - Peel one outer BARE gzip/bzip2 compression layer from
data. Archives (.tgz/.tbz2/.zip/.7z) are NOT peeled here — they are member lists; use [crate::archive::open].nameis an optional file-name hint. - reassemble
- Reassemble a segmented image: a
SegmentKind::SplitRawset becomes a stitchedConcatSource; anSegmentKind::Ewf/SegmentKind::SplitVmdkset yields its orderedSegmentSourcesfor a container reader’s backing; anything else isReassembled::NotSegmented. - resolve
- Fully resolve
datadown through every archive layer to a flat list of leaf files (and the directory entries seen along the way). - segment_
sources - Produce the ordered per-segment
PeeledSourcehandles for a segmented image, orOk(None)whendatais not a segment set. Each segment is materialized via its owncrate::Access(in-place window / zran index / temp spill), in segment-number order — the primitive bothreassembleand a container reader’sSegmentBackingbuild on. - sniff
- Determine the packing format. Container identity (zip / 7z) is decided by
magic; the tar-compression combos (
.tgz/.tbz2/.tbz/.tb2) are distinguished from bare gzip/bzip2 by the file name (the outer magic alone can’t tell a gzipped tar from a gzipped single file).