pub struct LibraryContext {
pub paths: LibraryPaths,
pub cache: CachePaths,
pub settings: LibraryConfig,
/* private fields */
}Expand description
One media library as an explicit, immutable value.
Clones share the pinned identity and the memo (the interior state is
behind an Arc); the path and settings structs are plain data computed
once from the canonical root and identical in every clone. There is no
connection here, no global, and no lookup against the environment: a
context is fully described by what it was constructed with.
Fields§
§paths: LibraryPathsDerived paths under the canonical root.
cache: CachePathsCache locations under the explicit cache base.
settings: LibraryConfigSettings in force for this context, loaded once from the library’s
config.toml at construction (built-in defaults when it is absent).
A snapshot: editing the file later does not mutate an existing
context, only a context built after the edit.
Implementations§
Source§impl LibraryContext
impl LibraryContext
Sourcepub fn new(root: &Path, cache_base: &Path) -> Result<Self>
pub fn new(root: &Path, cache_base: &Path) -> Result<Self>
Build a context for root, keeping derived caches under cache_base.
Creates nothing, anywhere: neither the state directory inside the root
nor any part of the cache base. Both are writers’ job, so looking at a
library never litters it. The library’s config.toml is read here
when present: settings are snapshotted into the context, an edit to
the file after construction does not mutate it, and an invalid or
corrupt file fails construction rather than silently defaulting.
Sourcepub fn ensure_root_identity(&self) -> Result<()>
pub fn ensure_root_identity(&self) -> Result<()>
Recheck that the canonical root still names the directory pinned at construction, and error if it does not.
Bounded: one bounded stat; a check that could hang on a wedged mount
is not a check. The error is built from strings in hand; the failing
path is never touched again to phrase the message, the same rule
TimedOutAfter::describe exists to enforce.
Trait Implementations§
Source§impl Clone for LibraryContext
impl Clone for LibraryContext
Source§fn clone(&self) -> LibraryContext
fn clone(&self) -> LibraryContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more