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.
§Provider
This service is provided by the ConfigManager extension, it will panic if used in an app not extended.
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) -> Var<ConfigStatus>
pub fn status(&self) -> Var<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,
) -> Var<T>
pub fn get<T: ConfigValue>( &self, key: impl Into<ConfigKey>, default: T, ) -> Var<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,
) -> Var<RawConfigValue>
fn get_raw( &mut self, key: ConfigKey, default: RawConfigValue, insert: bool, ) -> Var<RawConfigValue>
key. Read moreSource§fn contains_key(&mut self, key: ConfigKey) -> Var<bool>
fn contains_key(&mut self, key: ConfigKey) -> Var<bool>
key is in the backing storage.Source§fn status(&self) -> Var<ConfigStatus>
fn status(&self) -> Var<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