Skip to main content

OutputFile

Struct OutputFile 

Source
pub struct OutputFile { /* private fields */ }
Expand description

The archive file a creation writes: its path, whether it may replace an existing file and how its format is chosen.

The archive is staged in a temporary file in the target’s directory (which must be writable) and renamed into place only when it is complete, so a failed creation leaves the path as it was. The output must be absent, a regular file, or a symlink to one (or dangling); a directory, a FIFO or a device is refused with InvalidConfiguration.

Replacing keeps the permission bits of the file that is replaced (a symlink is resolved first), never wider than before and without setuid, setgid or sticky bits; a new file gets 0o666 filtered by the umask. Owner, group, ACLs and extended attributes of a replaced file are not preserved: the new file belongs to the creating user and to the group the filesystem gives a new file in that directory (the directory’s group on macOS and BSD), so a file that was shared through its group can become readable by another group under the same mode bits.

The staged file and the target are never archived, even when a source directory contains them. They are recognized by file name and canonical parent directory, so an alias of the output directory that canonicalization does not resolve (a bind or nullfs mount of it inside a source tree) is not recognized and the output may be archived into itself. Do not put such a mount under a source.

A ProgressCallback that reports is_cancelled stops the creation: nothing is published and a previous output stays as it was. After the archive is published the parent directory is synced on a best-effort basis (Unix).

§Examples

use exarch_core::OutputFile;
use exarch_core::OutputFormat;
use exarch_core::OutputPolicy;
use exarch_core::formats::detect::CreatableFormat;

let out = OutputFile::replace("backup.tar.gz");
assert_eq!(out.policy(), OutputPolicy::Replace);
assert_eq!(out.format(), OutputFormat::FromExtension);

let out = OutputFile::create_new("bundle.apk").with_format(CreatableFormat::Zip);
assert_eq!(out.format(), OutputFormat::Explicit(CreatableFormat::Zip));

Implementations§

Source§

impl OutputFile

Source

pub fn create_new(path: impl Into<PathBuf>) -> Self

An output at path that must not exist yet.

Source

pub fn replace(path: impl Into<PathBuf>) -> Self

An output at path that replaces an existing file.

Source

pub const fn with_format(self, format: CreatableFormat) -> Self

Writes format instead of the one the extension names.

Source

pub const fn with_durability(self, durability: Durability) -> Self

Sets whether the archive is flushed to stable storage before success is reported.

Source

pub fn path(&self) -> &Path

The output path.

Source

pub const fn policy(&self) -> OutputPolicy

Whether an existing file may be replaced.

Source

pub const fn format(&self) -> OutputFormat

How the format is chosen.

Source

pub const fn durability(&self) -> Durability

Whether the archive is flushed to stable storage.

Trait Implementations§

Source§

impl Clone for OutputFile

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 OutputFile

Source§

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

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

impl Eq for OutputFile

Source§

impl PartialEq for OutputFile

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 OutputFile

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.