pub struct Storage { /* private fields */ }Expand description
Storage facade for file operations.
Implementations§
Source§impl Storage
impl Storage
Sourcepub fn with_config(default_disk: &str, configs: Vec<(&str, DiskConfig)>) -> Self
pub fn with_config(default_disk: &str, configs: Vec<(&str, DiskConfig)>) -> Self
Create storage with custom configuration.
Sourcepub fn with_storage_config(config: StorageConfig) -> Self
pub fn with_storage_config(config: StorageConfig) -> Self
Create storage from a StorageConfig (typically loaded from environment).
§Example
ⓘ
use ferro_storage::{Storage, StorageConfig};
// Load configuration from environment variables
let config = StorageConfig::from_env();
let storage = Storage::with_storage_config(config);
// Or use the builder pattern
let config = StorageConfig::new("local")
.disk("local", DiskConfig::local("./storage"))
.disk("public", DiskConfig::local("./public").with_url("/storage"));
let storage = Storage::with_storage_config(config);Sourcepub fn default_disk(&self) -> Result<Disk, Error>
pub fn default_disk(&self) -> Result<Disk, Error>
Get the default disk.
Sourcepub fn register_disk(
&self,
name: impl Into<String>,
driver: Arc<dyn StorageDriver>,
)
pub fn register_disk( &self, name: impl Into<String>, driver: Arc<dyn StorageDriver>, )
Register a disk.
Sourcepub async fn put(
&self,
path: &str,
contents: impl Into<Bytes>,
) -> Result<(), Error>
pub async fn put( &self, path: &str, contents: impl Into<Bytes>, ) -> Result<(), Error>
Put file contents.
Sourcepub async fn put_with_options(
&self,
path: &str,
contents: impl Into<Bytes>,
options: PutOptions,
) -> Result<(), Error>
pub async fn put_with_options( &self, path: &str, contents: impl Into<Bytes>, options: PutOptions, ) -> Result<(), Error>
Put with options.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Storage
impl !RefUnwindSafe for Storage
impl Send for Storage
impl Sync for Storage
impl Unpin for Storage
impl UnsafeUnpin for Storage
impl !UnwindSafe for Storage
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