Skip to main content

StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend: Send + Sync {
    // Required methods
    fn push<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        local_path: &'life1 Path,
        remote_path: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), InfraError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn pull<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        remote_path: &'life1 str,
        local_path: &'life2 Path,
    ) -> Pin<Box<dyn Future<Output = Result<(), InfraError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn list<'life0, 'life1, 'async_trait>(
        &'life0 self,
        remote_path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<RemoteFile>, InfraError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn exists<'life0, 'life1, 'async_trait>(
        &'life0 self,
        remote_path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool, InfraError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn backend_type(&self) -> &str;

    // Provided methods
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        remote_path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), InfraError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn push_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        src_root: &'life1 Path,
        dest_root: &'life2 str,
        relative_paths: &'life3 [String],
    ) -> Pin<Box<dyn Future<Output = HashMap<String, Result<(), InfraError>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn pull_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        src_root: &'life1 str,
        dest_root: &'life2 Path,
        relative_paths: &'life3 [String],
    ) -> Pin<Box<dyn Future<Output = HashMap<String, Result<(), InfraError>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn delete_batch<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        remote_root: &'life1 str,
        relative_paths: &'life2 [String],
    ) -> Pin<Box<dyn Future<Output = HashMap<String, Result<(), InfraError>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn supports_batch(&self) -> bool { ... }
    fn set_progress_callback(&self, _callback: Option<ProgressFn>) { ... }
    fn ensure<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), InfraError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Abstract file transfer backend.

Implementations handle the actual data movement for a specific protocol. The sync service routes operations to the correct backend based on location.

Required Methods§

Source

fn push<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, local_path: &'life1 Path, remote_path: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Push a local file to this remote.

Source

fn pull<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, remote_path: &'life1 str, local_path: &'life2 Path, ) -> Pin<Box<dyn Future<Output = Result<(), InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Pull a file from this remote to a local path.

Source

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

List files at a remote path.

Source

fn exists<'life0, 'life1, 'async_trait>( &'life0 self, remote_path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if a remote file exists.

Source

fn backend_type(&self) -> &str

Backend type name for display and config matching.

Provided Methods§

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, remote_path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a file on this remote.

Returns Ok(()) if the file was deleted or didn’t exist. Default implementation returns Err — backends that support deletion must override this.

Source

fn push_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, src_root: &'life1 Path, dest_root: &'life2 str, relative_paths: &'life3 [String], ) -> Pin<Box<dyn Future<Output = HashMap<String, Result<(), InfraError>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Push multiple files in a single batch operation.

src_root is the local base directory, dest_root is the remote base, and relative_paths are paths relative to both roots.

Returns a map of relative_path → Ok/Err for per-file status tracking. Default implementation falls back to sequential push() calls.

Source

fn pull_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, src_root: &'life1 str, dest_root: &'life2 Path, relative_paths: &'life3 [String], ) -> Pin<Box<dyn Future<Output = HashMap<String, Result<(), InfraError>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Pull multiple files in a single batch operation.

src_root is the remote base, dest_root is the local base directory, and relative_paths are paths relative to both roots.

Returns a map of relative_path → Ok/Err for per-file status tracking. Default implementation falls back to sequential pull() calls.

Source

fn delete_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, remote_root: &'life1 str, relative_paths: &'life2 [String], ) -> Pin<Box<dyn Future<Output = HashMap<String, Result<(), InfraError>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete multiple files in a single batch operation.

remote_root is the remote base directory, relative_paths are paths relative to it. Uses rclone delete --files-from for rclone backends.

Returns a map of relative_path → Ok/Err for per-file status tracking. Default implementation falls back to sequential delete() calls.

Source

fn supports_batch(&self) -> bool

Whether this backend supports efficient batch push/pull.

When true, callers should prefer push_batch/pull_batch/delete_batch over individual calls. Default: false (sequential fallback).

Source

fn set_progress_callback(&self, _callback: Option<ProgressFn>)

Set a progress callback for batch operations.

Called by the sync engine before batch execution. Implementations that support chunked transfers (e.g. RcloneBackend) should call this callback on chunk completion. Default: no-op (callback is ignored).

Source

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

外部ツールの到達確認 + 確保。

  • rclone: バイナリ存在確認 → なければインストール → 接続テスト
  • memory: 常にOk

デフォルト実装: list("") で接続テスト(バイナリが存在しなければここで失敗する)。

Implementors§