pub trait ConfigExt: Config {
// Provided methods
fn get_opt<T: FromConfig>(
&self,
section: &str,
name: &str,
) -> Result<Option<T>> { ... }
fn get_nonempty_opt<T: FromConfig>(
&self,
section: &str,
name: &str,
) -> Result<Option<T>> { ... }
fn get_or<T: FromConfig>(
&self,
section: &str,
name: &str,
default_func: impl Fn() -> T,
) -> Result<T> { ... }
fn get_or_default<T: Default + FromConfig>(
&self,
section: &str,
name: &str,
) -> Result<T> { ... }
fn must_get<T: FromConfig>(&self, section: &str, name: &str) -> Result<T> { ... }
}Expand description
Extra APIs (incompatible with trait objects) around reading config.
Provided Methods§
Sourcefn get_opt<T: FromConfig>(&self, section: &str, name: &str) -> Result<Option<T>>
fn get_opt<T: FromConfig>(&self, section: &str, name: &str) -> Result<Option<T>>
Get a config item. Convert to type T.
Sourcefn get_nonempty_opt<T: FromConfig>(
&self,
section: &str,
name: &str,
) -> Result<Option<T>>
fn get_nonempty_opt<T: FromConfig>( &self, section: &str, name: &str, ) -> Result<Option<T>>
Get a nonempty config item. Convert to type T.
Sourcefn get_or<T: FromConfig>(
&self,
section: &str,
name: &str,
default_func: impl Fn() -> T,
) -> Result<T>
fn get_or<T: FromConfig>( &self, section: &str, name: &str, default_func: impl Fn() -> T, ) -> Result<T>
Get a config item. Convert to type T.
If the config item is not set, calculate it using default_func.
Sourcefn get_or_default<T: Default + FromConfig>(
&self,
section: &str,
name: &str,
) -> Result<T>
fn get_or_default<T: Default + FromConfig>( &self, section: &str, name: &str, ) -> Result<T>
Get a config item. Convert to type T.
If the config item is not set, return T::default().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.