pub struct Storage<B: StorageBackend> { /* private fields */ }Expand description
High-level storage interface with additional features
Implementations§
Source§impl<B: StorageBackend> Storage<B>
impl<B: StorageBackend> Storage<B>
Sourcepub fn with_config(backend: B, config: StorageConfig) -> Self
pub fn with_config(backend: B, config: StorageConfig) -> Self
Create a storage instance with custom configuration
Sourcepub async fn put(
&self,
path: &str,
data: &[u8],
options: Option<UploadOptions>,
) -> StorageResult<FileMetadata>
pub async fn put( &self, path: &str, data: &[u8], options: Option<UploadOptions>, ) -> StorageResult<FileMetadata>
Store a file with validation
Sourcepub async fn put_stream<S>(
&self,
path: &str,
stream: S,
options: Option<UploadOptions>,
) -> StorageResult<FileMetadata>
pub async fn put_stream<S>( &self, path: &str, stream: S, options: Option<UploadOptions>, ) -> StorageResult<FileMetadata>
Store a file from a stream with validation
Sourcepub async fn get_stream(
&self,
path: &str,
) -> StorageResult<Option<Box<dyn Stream<Item = Result<Bytes, Error>> + Send + Unpin>>>
pub async fn get_stream( &self, path: &str, ) -> StorageResult<Option<Box<dyn Stream<Item = Result<Bytes, Error>> + Send + Unpin>>>
Get a file as a stream
Sourcepub async fn exists(&self, path: &str) -> StorageResult<bool>
pub async fn exists(&self, path: &str) -> StorageResult<bool>
Check if file exists
Sourcepub async fn metadata(&self, path: &str) -> StorageResult<Option<FileMetadata>>
pub async fn metadata(&self, path: &str) -> StorageResult<Option<FileMetadata>>
Get file metadata
Sourcepub async fn delete(&self, path: &str) -> StorageResult<bool>
pub async fn delete(&self, path: &str) -> StorageResult<bool>
Delete a file
Sourcepub async fn list(
&self,
prefix: Option<&str>,
limit: Option<u32>,
) -> StorageResult<Vec<FileMetadata>>
pub async fn list( &self, prefix: Option<&str>, limit: Option<u32>, ) -> StorageResult<Vec<FileMetadata>>
List files
Sourcepub async fn copy(
&self,
from: &str,
to: &str,
options: Option<UploadOptions>,
) -> StorageResult<FileMetadata>
pub async fn copy( &self, from: &str, to: &str, options: Option<UploadOptions>, ) -> StorageResult<FileMetadata>
Copy a file
Sourcepub async fn move_file(
&self,
from: &str,
to: &str,
options: Option<UploadOptions>,
) -> StorageResult<FileMetadata>
pub async fn move_file( &self, from: &str, to: &str, options: Option<UploadOptions>, ) -> StorageResult<FileMetadata>
Move a file
Sourcepub async fn signed_url(
&self,
path: &str,
expires_in: Duration,
) -> StorageResult<String>
pub async fn signed_url( &self, path: &str, expires_in: Duration, ) -> StorageResult<String>
Generate signed URL
Sourcepub async fn public_url(&self, path: &str) -> StorageResult<String>
pub async fn public_url(&self, path: &str) -> StorageResult<String>
Generate public URL
Sourcepub async fn stats(&self) -> StorageResult<StorageStats>
pub async fn stats(&self) -> StorageResult<StorageStats>
Get storage statistics
Sourcepub async fn delete_many(&self, paths: &[&str]) -> StorageResult<Vec<String>>
pub async fn delete_many(&self, paths: &[&str]) -> StorageResult<Vec<String>>
Delete multiple files
Auto Trait Implementations§
impl<B> Freeze for Storage<B>where
B: Freeze,
impl<B> RefUnwindSafe for Storage<B>where
B: RefUnwindSafe,
impl<B> Send for Storage<B>
impl<B> Sync for Storage<B>
impl<B> Unpin for Storage<B>where
B: Unpin,
impl<B> UnwindSafe for Storage<B>where
B: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more