Skip to main content

Module reference

Module reference 

Source
Expand description

The canonical member-stream serialization the reference.json vectors and the C ABI surface (ffi) are defined over.

§Wire format

Every integer is big-endian. The stream a member-emitting FFI call hands out is exactly:

  1. member_count as u32;
  2. per member, in central-directory order:
    • name_len as u32, followed by the member name as UTF-8 bytes (the reader refuses non-UTF-8 names at ZipArchive::new, so the name is always valid);
    • method as u16 (0 stored, 8 DEFLATE);
    • data_descriptor as one byte, 0 or 1;
    • compressed_size as u64;
    • uncompressed_size as u64;
    • crc32 as u32;
    • content_len as u64, followed by exactly that many bytes of the extracted member content (CRC-verified by extraction).

The per-member sha256 digests in reference.json cover the content bytes alone; the member-emitting FFI operation returns the whole stream, so the language SDKs re-derive every recorded field from one buffer.

This module is the single definition of that format: the vector generator (tools/gen-reference) serializes its own records and shares no code with the runtime, so nothing was moved here — the generator stays untouched and the SDK-facing contract lives only in this file.

Functions§

member_bytes
Serializes one member — its central-directory facts plus the extracted content — into the canonical stream fragment (see the module docs for the exact layout).
members_stream
Serializes a whole parsed archive into the canonical byte stream the language SDKs receive: the u32 member count followed by every member in central-directory order, each extracted and CRC-verified.