Skip to main content

Crate zip_framing

Crate zip_framing 

Source
Expand description

Strict ZIP record framing for asynchronous, seekable inputs.

The core API in this crate is Index, which can be built from a ZIP’s central directory and used to access individual members (after reconciling their central and local states).

Potentially relevant internals:

  • CentralDirectoryEntry, IndexedEntry, and Entry represent a refinement type hierarchy, i.e. they go from fewest invariants preserved (just parsing the central directory entry) to the most invariants preserved (a member whose central and local records have been checked for consistency).

  • Filenames and UNIX extra-field link targets must be UTF-8.

  • zip-framing does not decode or validate member payloads. It exposes their offsets and compressed sizes so consumers can read and decode them, then verify their decoded sizes and CRC32s.

  • zip-framing assumes that the ZIP source does not change.

§ZIP compatibility

  • zip-framing rejects empty filenames, including unnamed members from standard input (APPNOTE 4.4.17.1).

  • Directory member names must end in / so readers can identify their type from the filename alone.

  • APPNOTE 4.4.17.1 requires forward slashes as path separators. By default, zip-framing rejects backslashes in member names. See IndexPolicy::allow_backslashes.

  • By default, zip-framing rejects stored members that use a data descriptor, since other streaming ZIP parsers frequently misinterpret them. See IndexPolicy::allow_stored_data_descriptors.

  • By default, zip-framing does not honor symlink mode bits unless the host system indicated by the “version made by” field indicates a UNIX host (3). See IndexPolicy::allow_ambiguous_symlink_modes.

  • zip-framing rejects members that have the “record-oriented” bit set in their internal file attributes (APPNOTE 4.4.14.2).

  • By default, zip-framing accepts only required ZIP64 extra fields (0x0001). See ExtraFieldPolicy for options to accept other fields. Redundant local ZIP64 sizes require a separate opt-in through IndexPolicy::allow_redundant_zip64_sizes.

  • By default, each member header must declare at least the extraction version required by its features. See IndexPolicy::allow_incompatible_extraction_versions.

  • Timestamps may differ between headers and across formats. zip-framing accepts any packed DOS date and time and checks the layout of supported timestamp extras. It does not interpret or expose timestamp values.

  • Windows NT security descriptor extras (0x4453) may appear in either header or both. zip-framing checks each layout independently and ignores the declared size and descriptor contents.

Modules§

constants
ZIP wire-format values shared by record parsing, serialization, and codecs.
write
Canonical UTF-8, single-volume ZIP64 record serialization.

Structs§

Budget
ZIP resource limits and cumulative metadata and uncompressed-size usage.
CentralDirectoryEntry
Metadata retained from a member’s central directory entry.
CommentPolicy
Which comments the reader accepts in member and end records.
DeviceNumbers
Device numbers from a PKWARE UNIX extra field.
Entry
A member whose local file entry, extras, and optional data descriptor have been reconciled with the directory and checked for a consistent kind.
ExtraHeaderIdSet
A set of known ZIP extra-field identifiers for ExtraFieldPolicy::AllowListed.
Index
A ZIP member index.
IndexPolicy
Controls resource limits and compatibility when indexing a ZIP archive.
IndexedEntry
An indexed ZIP member and its central directory entry.
Limits
Limits applied when reading ZIP archives.

Enums§

BudgetError
A failed cumulative budget charge.
CommentRule
Which ZIP comment bytes the reader accepts. Empty comments are always accepted.
CompressionMethod
A supported ZIP compression method.
EntryKind
A ZIP member’s kind, determined from its reconciled metadata.
Error
A failure while reading or writing ZIP records.
ExtraFieldPolicy
Which extra fields a reader accepts in local and central member headers.
ExtraHeaderId
A supported ZIP member extra-field identifier. The discriminant is the wire value.
HostSystem
The host-system interpretation of a ZIP member’s external attributes.
IndexPolicyViolation
A supported ZIP feature excluded by the selected IndexPolicy.
LimitExceeded
A ZIP resource limit and its configured maximum.