Skip to main content

StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend: Send + Sync {
Show 14 methods // 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 archive_move<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, src_remote_path: &'life1 str, archive_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 archive_move_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, src_root: &'life1 str, archive_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 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 archive_move<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, src_remote_path: &'life1 str, archive_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,

Move a file to an archive path (soft delete).

Semantics: src_remote_path is moved to archive_remote_path atomically. Used by cold-storage backends (B2) to preserve deleted file revisions instead of hard-deleting them. The caller constructs the archive path (typically {archive_root}/{ISO8601_ts}/{relative_path}).

Default implementation returns Err — backends that don’t support archive-on-delete should leave this unimplemented; callers must check before invoking.

Source

fn archive_move_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, src_root: &'life1 str, archive_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,

Batch archive-move: relocate multiple files from src_root to archive_dest_root preserving relative paths.

Semantics: for each relative_path, moves {src_root}/{relative_path}{archive_dest_root}/{relative_path}.

Default implementation falls back to sequential archive_move().

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§