pub struct StorageConfig {
pub default: String,
pub disks: HashMap<String, DiskConfig>,
}Expand description
Configuration for the storage system.
Fields§
§default: StringDefault disk name.
disks: HashMap<String, DiskConfig>Disk configurations.
Implementations§
Source§impl StorageConfig
impl StorageConfig
Sourcepub fn new(default: impl Into<String>) -> Self
pub fn new(default: impl Into<String>) -> Self
Create a new storage config with a default disk.
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Create configuration from environment variables.
Reads the following environment variables:
FILESYSTEM_DISK: Default disk name (default: “local”)FILESYSTEM_LOCAL_ROOT: Root path for local disk (default: “./storage”)FILESYSTEM_LOCAL_URL: Public URL for local filesFILESYSTEM_PUBLIC_ROOT: Root path for public disk (default: “./storage/public”)FILESYSTEM_PUBLIC_URL: Public URL for public files (default: “/storage”)
With s3 feature:
AWS_ACCESS_KEY_ID: S3 access keyAWS_SECRET_ACCESS_KEY: S3 secret keyAWS_DEFAULT_REGION: S3 region (default: “us-east-1”)AWS_BUCKET: S3 bucket nameAWS_URL: S3 URL base
§Example
ⓘ
use ferro_storage::{StorageConfig, Storage};
let config = StorageConfig::from_env();
let storage = Storage::with_storage_config(config);Sourcepub fn disk(self, name: impl Into<String>, config: DiskConfig) -> Self
pub fn disk(self, name: impl Into<String>, config: DiskConfig) -> Self
Add a disk configuration.
Sourcepub fn default_disk(self, name: impl Into<String>) -> Self
pub fn default_disk(self, name: impl Into<String>) -> Self
Set the default disk.
Sourcepub fn get_default(&self) -> &str
pub fn get_default(&self) -> &str
Get the default disk name.
Sourcepub fn get_disk(&self, name: &str) -> Option<&DiskConfig>
pub fn get_disk(&self, name: &str) -> Option<&DiskConfig>
Get a disk configuration by name.
Trait Implementations§
Source§impl Clone for StorageConfig
impl Clone for StorageConfig
Source§fn clone(&self) -> StorageConfig
fn clone(&self) -> StorageConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StorageConfig
impl Debug for StorageConfig
Auto Trait Implementations§
impl Freeze for StorageConfig
impl RefUnwindSafe for StorageConfig
impl Send for StorageConfig
impl Sync for StorageConfig
impl Unpin for StorageConfig
impl UnsafeUnpin for StorageConfig
impl UnwindSafe for StorageConfig
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