Skip to main content

Transaction

Struct Transaction 

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

A rollbackable transaction that executes a sequence of RollbackableOperations.

Implementations§

Source§

impl Transaction

Source

pub fn new() -> Self

Constructs a new, empty Transaction using the OS temporary directory for backups.

Source

pub fn with_temp_dir<P: AsRef<Path>>(temp_dir: P) -> Self

Constructs a new, empty Transaction with a custom backup directory.

Source

pub fn create_file<S: AsRef<Path>>(self, path: S) -> Self

Adds a CreateFile operation.

Source

pub fn create_dir<S: AsRef<Path>>(self, path: S) -> Self

Adds a CreateDirectory operation.

Source

pub fn append_file<S: AsRef<Path>>(self, path: S, data: Vec<u8>) -> Self

Adds an AppendFile operation.

Source

pub fn copy_file<S: AsRef<Path>, T: AsRef<Path>>( self, source: S, dest: T, ) -> Self

Adds a CopyFile operation.

Source

pub fn copy_dir<S: AsRef<Path>, T: AsRef<Path>>( self, source: S, dest: T, ) -> Self

Adds a CopyDirectory operation.

Source

pub fn delete_file<S: AsRef<Path>>(self, source: S) -> Self

Adds a DeleteFile operation.

Source

pub fn delete_dir<S: AsRef<Path>>(self, source: S) -> Self

Adds a DeleteDirectory operation.

Source

pub fn move_file<S: AsRef<Path>, T: AsRef<Path>>( self, source: S, dest: T, ) -> Self

Adds a MoveFile operation.

Source

pub fn move_dir<S: AsRef<Path>, T: AsRef<Path>>( self, source: S, dest: T, ) -> Self

Adds a MoveDirectory operation.

Source

pub fn write_file<S: AsRef<Path>>(self, path: S, data: Vec<u8>) -> Self

Adds a WriteFile operation.

Source

pub fn touch_file<S: AsRef<Path>>(self, path: S) -> Self

Adds a TouchFile operation.

Trait Implementations§

Source§

impl Default for Transaction

Source§

fn default() -> Self

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

impl RollbackableOperation for Transaction

Source§

fn execute(&mut self) -> Result<()>

Executes all operations in order, stopping at the first error.

Source§

fn rollback(&mut self) -> Result<()>

Rolls back all executed operations in reverse order, then resets the counter.

Only the operations that completed successfully are rolled back.

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> 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.