Struct encrypt_config::Config
source · pub struct Config { /* private fields */ }Expand description
A struct that can be used to store configuration values.
Example
See Source, PersistSource, SecretSource
Implementations§
source§impl Config
impl Config
sourcepub fn get<K, R>(&self, key: K) -> ConfigResult<R>
pub fn get<K, R>(&self, key: K) -> ConfigResult<R>
Get a value from the config.
Arguments
key- The key of the value to get.
R must implement serde::de::DeserializeOwned, because this crate stores seriliazed data.
sourcepub fn add_source(&mut self, source: impl Source) -> ConfigResult<()>
pub fn add_source(&mut self, source: impl Source) -> ConfigResult<()>
Add a source to the config.
The source must implement Source trait, which is for normal config that does not need to be encrypted or persisted.
sourcepub fn add_persist_source(
&mut self,
source: impl PersistSource
) -> ConfigResult<()>
Available on crate feature persist only.
pub fn add_persist_source( &mut self, source: impl PersistSource ) -> ConfigResult<()>
persist only.Add a persist source to the config.
The source must implement PersistSource trait, which is for config that needs to be persisted.
sourcepub fn add_secret_source(
&mut self,
source: impl SecretSource
) -> ConfigResult<()>
Available on crate feature secret only.
pub fn add_secret_source( &mut self, source: impl SecretSource ) -> ConfigResult<()>
secret only.Add a secret source to the config.
The source must implement SecretSource trait, which is for config that needs to be encrypted and persisted.
sourcepub fn upgrade_all<'v, K, V, KV>(&mut self, kv: KV) -> ConfigResult<()>
pub fn upgrade_all<'v, K, V, KV>(&mut self, kv: KV) -> ConfigResult<()>
Upgrade all values in the config. The keys must already exist. If not, those key-values before the first not existing one will be upgraded, and those after will be omitted.