pub struct Loader { /* private fields */ }Expand description
Service for loading configuration from sources.
The Loader is responsible for:
- Loading raw content from sources
- Detecting and parsing formats
- Converting to typed configuration
Implementations§
Source§impl Loader
impl Loader
Sourcepub fn builder() -> LoaderBuilder
pub fn builder() -> LoaderBuilder
Create a builder for constructing a Loader.
Sourcepub fn options(&self) -> &LoadOptions
pub fn options(&self) -> &LoadOptions
Get the load options.
Sourcepub fn load_as<S: Source, T: DeserializeOwned>(&self, source: &S) -> Result<T>
pub fn load_as<S: Source, T: DeserializeOwned>(&self, source: &S) -> Result<T>
Load and parse content from a source into a specific type.
§Errors
Returns an error if loading, parsing, or deserialization fails.
Sourcepub fn parse(&self, raw: &RawContent, format: Format) -> Result<ParsedContent>
pub fn parse(&self, raw: &RawContent, format: Format) -> Result<ParsedContent>
Sourcepub fn parse_raw(
&self,
raw: RawContent,
detected_format: Option<Format>,
) -> Result<ParsedContent>
pub fn parse_raw( &self, raw: RawContent, detected_format: Option<Format>, ) -> Result<ParsedContent>
Parse raw content, detecting the format.
§Errors
Returns an error if parsing fails or format cannot be detected.
Sourcepub fn merge(&self, contents: Vec<ParsedContent>) -> ParsedContent
pub fn merge(&self, contents: Vec<ParsedContent>) -> ParsedContent
Merge multiple parsed contents.
Uses the merge strategy from options.
Sourcepub fn to_type<T: DeserializeOwned>(&self, content: ParsedContent) -> Result<T>
pub fn to_type<T: DeserializeOwned>(&self, content: ParsedContent) -> Result<T>
Sourcepub fn load_multiple<S: Source>(&self, sources: &[S]) -> Result<ParsedContent>
pub fn load_multiple<S: Source>(&self, sources: &[S]) -> Result<ParsedContent>
Load from multiple sources and merge.
Sources are loaded in order and merged according to the merge strategy.
Optional sources that fail are skipped if ignore_optional_missing is true.
§Errors
Returns an error if a required source fails and fail_fast is true.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Loader
impl RefUnwindSafe for Loader
impl Send for Loader
impl Sync for Loader
impl Unpin for Loader
impl UnsafeUnpin for Loader
impl UnwindSafe for Loader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more