Skip to main content

oxigdal_cloud/backends/
mod.rs

1//! Cloud storage backend implementations
2//!
3//! This module provides various cloud storage backends including S3, Azure Blob Storage,
4//! Google Cloud Storage, and HTTP.
5
6#[cfg(feature = "s3")]
7pub mod s3;
8
9#[cfg(feature = "azure-blob")]
10pub mod azure;
11
12#[cfg(feature = "gcs")]
13pub mod gcs;
14
15#[cfg(feature = "http")]
16pub mod http;
17
18#[cfg(feature = "s3")]
19pub use s3::S3Backend;
20
21#[cfg(feature = "azure-blob")]
22pub use azure::AzureBlobBackend;
23
24#[cfg(feature = "gcs")]
25pub use gcs::GcsBackend;
26
27#[cfg(feature = "http")]
28pub use http::HttpBackend;
29
30use crate::error::Result;
31
32/// Common trait for cloud storage backends
33#[cfg(feature = "async")]
34#[async_trait::async_trait]
35pub trait CloudStorageBackend: Send + Sync {
36    /// Gets an object from storage
37    async fn get(&self, key: &str) -> Result<bytes::Bytes>;
38
39    /// Puts an object to storage
40    async fn put(&self, key: &str, data: &[u8]) -> Result<()>;
41
42    /// Deletes an object from storage
43    async fn delete(&self, key: &str) -> Result<()>;
44
45    /// Checks if an object exists
46    async fn exists(&self, key: &str) -> Result<bool>;
47
48    /// Lists objects with a given prefix
49    async fn list_prefix(&self, prefix: &str) -> Result<Vec<String>>;
50
51    /// Returns whether this backend is read-only
52    fn is_readonly(&self) -> bool {
53        false
54    }
55}