Skip to main content

TrashBackend

Trait TrashBackend 

Source
pub trait TrashBackend: Send + Sync {
    // Required methods
    fn trash<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 Path,
    ) -> Pin<Box<dyn Future<Output = Result<(), TrashError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn trash_bytes<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        original_path: &'life1 Path,
        bytes: &'life2 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<(), TrashError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn list<'life0, 'life1, 'async_trait>(
        &'life0 self,
        filter: Option<&'life1 str>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<TrashEntry>, TrashError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn find_by_name<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<TrashEntry>, TrashError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn restore<'life0, 'async_trait>(
        &'life0 self,
        entries: Vec<TrashEntry>,
    ) -> Pin<Box<dyn Future<Output = Result<(), TrashError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn purge_all<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<usize, TrashError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Backend trait for trash operations.

Required Methods§

Source

fn trash<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<(), TrashError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Move a file or directory to trash.

Source

fn trash_bytes<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, original_path: &'life1 Path, bytes: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), TrashError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Snapshot raw bytes into the trash under a name derived from original_path’s basename.

Used by the write-model gate to back up a file’s prior content before a truncating overwrite (tee/patch/sed -i). Unlike trash it copies rather than moves, so the file stays in place for the overwrite (and for read-modify-write callers). What’s recoverable is the snapshot’s bytes (via list/restore), not its original location.

Source

fn list<'life0, 'life1, 'async_trait>( &'life0 self, filter: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<TrashEntry>, TrashError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List trashed items, optionally filtered by name substring.

Source

fn find_by_name<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<TrashEntry>, TrashError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Find entries matching a name (exact first, then substring).

Returns matched entries or an error describing the ambiguity.

Source

fn restore<'life0, 'async_trait>( &'life0 self, entries: Vec<TrashEntry>, ) -> Pin<Box<dyn Future<Output = Result<(), TrashError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Restore trashed items to their original locations.

Source

fn purge_all<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize, TrashError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Permanently delete all trashed items. Returns count purged.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§