pub struct FilesystemConfig { /* private fields */ }Expand description
A named collection of additional disks, declared by the app itself
(typically in a config/filesystems.rs it writes, the same
“add-your-own-config-file-when-you-need-it” pattern config/blog.rs-
style app-specific config already establishes) - see this module’s
own doc comment for why this exists alongside, not instead of,
local()/public().
§Example
use larust_storage::{DiskConfig, FilesystemConfig};
// config/filesystems.rs
fn config() -> FilesystemConfig {
FilesystemConfig::new()
.with_disk("exports", DiskConfig::private("storage/exports"))
.with_disk("avatars", DiskConfig::public("storage/avatars", "/avatars"))
}
let filesystems = config();
let exports = filesystems.disk("exports")?;
exports.put("2024-01.csv", b"id,total\n").await?;Implementations§
Source§impl FilesystemConfig
impl FilesystemConfig
pub fn new() -> Self
Sourcepub fn with_disk(self, name: impl Into<String>, config: DiskConfig) -> Self
pub fn with_disk(self, name: impl Into<String>, config: DiskConfig) -> Self
Declares a disk under name - with_*, not a same-named disk,
so this builder method and FilesystemConfig::disk’s own
Laravel-shaped lookup (Storage::disk('name')) can both exist
without a name collision, matching this codebase’s own existing
with_error_pages/with_graceful_shutdown/with_sessions
builder-method convention. Declaring the same name twice silently
keeps the last one - unlike CommandRegistry::register/
JobRegistry::register’s own panic-on-duplicate, a config file is
read top-to-bottom once at startup, not accumulated across
independent call sites the way those two registries are, so a
repeated name here is far more likely to be a deliberate override
(or a copy-pasted block someone forgot to rename) than the kind of
silently-shadowed registration a panic exists to catch.
Sourcepub fn disk(&self, name: &str) -> Result<Disk, AppError>
pub fn disk(&self, name: &str) -> Result<Disk, AppError>
Looks up a declared disk by name - Laravel’s own
Storage::disk('name'). Fails clearly - naming the missing key -
rather than panicking or silently falling back to some default,
the same “explicit, fails loudly on an unknown name” contract
larust_orm::DatabaseConnections’s own connection lookup already
established.