Skip to main content

StrictLoader

Struct StrictLoader 

Source
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

Source

pub fn new(path: impl Into<PathBuf>) -> Self

Create a loader for the canonical file at path, decoded as TOML.

Source

pub fn with_include(self, path: impl Into<PathBuf>) -> Self

Add an include file merged beneath the canonical file (a default source).

Source

pub fn with_includes<I, P>(self, paths: I) -> Self
where I: IntoIterator<Item = P>, P: Into<PathBuf>,

Add multiple include files, in increasing precedence order.

Source

pub fn with_merge(self, merge: IncludeMerge) -> Self

Set the identity-aware include-merge configuration.

Source

pub fn with_codec(self, codec: Arc<dyn Codec>) -> Self

Set the Codec used to decode the canonical file and every include.

Defaults to TomlCodec. Use this to load a strict JSON document, or any user-supplied format, without changing the loader.

Source

pub fn load<T>(&self) -> AppResult<T>

Load, merge includes, and deserialize into T.

Honors #[serde(deny_unknown_fields)]: an unknown key is a hard error.

Source

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.

Source

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)].

Source

pub fn load_raw_resolving_includes<F>(&self, resolve: F) -> AppResult<Value>
where F: FnOnce(&Value) -> AppResult<Vec<PathBuf>>,

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.

Trait Implementations§

Source§

impl Debug for StrictLoader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more