Trait zng_ext_config::Config
source · pub trait Config: AnyConfig {
// Required method
fn get<T: ConfigValue>(
&mut self,
key: impl Into<ConfigKey>,
default: impl FnOnce() -> T
) -> BoxedVar<T>;
}
Expand description
Represents one or more config sources.
Required Methods§
sourcefn get<T: ConfigValue>(
&mut self,
key: impl Into<ConfigKey>,
default: impl FnOnce() -> T
) -> BoxedVar<T>
fn get<T: ConfigValue>( &mut self, key: impl Into<ConfigKey>, default: impl FnOnce() -> T ) -> BoxedVar<T>
Gets a variable that is bound to the config key
.
The same variable is returned for multiple requests of the same key. If the loaded config is not read-only the returned variable can be set to update the config source.
The default
closure is used to generate a value if the key is not found in the config, the default value
is not inserted in the config, the key is inserted or replaced only when the returned variable updates. Note
that the default
closure may be used even if the key is already in the config, depending on the config implementation.
Object Safety§
This trait is not object safe.