Skip to main content

StorageClientPlugin

Trait StorageClientPlugin 

Source
pub trait StorageClientPlugin: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn get(&self, key: &str) -> Result<Vec<u8>, StorageError>;
    fn put(
        &self,
        key: &str,
        body: Vec<u8>,
        opts: PutOpts,
    ) -> Result<(), StorageError>;
    fn delete(&self, key: &str) -> Result<(), StorageError>;
    fn list_page(
        &self,
        prefix: &str,
        continuation_token: Option<&str>,
    ) -> Result<(Vec<Object>, Option<String>), StorageError>;
    fn presigned_url(
        &self,
        key: &str,
        op: PresignOp,
        ttl_secs: u64,
    ) -> Result<String, StorageError>;

    // Provided method
    fn is_healthy(&self) -> bool { ... }
}
Expand description

A plugin that owns a blob / object store.

Implementations are expected to be thread-safe and to hold any connection-pool or client state internally behind &self. All methods are synchronous — backends that need async I/O drive their own runtime (see module docs).

Concurrency: callers may invoke any method from multiple threads concurrently. put is last-write-wins unless the backend supports conditional writes (not yet exposed in this trait).

Required Methods§

Source

fn name(&self) -> &str

Unique identifier for this backend (e.g. "s3", "r2", "minio", "fs"). Used in logs, metrics, and the TUI.

Source

fn get(&self, key: &str) -> Result<Vec<u8>, StorageError>

Fetch the object at key. Returns NotFound if the key does not exist, AccessDenied if credentials are wrong or insufficient, Backend(msg) for transport failures.

Source

fn put( &self, key: &str, body: Vec<u8>, opts: PutOpts, ) -> Result<(), StorageError>

Upload body to key with the given options. Overwrites any existing object. Returns QuotaExceeded if the upload exceeds a backend quota (object size, per-bucket limit), AccessDenied for credential failures, Backend(msg) otherwise.

Source

fn delete(&self, key: &str) -> Result<(), StorageError>

Delete the object at key. Idempotent: deleting a non-existent key is Ok(()), not NotFound. Returns AccessDenied for credential failures, Backend(msg) otherwise.

Source

fn list_page( &self, prefix: &str, continuation_token: Option<&str>, ) -> Result<(Vec<Object>, Option<String>), StorageError>

List one page of objects under prefix.

Returns (objects, next_token). If next_token is Some, pass it back as continuation_token on the next call to get the next page. A None token means “no more pages”. An empty page is a valid (non-error) response; backends should not return NotFound for an empty prefix.

Page size is the backend’s native default (usually 1000 for S3 family). Callers that need smaller pages should filter client-side.

Source

fn presigned_url( &self, key: &str, op: PresignOp, ttl_secs: u64, ) -> Result<String, StorageError>

Mint a presigned URL for key valid for ttl_secs seconds.

Returns the URL as a String — kept stringly-typed so leaf crates don’t pull in url. Callers that want a parsed Url construct one themselves.

Backends that cannot mint presigned URLs (e.g. a pure-filesystem plugin) should return Backend("presigned URLs not supported") rather than panicking.

Provided Methods§

Source

fn is_healthy(&self) -> bool

Health check. Default: always healthy. Backends with a long-lived client should override to ping the service (e.g. HeadBucket for S3).

Implementors§