Skip to main content

IncompleteOutputPolicy

Enum IncompleteOutputPolicy 

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

Cleanup policy for staged plaintext after a returned decryption error.

Decryption stages a file or directory at {output_dir}/{root_name}.incomplete. After payload authentication and archive validation complete, it promotes that entry to {output_dir}/{root_name} using the platform’s no-clobber commit route. Root permission and identity checks follow promotion. A pre-existing final or .incomplete entry is rejected, not reused or removed.

Self::DeleteOnError is the default; Self::RetainOnError preserves partial output for inspection or recovery. A failed or unconfirmed cleanup is reported in the returned error with the working path.

Once the output is confirmed as committed, later errors preserve it. These include a replaced final name, a changed or unconfirmable destination directory, a retained staging link, or a committed file with a link count other than one. The error describes the complete output or replacement; it must not be treated as evidence that nothing was written. Identity comparisons are skipped where the filesystem provides no usable identity; destination-directory confirmation also skips descriptor or memory exhaustion.

Extraction requires a retained handle to the staged root before streaming content. Failure to obtain it can leave an empty entry if cleanup also fails. Any remaining .incomplete entry blocks a retry.

A normal Err return applies this policy and reports, in the returned error, a removal that failed or could not be confirmed. A panic unwind applies it as well, best effort and without a report, because the panic is what propagates. A panic in a build with panic = "abort" aborts the process instead. An abort, any other process termination, and power loss run no cleanup, so staged plaintext can remain under either policy; the caller must inspect or remove that output explicitly.

This enum deliberately does not implement Copy: future policies may carry owned configuration, such as a destination for retained output.

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, remove the .incomplete working tree from output_dir. Directory permissions the run applied to its own staged tree are restored first, so a stored mode without owner write permission cannot keep the run’s own entries on disk. If the removal still fails or cannot be confirmed — a permission another process changed, a storage error, a staged tree that is no longer where it was created — the returned error names the working path and says whether plaintext may remain there (a staged file is emptied through its handle before the unlink, so one that could not be unlinked holds none). The original error keeps its class where that class carries a message, and otherwise becomes CryptoError::Io with both texts. A staged directory found to have another owner before any content was written is not this run’s, so it is named in the error and left in place rather than removed.

§

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. Completeness is established only by successfully authenticating a final chunk with last_flag = 1. An attacker who truncates the ciphertext at a chunk boundary can 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) -> 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 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() -> Self

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

impl Eq for IncompleteOutputPolicy

Source§

impl PartialEq for IncompleteOutputPolicy

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

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.