Skip to main content

IncompleteOutputPolicy

Enum IncompleteOutputPolicy 

Source
#[non_exhaustive]
pub enum IncompleteOutputPolicy { DeleteOnError, RetainOnError, }
Expand description

Policy for the .incomplete working tree when decrypt fails.

During decryption the archive is staged under {output_dir}/{root_name}.incomplete and atomically renamed to {output_dir}/{root_name} only after every authentication and validation check has passed. This policy controls what happens to the staged tree when a decrypt error occurs before that rename: payload AEAD failure on a later chunk, archive structural reject (manifest tree-shape failure, path-grammar reject, duplicate detection), trailing-bytes reject, or a final-name collision discovered at promotion time.

Self::DeleteOnError is the default. It matches the typical user expectation that “decrypt failed → no plaintext on disk” and avoids leaving authenticated-but-incomplete plaintext that an unaware caller could pick up.

Self::RetainOnError is the opt-in for backup-recovery and forensic flows where partial plaintext is more useful than no plaintext.

Note: this policy only governs cleanup of the .incomplete working tree after a normal Err return. Process termination (crash, SIGKILL, power loss) and panic unwinding bypass cleanup entirely, so a killed or panicking process can leave .incomplete output regardless of the policy. The library does not wrap extraction in catch_unwind; if a panic propagates out of unarchive, treat the working tree as if the process had been killed. It may contain authenticated but incomplete plaintext that the caller must inspect or remove explicitly.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

DeleteOnError

On decrypt error, best-effort remove the .incomplete working tree from output_dir. Cleanup failures (path already gone, permission denied, racing process) are swallowed so the original CryptoError is the value the caller sees.

§

RetainOnError

On decrypt error, leave the .incomplete working tree in output_dir for the caller to inspect or recover.

Truncation-prefix caveat: FerroCrypt’s payload uses XChaCha20-Poly1305 STREAM-BE32, which authenticates each 64 KiB chunk individually but does not detect truncation until the final chunk’s last_flag arrives. An attacker who can truncate the ciphertext at a chunk boundary can therefore choose which authenticated plaintext prefix is retained. Callers who opt in to retention and act on partial output must treat the staged plaintext as a potentially attacker-chosen subset of the original, not as the full original truncated by storage failure.

Trait Implementations§

Source§

impl Clone for IncompleteOutputPolicy

Source§

fn clone(&self) -> IncompleteOutputPolicy

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 IncompleteOutputPolicy

Source§

impl Debug for IncompleteOutputPolicy

Source§

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

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

impl Default for IncompleteOutputPolicy

Source§

fn default() -> IncompleteOutputPolicy

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

impl Eq for IncompleteOutputPolicy

Source§

impl PartialEq for IncompleteOutputPolicy

Source§

fn eq(&self, other: &IncompleteOutputPolicy) -> 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 IncompleteOutputPolicy

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.