pub struct StrictLoader { /* private fields */ }Expand description
Strict, layered document loader.
Loads a canonical config file, optionally merging in include files,
and deserializes into a typed schema while honoring #[serde(deny_unknown_fields)].
Unlike the crate::ConfigLoader pipeline (built on the config crate’s value tree),
this path decodes through rskit_codec into the canonical Value tree
and deserializes from it, so serde’s unknown-field rejection fires
and dynamic-keyed sections can be retained verbatim as crate::strict::RawValue for downstream parsing.
The on-disk format is pluggable via Codec: TOML is the built-in default (StrictLoader::new);
any other codec (JSON, …) drops in through StrictLoader::with_codec.
Include files are treated as defaults: the canonical file’s values win over includes,
and later includes win over earlier ones.
Array-of-tables sections registered as identity-keyed (see IncludeMerge) are concatenated
and hard-error on duplicate identity.
Implementations§
Source§impl StrictLoader
impl StrictLoader
Sourcepub fn new(path: impl Into<PathBuf>) -> Self
pub fn new(path: impl Into<PathBuf>) -> Self
Create a loader for the canonical file at path, decoded as TOML.
Sourcepub fn with_include(self, path: impl Into<PathBuf>) -> Self
pub fn with_include(self, path: impl Into<PathBuf>) -> Self
Add an include file merged beneath the canonical file (a default source).
Sourcepub fn with_includes<I, P>(self, paths: I) -> Self
pub fn with_includes<I, P>(self, paths: I) -> Self
Add multiple include files, in increasing precedence order.
Sourcepub fn with_merge(self, merge: IncludeMerge) -> Self
pub fn with_merge(self, merge: IncludeMerge) -> Self
Set the identity-aware include-merge configuration.
Sourcepub fn with_codec(self, codec: Arc<dyn Codec>) -> Self
pub fn with_codec(self, codec: Arc<dyn Codec>) -> Self
Sourcepub fn load<T>(&self) -> AppResult<T>where
T: DeserializeOwned,
pub fn load<T>(&self) -> AppResult<T>where
T: DeserializeOwned,
Load, merge includes, and deserialize into T.
Honors #[serde(deny_unknown_fields)]: an unknown key is a hard error.
Sourcepub fn load_raw(&self) -> AppResult<Value>
pub fn load_raw(&self) -> AppResult<Value>
Load and merge includes into a single raw value tree (no typed schema).
Validates identity-keyed sections but performs no schema typing, so callers can inspect or hand off dynamic-keyed subtrees verbatim.
Sourcepub fn load_resolving_includes<T, F>(&self, resolve: F) -> AppResult<T>
pub fn load_resolving_includes<T, F>(&self, resolve: F) -> AppResult<T>
Load and deserialize into T, resolving include paths from the canonical document itself.
Reads the canonical file exactly once,
passes its decoded value tree to resolve to obtain the include list (for configs that declare their own includes, e.g. [toven].include = [...]),
then merges those includes beneath the canonical document.
Any statically-registered with_includes are ignored by this entry point.
Honors #[serde(deny_unknown_fields)].
Sourcepub fn load_raw_resolving_includes<F>(&self, resolve: F) -> AppResult<Value>
pub fn load_raw_resolving_includes<F>(&self, resolve: F) -> AppResult<Value>
Raw counterpart of load_resolving_includes.
Reads the canonical file once, derives the include list from it via resolve,
and merges the includes beneath the canonical document.