#object-storage #amazon-s3 #storage-service #acme #async-client #cages #evervault

storage-client-interface

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

3 releases (breaking)

0.3.0 Oct 7, 2024
0.2.0 Aug 31, 2023
0.1.0 Aug 30, 2023

#398 in Development tools

Download history 421/week @ 2024-11-29 245/week @ 2024-12-06 198/week @ 2024-12-13 7/week @ 2024-12-20 61/week @ 2024-12-27 235/week @ 2025-01-03 217/week @ 2025-01-10 351/week @ 2025-01-17 512/week @ 2025-01-24 298/week @ 2025-01-31 529/week @ 2025-02-07 301/week @ 2025-02-14 441/week @ 2025-02-21 490/week @ 2025-02-28 234/week @ 2025-03-07 226/week @ 2025-03-14

1,478 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.2–11MB
~101K SLoC