#[non_exhaustive]pub struct ArchiveLimits { /* private fields */ }Expand description
Resource caps for FCA archive encoding and extraction.
The defaults suit ordinary files and directory trees. Raise a cap only for input of a known origin that legitimately exceeds it, and pass the same value to both sides when possible. Reader limits must admit the archive’s actual contents, regardless of the writer’s configured ceilings.
Every cap has a published *_DEFAULT constant, so adjusting one cap
relative to the defaults does not mean copying a number out of
FORMAT.md §9.12. Only ArchiveLimits::max_path_bytes has a
structural ceiling — the on-disk path_len field is a u16 — and its
builder method clamps there, so safe downstream code cannot construct a
cap the format cannot represent. The other caps are resource policy alone
and accept any value their type holds.
Archive caps are enforced at the earliest point their authenticated FCA values are available. Encryption applies them during archive preflight, before key derivation or output staging. Decryption must first authenticate and begin decrypting the FCA payload; each cap then runs before the allocation, content copy, or filesystem work that it bounds, and complete manifest validation still precedes filesystem output.
The archive count, size, path, and extension-region caps surface as
dedicated Archive*CapExceeded errors. A TLV value above
max_tlv_value_bytes is instead a TLV grammar defect and surfaces as
CryptoError::InvalidFormat(FormatDefect::MalformedTlv).
Pass a value to crate::Encryptor::archive_limits,
crate::PassphraseDecryptor::archive_limits, or
crate::PrivateKeyDecryptor::archive_limits. The struct is
#[non_exhaustive] so future releases can add further caps without a
breaking change.
This type remains Copy: its resource caps are numeric bounds, including
any caps added in future releases.
Implementations§
Source§impl ArchiveLimits
impl ArchiveLimits
Sourcepub const PATH_BYTES_STRUCTURAL_MAX: u32
pub const PATH_BYTES_STRUCTURAL_MAX: u32
Structural maximum for the per-path byte cap (65,535 bytes): the
on-disk path_len field is a u16 (FORMAT.md §9.12).
ArchiveLimits::max_path_bytes clamps at this value. It is the
only cap the format itself bounds; the rest are resource policy.
Sourcepub const ENTRY_COUNT_DEFAULT: u32 = 250_000
pub const ENTRY_COUNT_DEFAULT: u32 = 250_000
Default manifest entry count (250,000 entries).
Sourcepub const TOTAL_PLAINTEXT_BYTES_DEFAULT: u64
pub const TOTAL_PLAINTEXT_BYTES_DEFAULT: u64
Default cumulative logical regular-file byte count (64 GiB).
Sourcepub const PATH_DEPTH_DEFAULT: u32 = 64
pub const PATH_DEPTH_DEFAULT: u32 = 64
Default per-path component count (64 components).
Sourcepub const PATH_BYTES_DEFAULT: u32 = 4096
pub const PATH_BYTES_DEFAULT: u32 = 4096
Default per-path UTF-8 byte length (4,096 bytes).
Sourcepub const MANIFEST_BYTES_DEFAULT: u32
pub const MANIFEST_BYTES_DEFAULT: u32
Default serialized manifest byte length (64 MiB).
Sourcepub const ARCHIVE_EXT_BYTES_DEFAULT: u32
pub const ARCHIVE_EXT_BYTES_DEFAULT: u32
Default archive-level TLV region byte length (64 KiB).
Sourcepub const ENTRY_EXT_BYTES_DEFAULT: u32
pub const ENTRY_EXT_BYTES_DEFAULT: u32
Default per-entry TLV region byte length (64 KiB).
Sourcepub const TOTAL_ENTRY_EXT_BYTES_DEFAULT: u64
pub const TOTAL_ENTRY_EXT_BYTES_DEFAULT: u64
Default cumulative per-entry TLV byte length (64 MiB).
Sourcepub const TLV_VALUE_BYTES_DEFAULT: u32
pub const TLV_VALUE_BYTES_DEFAULT: u32
Default single-TLV value byte length (16 MiB).
Sourcepub fn max_entry_count(self, value: u32) -> Self
pub fn max_entry_count(self, value: u32) -> Self
Sets the maximum number of manifest entries. A source tree or a
manifest above the cap rejects with
CryptoError::ArchiveEntryCountCapExceeded before per-entry
state is allocated.
Sourcepub fn max_total_plaintext_bytes(self, value: u64) -> Self
pub fn max_total_plaintext_bytes(self, value: u64) -> Self
Sets the maximum cumulative logical byte count across regular-file
entries. A larger total rejects with
CryptoError::ArchiveTotalBytesCapExceeded before any file
content is copied.
Sourcepub fn max_path_depth(self, value: u32) -> Self
pub fn max_path_depth(self, value: u32) -> Self
Sets the maximum path component count for one archive entry. A
deeper path rejects with
CryptoError::ArchivePathDepthCapExceeded during source validation
or manifest parsing, before extraction.
Sourcepub fn max_path_bytes(self, value: u32) -> Self
pub fn max_path_bytes(self, value: u32) -> Self
Sets the maximum UTF-8 byte length of one archive path, clamped at
Self::PATH_BYTES_STRUCTURAL_MAX. A longer path rejects with
CryptoError::ArchivePathBytesCapExceeded. During decoding, the
declared length is checked before allocating the path string.
Sourcepub fn max_manifest_bytes(self, value: u32) -> Self
pub fn max_manifest_bytes(self, value: u32) -> Self
Sets the maximum serialized manifest byte length, per-entry TLV
regions included. A larger manifest rejects with
CryptoError::ArchiveManifestLenCapExceeded before the manifest
buffer is allocated.
Sourcepub fn max_archive_ext_bytes(self, value: u32) -> Self
pub fn max_archive_ext_bytes(self, value: u32) -> Self
Sets the maximum archive-level TLV region byte length. A larger
declared region rejects with
CryptoError::ArchiveExtLenCapExceeded before the extension
buffer is allocated.
Sourcepub fn max_entry_ext_bytes(self, value: u32) -> Self
pub fn max_entry_ext_bytes(self, value: u32) -> Self
Sets the maximum byte length of one per-entry TLV region. A larger
region rejects with
CryptoError::ArchiveEntryExtLenCapExceeded before its bytes are
sliced.
Sourcepub fn max_total_entry_ext_bytes(self, value: u64) -> Self
pub fn max_total_entry_ext_bytes(self, value: u64) -> Self
Sets the maximum cumulative byte length of every per-entry TLV
region in one manifest. A larger total rejects with
CryptoError::ArchiveTotalEntryExtCapExceeded while the manifest
is parsed.
Sourcepub fn max_tlv_value_bytes(self, value: u32) -> Self
pub fn max_tlv_value_bytes(self, value: u32) -> Self
Sets the maximum byte length of one TLV value inside an FCA
archive- or entry-level region. A region holding a longer value
rejects with CryptoError::InvalidFormat carrying
FormatDefect::MalformedTlv
while it is validated, not with an Archive*CapExceeded error
(FORMAT.md §9.12).