zng_ext_config

Trait AnyConfig

source
pub trait AnyConfig: Send + Any {
    // Required methods
    fn status(&self) -> BoxedVar<ConfigStatus>;
    fn get_raw(
        &mut self,
        key: ConfigKey,
        default: RawConfigValue,
        insert: bool,
        shared: bool,
    ) -> BoxedVar<RawConfigValue>;
    fn contains_key(&mut self, key: ConfigKey) -> BoxedVar<bool>;
    fn remove(&mut self, key: &ConfigKey) -> bool;
    fn low_memory(&mut self);
}
Expand description

Represents one or more config sources behind a dynamic reference.

See Config for the full trait.

Required Methods§

source

fn status(&self) -> BoxedVar<ConfigStatus>

Gets a read-only variable that represents the IO status of the config.

source

fn get_raw( &mut self, key: ConfigKey, default: RawConfigValue, insert: bool, shared: bool, ) -> BoxedVar<RawConfigValue>

Gets a weak typed variable to the config key.

This method is used when T cannot be passed because the config is behind a dynamic reference, the backend must convert the value from the in memory representation to RawConfigValue.

If shared is true and the key was already requested the same var is returned, if false a new variable is always generated. Note that if you have two different variables for the same key they will go out-of-sync as updates from setting one variable do not propagate to the other.

The default value is used if the key is not found in the config, the default value is only inserted in the config if insert, otherwise the key is inserted or replaced only when the returned variable changes.

source

fn contains_key(&mut self, key: ConfigKey) -> BoxedVar<bool>

Gets a read-only variable that tracks if an entry for the key is in the backing storage.

source

fn remove(&mut self, key: &ConfigKey) -> bool

Removes the key from the backing storage.

Any active config variable for the key will continue to work normally, retaining the last config value and re-inserting the key if assigned a new value.

Returns true if the key was found and will be removed in the next app update. Returns false if the key was not found or the config is read-only.

source

fn low_memory(&mut self)

Cleanup and flush RAM caches.

Implementations§

source§

impl dyn AnyConfig

source

pub fn get_raw_serde_bidi<T: ConfigValue>( &mut self, key: impl Into<ConfigKey>, default: T, insert: bool, shared: bool, ) -> BoxedVar<T>

Get raw config and setup a bidi binding that converts to and from T.

See get_raw for more details about the inputs.

Implementors§