pub trait ConfigProvider: Send + Sync {
// Required method
fn load_raw(&self, path: &[&str]) -> Result<Option<String>, ConfigError>;
// Provided methods
fn seq_delim(&self) -> &'static str { ... }
fn within(self, prefix: impl Into<String>) -> ScopedConfigProvider<Self>
where Self: Sized { ... }
fn or_else<B: ConfigProvider + Clone>(
self,
fallback: B,
) -> OrElseConfigProvider<Self, B>
where Self: Sized + Clone { ... }
}Expand description
Abstract configuration source (Effect ConfigProvider).
Required Methods§
Sourcefn load_raw(&self, path: &[&str]) -> Result<Option<String>, ConfigError>
fn load_raw(&self, path: &[&str]) -> Result<Option<String>, ConfigError>
Look up a scalar; segments are joined with ProviderOptions::path_delim (or provider-specific rules).
Provided Methods§
Sourcefn seq_delim(&self) -> &'static str
fn seq_delim(&self) -> &'static str
Delimiter used by crate::read_string_list (Effect seqDelim).
Sourcefn within(self, prefix: impl Into<String>) -> ScopedConfigProvider<Self>where
Self: Sized,
fn within(self, prefix: impl Into<String>) -> ScopedConfigProvider<Self>where
Self: Sized,
Scope this provider under prefix, prepending those segments to every lookup
(Effect ConfigProvider.within).
use effect_config::{ConfigProvider, MapConfigProvider};
let base = MapConfigProvider::from_pairs([("SERVER_HOST", "localhost")]);
let scoped = base.within("SERVER");
let host = scoped.load_raw(&["HOST"]).unwrap();
assert_eq!(host, Some("localhost".to_string()));Sourcefn or_else<B: ConfigProvider + Clone>(
self,
fallback: B,
) -> OrElseConfigProvider<Self, B>
fn or_else<B: ConfigProvider + Clone>( self, fallback: B, ) -> OrElseConfigProvider<Self, B>
Try self first; fall back to fallback on missing keys (Effect ConfigProvider.orElse).
This is the provider-level fallback. For a descriptor-level fallback see
Config::with_default.