Skip to main content

ArchiveLimits

Struct ArchiveLimits 

Source
#[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

Source

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.

Source

pub const ENTRY_COUNT_DEFAULT: u32 = 250_000

Default manifest entry count (250,000 entries).

Source

pub const TOTAL_PLAINTEXT_BYTES_DEFAULT: u64

Default cumulative logical regular-file byte count (64 GiB).

Source

pub const PATH_DEPTH_DEFAULT: u32 = 64

Default per-path component count (64 components).

Source

pub const PATH_BYTES_DEFAULT: u32 = 4096

Default per-path UTF-8 byte length (4,096 bytes).

Source

pub const MANIFEST_BYTES_DEFAULT: u32

Default serialized manifest byte length (64 MiB).

Source

pub const ARCHIVE_EXT_BYTES_DEFAULT: u32

Default archive-level TLV region byte length (64 KiB).

Source

pub const ENTRY_EXT_BYTES_DEFAULT: u32

Default per-entry TLV region byte length (64 KiB).

Source

pub const TOTAL_ENTRY_EXT_BYTES_DEFAULT: u64

Default cumulative per-entry TLV byte length (64 MiB).

Source

pub const TLV_VALUE_BYTES_DEFAULT: u32

Default single-TLV value byte length (16 MiB).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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).

Trait Implementations§

Source§

impl Clone for ArchiveLimits

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ArchiveLimits

Source§

impl Debug for ArchiveLimits

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ArchiveLimits

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for ArchiveLimits

Source§

impl PartialEq for ArchiveLimits

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ArchiveLimits

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.