#object-storage #storage #storage-service #s3 #acme #evervault #cages

storage-client-interface

A Rust library for exposing the StorageClientInterface trait for interacting with a storage backend. Used by Evervault Cages.

2 unstable releases

0.2.0 Aug 31, 2023
0.1.0 Aug 30, 2023

#864 in Development tools

Download history 81/week @ 2023-12-30 106/week @ 2024-01-06 6/week @ 2024-01-13 51/week @ 2024-01-20 76/week @ 2024-02-10 36/week @ 2024-02-17 19/week @ 2024-02-24 72/week @ 2024-03-02 18/week @ 2024-03-09 2/week @ 2024-03-16 31/week @ 2024-03-23 42/week @ 2024-03-30 4/week @ 2024-04-06 2/week @ 2024-04-13

79 downloads per month

Apache-2.0

9KB
130 lines

storage-client-interface

The StorageClientInterface is a trait that defines a set of methods for interacting with object storage. It provides a clear and standardized way to perform common operations for retrieving, uploading, and deleting objects from a storage service. An S3 implementation is also provided under the feature s3 which is included under the default feature.

Trait Definition

use async_trait::async_trait;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum StorageClientError {
    #[error("GetObject Error: {0}")]
    GetObject(String),
    #[error("PutObject Error: {0}")]
    PutObject(String),
    #[error("DeleteObject Error: {0}")]
    DeleteObject(String),
    #[error("Storage Client Error - {0}")]
    General(String),
}

#[async_trait]
pub trait StorageClientInterface {
    async fn get_object(&self, key: String) -> Result<Option<String>, StorageClientError>;
    async fn put_object(&self, key: String, body: String) -> Result<(), StorageClientError>;
    async fn delete_object(&self, key: String) -> Result<(), StorageClientError>;
}

Methods

get_object

Retrieves an object from the storage service based on the provided key.

async fn get_object(&self, key: String) -> Result<Option<String>, StorageClientError>;

put_object

Uploads an object to the storage service with the given key and body.

async fn put_object(&self, key: String, body: String) -> Result<(), StorageClientError>;

delete_object

Deletes an object from the storage service using the specified key.

async fn delete_object(&self, key: String) -> Result<(), StorageClientError>;

Dependencies

~0.3–6.5MB
~111K SLoC