Skip to main content

StorageService

Trait StorageService 

Source
pub trait StorageService: Send + Sync {
Show 21 methods // Required methods fn upload_bytes<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, data: Bytes, options: Option<UploadOptions>, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageFile>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn upload_reader<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, reader: Box<dyn AsyncRead + Send + Unpin>, size: Option<u64>, options: Option<UploadOptions>, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageFile>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn upload_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 str, local_path: &'life2 str, options: Option<UploadOptions>, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageFile>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn download_bytes<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, options: Option<DownloadOptions>, ) -> Pin<Box<dyn Future<Output = StorageResult<Bytes>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn download_writer<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, writer: Box<dyn AsyncWrite + Send + Unpin>, options: Option<DownloadOptions>, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn download_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 str, local_path: &'life2 str, options: Option<DownloadOptions>, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn stream_file<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, range: Option<ByteRange>, ) -> Pin<Box<dyn Future<Output = StorageResult<Box<dyn Stream<Item = StorageResult<Bytes>> + Send + Unpin>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_file<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageFile>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn file_exists<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn delete_file<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn copy_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, from_path: &'life1 str, to_path: &'life2 str, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageFile>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn move_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, from_path: &'life1 str, to_path: &'life2 str, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageFile>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn list_files<'life0, 'life1, 'async_trait>( &'life0 self, prefix: &'life1 str, limit: Option<u32>, continuation_token: Option<String>, ) -> Pin<Box<dyn Future<Output = StorageResult<FileListResult>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn generate_presigned_url<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, options: PresignedUrlOptions, ) -> Pin<Box<dyn Future<Output = StorageResult<String>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_file_url<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, expiry_seconds: Option<u64>, ) -> Pin<Box<dyn Future<Output = StorageResult<String>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn update_metadata<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, metadata: HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageFile>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageStats>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn test_connection<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn backend_type(&self) -> StorageBackend; fn bucket(&self) -> &str; fn config(&self) -> &StorageConfig;
}
Expand description

Generic storage service trait

Required Methods§

Source

fn upload_bytes<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, data: Bytes, options: Option<UploadOptions>, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageFile>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Upload a file from bytes

Source

fn upload_reader<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, reader: Box<dyn AsyncRead + Send + Unpin>, size: Option<u64>, options: Option<UploadOptions>, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageFile>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Upload a file from a reader

Source

fn upload_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 str, local_path: &'life2 str, options: Option<UploadOptions>, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageFile>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Upload a file from local path

Source

fn download_bytes<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, options: Option<DownloadOptions>, ) -> Pin<Box<dyn Future<Output = StorageResult<Bytes>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Download a file to bytes

Source

fn download_writer<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, writer: Box<dyn AsyncWrite + Send + Unpin>, options: Option<DownloadOptions>, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Download a file to a writer

Source

fn download_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 str, local_path: &'life2 str, options: Option<DownloadOptions>, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Download a file to local path

Source

fn stream_file<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, range: Option<ByteRange>, ) -> Pin<Box<dyn Future<Output = StorageResult<Box<dyn Stream<Item = StorageResult<Bytes>> + Send + Unpin>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Stream a file (useful for large files)

Source

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

Get file metadata

Source

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

Check if file exists

Source

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

Delete a file

Source

fn copy_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, from_path: &'life1 str, to_path: &'life2 str, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageFile>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Copy a file

Source

fn move_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, from_path: &'life1 str, to_path: &'life2 str, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageFile>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Move a file

Source

fn list_files<'life0, 'life1, 'async_trait>( &'life0 self, prefix: &'life1 str, limit: Option<u32>, continuation_token: Option<String>, ) -> Pin<Box<dyn Future<Output = StorageResult<FileListResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List files in a directory/prefix

Source

fn generate_presigned_url<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, options: PresignedUrlOptions, ) -> Pin<Box<dyn Future<Output = StorageResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Generate presigned URL for file operations

Source

fn get_file_url<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, expiry_seconds: Option<u64>, ) -> Pin<Box<dyn Future<Output = StorageResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get file URL (public access or presigned)

Source

fn update_metadata<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, metadata: HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageFile>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update file metadata

Source

fn get_stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<StorageStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get storage statistics

Source

fn test_connection<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Test storage connection

Source

fn backend_type(&self) -> StorageBackend

Get storage backend type

Source

fn bucket(&self) -> &str

Get bucket/container name

Source

fn config(&self) -> &StorageConfig

Get configuration

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§