Struct FileWriter

Source
pub struct FileWriter<'a> {
    pub writer: BufWriter<File>,
    pub tmp_prefix: String,
    pub tmp_suffix: String,
    /* private fields */
}
Expand description

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.

Call complete() to rename() the file into place.

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§

Source§

impl<'a> FileWriter<'a>

Source

pub fn complete_with<P: AsRef<Path>, F>(self, dest: P, f: F) -> Result<()>
where F: Fn(&File) -> Result<()>,

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.

Source

pub fn complete<P: AsRef<Path>>(self, dest: P) -> Result<()>

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

Auto Trait Implementations§

§

impl<'a> Freeze for FileWriter<'a>

§

impl<'a> RefUnwindSafe for FileWriter<'a>

§

impl<'a> Send for FileWriter<'a>

§

impl<'a> Sync for FileWriter<'a>

§

impl<'a> Unpin for FileWriter<'a>

§

impl<'a> UnwindSafe for FileWriter<'a>

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> 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, 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.
Source§

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

Source§

fn vzip(self) -> V