Skip to main content

StaticStorage

Trait StaticStorage 

Source
pub trait StaticStorage: Send + Sync {
    // Required methods
    fn put(&self, rel_path: &str, bytes: &[u8]) -> Result<(), StaticError>;
    fn exists(&self, rel_path: &str) -> Result<bool, StaticError>;
}
Expand description

A swappable destination for collected static assets, the static-files storage backend. collectstatic writes every file through a StaticStorage rather than calling std::fs directly, so the same collect path targets the local filesystem (LocalStorage, the default) or a remote object store (the feature-gated S3 backend in umbral-storage) without the collect engine knowing which.

rel_path is always the logical path RELATIVE to static_root ("admin/admin.css", "css/app.css"), forward-slash separated. The backend maps it onto its own addressing (a filesystem join, an S3 object key) — the engine never constructs an absolute on-disk path.

Required Methods§

Source

fn put(&self, rel_path: &str, bytes: &[u8]) -> Result<(), StaticError>

Write bytes at the logical rel_path, creating any intermediate structure (directories, key prefixes) the backend needs. Overwrites an existing object so re-running collectstatic is idempotent.

Source

fn exists(&self, rel_path: &str) -> Result<bool, StaticError>

Whether an object already exists at rel_path.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§