Struct zng_ext_config::CONFIG
source · pub struct CONFIG;
Expand description
Represents the app main config.
Config sources must be loaded using CONFIG.load
, otherwise the config only lives for the
duration of the app instance.
Implementations§
source§impl CONFIG
impl CONFIG
sourcepub fn load(&self, source: impl AnyConfig)
pub fn load(&self, source: impl AnyConfig)
Replace the config source.
Variables and bindings survive source replacement, updating to the new value or setting the new source if the key is not present in the new source.
sourcepub fn status(&self) -> BoxedVar<ConfigStatus>
pub fn status(&self) -> BoxedVar<ConfigStatus>
Gets a read-only variable that represents the IO status of the config.
sourcepub fn get<T: ConfigValue>(
&self,
key: impl Into<ConfigKey>,
default: T,
) -> BoxedVar<T>
pub fn get<T: ConfigValue>( &self, key: impl Into<ConfigKey>, default: 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
value is used 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.
Trait Implementations§
source§impl AnyConfig for CONFIG
impl AnyConfig for CONFIG
source§fn get_raw(
&mut self,
key: ConfigKey,
default: RawConfigValue,
insert: bool,
shared: bool,
) -> BoxedVar<RawConfigValue>
fn get_raw( &mut self, key: ConfigKey, default: RawConfigValue, insert: bool, shared: bool, ) -> BoxedVar<RawConfigValue>
key
. Read moresource§fn contains_key(&mut self, key: ConfigKey) -> BoxedVar<bool>
fn contains_key(&mut self, key: ConfigKey) -> BoxedVar<bool>
key
is in the backing storage.source§fn status(&self) -> BoxedVar<ConfigStatus>
fn status(&self) -> BoxedVar<ConfigStatus>
source§fn remove(&mut self, key: &ConfigKey) -> bool
fn remove(&mut self, key: &ConfigKey) -> bool
key
from the backing storage. Read moresource§fn low_memory(&mut self)
fn low_memory(&mut self)
Auto Trait Implementations§
impl Freeze for CONFIG
impl RefUnwindSafe for CONFIG
impl Send for CONFIG
impl Sync for CONFIG
impl Unpin for CONFIG
impl UnwindSafe for CONFIG
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more