Expand description
The archive payload format for directory trees, carried inside an encrypted file’s content stream. The shadow archive payload format: a directory tree serialized as one byte stream.
An archive travels as the content of an encrypted file whose metadata
envelope marks it as crate::file::ContentKind::Archive, so it
inherits the container format’s encryption, authentication, and
streaming. This module defines only the plaintext payload layout and is
deliberately independent of the format versions: the layout carries its
own magic and version byte and can be reused by future container
versions unchanged.
Layout (all integers little endian):
magic: "SHDWARC" + version byte 1 (8 bytes)
entries, each:
entry_type: u8 (1 = file, 2 = directory, 0 = end)
for file/directory entries:
path_len: u16, path: UTF-8 ('/'-separated relative path)
flags: u8 (bit 0 mtime, bit 1 mode)
mtime_secs: i64, mtime_nanos: u32 (if flag)
mode: u32 (if flag)
for file entries:
content_len: u64, content bytes
terminator: entry_type 0; nothing may followDirectory entries appear before their contents. Paths are validated on
both encode and parse: relative, ‘/’-separated, no .. or . or empty
components, no backslashes.
Encoding is a set of pure functions producing header bytes (the caller
interleaves raw file content); parsing is the incremental
[ArchiveParser], fed arbitrary byte pieces and drained of
[ArchiveEvent]s, so neither side ever needs the whole archive in
memory.
Structs§
- Archive
Parser - Incremental archive parser:
ArchiveParser::feedit byte pieces of any size, then drainArchiveParser::next_eventuntil it returnsNone(more input needed). CallArchiveParser::finishafter the last feed to catch truncated streams. Buffered bytes are zeroized on drop.
Enums§
- Archive
Error - Errors from encoding or parsing an archive stream.
- Archive
Event - One parsed element of an archive stream, in stream order.
Constants§
- MAGIC
- MAX_
PATH_ LEN - Upper bound on an entry path, matching common filesystem limits.
Functions§
- encode_
directory - Header bytes for a directory entry.
metadata.filename()is the directory’s relative path. - encode_
end - The archive terminator entry.
- encode_
file - Header bytes for a file entry; exactly
content_lenraw content bytes must follow.metadata.filename()is the file’s relative path. - validate_
path - Validates a ‘/’-separated relative entry path.