pub struct Store { /* private fields */ }fs only.Expand description
Where uploads are kept. Send + Sync; create one per process or per
route and share it by reference.
§Examples
use form_net::{SpillMode, Store};
// Files over 64 KiB spill to anonymous temporary files.
let store = Store::temp()?;
assert!(store.dir().is_some());
// Never touch the file system.
let memory = Store::memory_only().memory_threshold(1 << 20);
assert!(memory.dir().is_none());Implementations§
Source§impl Store
impl Store
Sourcepub fn temp() -> Result<Store, FormError>
pub fn temp() -> Result<Store, FormError>
A store with its own private directory under the system temporary
directory, created now: form-net-<32 hex>, owner-only on Unix,
failing if the path exists. Files up to 64 KiB stay in memory;
larger ones spill to anonymous temporary files.
§Errors
Io { kind } when the directory cannot be created; Random when the
OS random source fails (no predictable fallback name).
Sourcepub fn memory_only() -> Store
pub fn memory_only() -> Store
A store that never touches the file system: a file larger than
max_file_bytes is refused, never spilled.
Sourcepub fn memory_threshold(self, bytes: u64) -> Store
pub fn memory_threshold(self, bytes: u64) -> Store
Keeps each file in memory up to bytes; a file whose next write would
pass it spills first. 0 spills every file at its first byte.
Sourcepub fn max_disk_bytes(self, bytes: u64) -> Store
pub fn max_disk_bytes(self, bytes: u64) -> Store
Caps the bytes one request may put on disk (Limit { Disk } beyond).
Unset, the cap is the request’s max_body_bytes.
Sourcepub fn cleanup_failures(&self) -> u64
pub fn cleanup_failures(&self) -> u64
Deletions that failed during a drop (they cannot be returned).
Sourcepub fn stats(&self) -> StoreStats
pub fn stats(&self) -> StoreStats
What the store holds now.