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) -> Box<dyn VarBoxed<ConfigStatus>>
pub fn status(&self) -> Box<dyn VarBoxed<ConfigStatus>>
Gets a read-only variable that represents the IO status of the config.
sourcepub fn get<T>(&self, key: impl Into<Txt>, default: T) -> Box<dyn VarBoxed<T>>where
T: ConfigValue,
pub fn get<T>(&self, key: impl Into<Txt>, default: T) -> Box<dyn VarBoxed<T>>where
T: ConfigValue,
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: Txt,
default: RawConfigValue,
insert: bool,
shared: bool,
) -> Box<dyn VarBoxed<RawConfigValue>>
fn get_raw( &mut self, key: Txt, default: RawConfigValue, insert: bool, shared: bool, ) -> Box<dyn VarBoxed<RawConfigValue>>
key
. Read moresource§fn contains_key(&mut self, key: Txt) -> Box<dyn VarBoxed<bool>>
fn contains_key(&mut self, key: Txt) -> Box<dyn VarBoxed<bool>>
key
is in the backing storage.source§fn status(&self) -> Box<dyn VarBoxed<ConfigStatus>>
fn status(&self) -> Box<dyn VarBoxed<ConfigStatus>>
source§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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for 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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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