Skip to main content

Crate larust_storage

Crate larust_storage 

Source
Expand description

Laravel’s Storage::disk('local')/Storage::disk('public'). local()/public() are - deliberately, still - plain, zero-config, compile-time-checked functions, not a stringly-typed disk(name) lookup with a runtime-failable name: there’s nothing to look up for the two disks every app already has.

public()’s root is public/ itself - this framework’s existing static-file docroot (larust_core::Application::serve()’s ServeDir::new("public")) - so a file written to public/uploads/x.png is already reachable at /uploads/x.png with no symlink machinery, unlike Laravel’s own storage/app/public ↔ public/storage symlink convention.

FilesystemConfig is the additive answer to “a third, named disk” - an app that genuinely needs a disk name to come from configuration (or just wants more than two disks) declares its own config/filesystems.rs (Laravel’s own config/filesystems.php, real Rust instead), the same HashMap-of-named-configs shape larust_orm::DatabaseConnections already established for exactly this “explicit, app-owned, fails loudly on an unknown name” pattern - not a second, competing design invented just for this. local()/public() stay entirely untouched.

Structs§

Disk
DiskConfig
One named disk’s declaration inside a FilesystemConfig - a root path and, for a publicly-served disk, the URL prefix files under it are reachable at. Built with DiskConfig::private/DiskConfig::public rather than a struct literal, mirroring local()/public()’s own private-vs-served distinction (url_prefix: None vs Some(..)) so a config-declared disk can’t accidentally end up in a state neither of the two built-in disks can.
FilesystemConfig
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().

Functions§

local
Root: storage/app/ (Laravel’s own convention) - private, never served. url() always returns None on the disk this returns.
local_at
Returns the private disk rooted below an explicit application root.
public
Root: public/ - this framework’s existing static-file docroot. url() returns a /-prefixed, directly request-usable path.
public_at
Returns the public disk rooted below an explicit application root. Use this with Application::paths() when a binary is launched from a directory other than its project root.