Skip to main content

Source

Trait Source 

Source
pub trait Source {
    // Required method
    fn collect(&self) -> Result<ConfigValue, SourceError>;

    // Provided method
    fn with_app_name(self, _name: &str) -> Self
       where Self: Sized { ... }
}
Expand description

A source that can produce a ConfigValue tree.

Required Methods§

Source

fn collect(&self) -> Result<ConfigValue, SourceError>

Collect config values from this source.

§Errors

Returns SourceError on I/O, parse, or environment variable errors.

Provided Methods§

Source

fn with_app_name(self, _name: &str) -> Self
where Self: Sized,

Inject the application name derived from crate::config::ConfigSchema::APP_NAME.

Called automatically by crate::config::ConfigLoader::with_source and [crate::config::ConfigLoader::with_watched_source] before the source is stored. The default is a no-op; override it for sources that use the app name to scope their data (e.g. RedbSource, EnvSource). The name must not override an explicit value already set on the source.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§