Trait SingleFileOperation

Source
pub trait SingleFileOperation: RollbackableOperation + Drop {
    // Required methods
    fn get_path(&self) -> &Path;
    fn get_backup_path(&self) -> &Path;
    fn set_backup_path<S: AsRef<Path>>(&mut self, uuid: S);
    fn get_temp_dir(&self) -> &Path;

    // Provided methods
    fn dispose(&self) -> Result<()> { ... }
    fn create_backup_file(&mut self) -> Result<()> { ... }
}
Expand description

Trait that represents a single file operation

Required Methods§

Source

fn get_path(&self) -> &Path

Returns path to source file

Source

fn get_backup_path(&self) -> &Path

Returns path to backup file

Defaults to “”

Source

fn set_backup_path<S: AsRef<Path>>(&mut self, uuid: S)

Sets the backup path

Source

fn get_temp_dir(&self) -> &Path

Returns path to temp dir

Provided Methods§

Source

fn dispose(&self) -> Result<()>

Dispose off resources used by the operation

It should be called inside Drop

Source

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

Creates a backup of the source file

If backup file is successfully created, method should call set_backup_path

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§