pub struct Config { /* private fields */ }
Expand description
Configuration value storage.
Implementations§
Source§impl Config
impl Config
Sourcepub fn get<'de, S, T>(&self, path: &[S]) -> Result<Option<T>, Error>
pub fn get<'de, S, T>(&self, path: &[S]) -> Result<Option<T>, Error>
Get the current value of a config option.
This will return Ok(None)
if the requested option does not exist, and
an error if it does not match the requested type. This will never error
if T
is toml::Value
.
§Example
use configory::Manager;
let manager = Manager::new("configory", ()).unwrap();
manager.set(&["option"], 3);
let existing_value = manager.get::<_, i32>(&["option"]);
let missing_value = manager.get::<_, i32>(&["missing"]);
assert_eq!(existing_value, Ok(Some(3)));
assert_eq!(missing_value, Ok(None));
Sourcepub fn set<S, V>(&self, path: &[S], value: V)
pub fn set<S, V>(&self, path: &[S], value: V)
Set a runtime override for a config option.
See Self::reset
for clearing runtime overrides.
§Example
use configory::Manager;
let manager = Manager::new("configory", ()).unwrap();
manager.set(&["option"], 3);
Sourcepub fn reset<S>(&self, path: &[S])
pub fn reset<S>(&self, path: &[S])
Clear the runtime override for a config option.
See Self::set
for setting runtime overrides.
§Example
use configory::Manager;
let manager = Manager::new("configory", ()).unwrap();
assert_eq!(manager.get::<_, i32>(&["option"]), Ok(Some(3)));
manager.reset(&["option"]);
assert_eq!(manager.get::<_, i32>(&["option"]), Ok(None));
Trait Implementations§
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
Mutably borrows from an owned value. Read more