Struct openat_ext::FileWriter[][src]

pub struct FileWriter<'a> {
    pub writer: BufWriter<File>,
    pub tmp_prefix: String,
    pub tmp_suffix: String,
    // some fields omitted
}

A wrapper for atomically replacing a file. The primary field to access here is the writer. You can also configure the temporary prefix and suffix used for the temporary file before it is moved over the final destination.

To ensure that errors are handled correctly, you must explicitly invoke either complete() or abandon(). Letting this value drop without invoking either of those will panic (unless the thread is already panicing, in which case this requirement is skipped).

Fields

writer: BufWriter<File>

Write to the destination file.

tmp_prefix: String

This string will be used as a prefix for the temporary file

tmp_suffix: String

This string will be used as a suffix for the temporary file

Implementations

impl<'a> FileWriter<'a>[src]

pub fn complete_with<F>(self, f: F) -> Result<()> where
    F: Fn(&File) -> Result<()>, 
[src]

Flush any outstanding buffered data and rename the temporary file into place. The provided closure will be invoked on the real underlying file descriptor before it is renamed into place. You can use this to change file attributes. For example, you can change the mode, extended attributes, or invoke fchmod() to change ownership, etc.

pub fn complete(self) -> Result<()>[src]

Flush any outstanding buffered data and rename the temporary file into place.

pub fn abandon(self)[src]

Drop any buffered data and delete the temporary file without affecting the final destination.

Auto Trait Implementations

impl<'a> RefUnwindSafe for FileWriter<'a>[src]

impl<'a> Send for FileWriter<'a>[src]

impl<'a> Sync for FileWriter<'a>[src]

impl<'a> Unpin for FileWriter<'a>[src]

impl<'a> UnwindSafe for FileWriter<'a>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,