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
impl OutputFile
Sourcepub fn create_new(path: impl Into<PathBuf>) -> Self
pub fn create_new(path: impl Into<PathBuf>) -> Self
An output at path that must not exist yet.
Sourcepub fn replace(path: impl Into<PathBuf>) -> Self
pub fn replace(path: impl Into<PathBuf>) -> Self
An output at path that replaces an existing file.
Sourcepub const fn with_format(self, format: CreatableFormat) -> Self
pub const fn with_format(self, format: CreatableFormat) -> Self
Writes format instead of the one the extension names.
Sourcepub const fn with_durability(self, durability: Durability) -> Self
pub const fn with_durability(self, durability: Durability) -> Self
Sets whether the archive is flushed to stable storage before success is reported.
Sourcepub const fn policy(&self) -> OutputPolicy
pub const fn policy(&self) -> OutputPolicy
Whether an existing file may be replaced.
Sourcepub const fn format(&self) -> OutputFormat
pub const fn format(&self) -> OutputFormat
How the format is chosen.
Sourcepub const fn durability(&self) -> Durability
pub const fn durability(&self) -> Durability
Whether the archive is flushed to stable storage.
Trait Implementations§
Source§impl Clone for OutputFile
impl Clone for OutputFile
Source§impl Debug for OutputFile
impl Debug for OutputFile
impl Eq for OutputFile
Source§impl PartialEq for OutputFile
impl PartialEq for OutputFile
impl StructuralPartialEq for OutputFile
Auto Trait Implementations§
impl Freeze for OutputFile
impl RefUnwindSafe for OutputFile
impl Send for OutputFile
impl Sync for OutputFile
impl Unpin for OutputFile
impl UnsafeUnpin for OutputFile
impl UnwindSafe for OutputFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.