Skip to main content

StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend:
    Send
    + Sync
    + 'static {
    // Required methods
    fn file_meta<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<FileMeta>, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn read_stream<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        range: RangeSpec,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Read + Send>, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn write_stream<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        mode: WriteMode,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn UploadSink>, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_dir<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<DirEntry>, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn mkdir_all<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn remove<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn write_stream_session<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
        _session: &'life2 str,
        mode: WriteMode,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn UploadSink>, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn cleanup_stale_sessions<'life0, 'async_trait>(
        &'life0 self,
        max_age: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<usize, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Pluggable storage backend for libfw-server.

Required Methods§

Source

fn file_meta<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<FileMeta>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Return metadata for path, or None when it does not exist.

Source

fn read_stream<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, range: RangeSpec, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Read + Send>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Open a read stream for path restricted to range.

The returned reader yields exactly range.len() bytes on success.

Source

fn write_stream<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, mode: WriteMode, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn UploadSink>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Open a write stream for path according to mode.

Source

fn list_dir<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<DirEntry>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List the children of directory path (or the mount root when path is empty).

Source

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

Recursively create path (and parents) as a directory.

Source

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

Remove path (file, or directory recursively).

Provided Methods§

Source

fn write_stream_session<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 str, _session: &'life2 str, mode: WriteMode, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn UploadSink>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Open a positional write stream for a concurrent “session” upload.

All chunk requests for one file share the same session id and write into a single shared temp file at absolute offsets via UploadSink::write_at; only the final (commit) request renames it into place. The first request (which creates the temp) uses mode for the Create/Overwrite/Resume semantics; later requests ignore it.

Source

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

Remove stale in-progress “session” upload temps (tus Expiration).

A client that vanishes mid-upload leaves its shared session temp (and any range sidecar) behind; this sweeps the ones whose last write is older than max_age, returning how many were removed. Backends that do not maintain long-lived session temps return Ok(0) (the default); the bundled filesystem backend removes .libfw-sess-* temps and their .blocks sidecars.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§