pub struct ConfigValue { /* private fields */ }Expand description
A parsed configuration value.
Use Config::get or Config::select for path-aware fallible lookups with detailed error messages. The indexing API on this type is intentionally panicking and is meant only as a convenience shorthand.
Implementations§
Source§impl ConfigValue
impl ConfigValue
Sourcepub fn to_toml_fragment(&self) -> String
pub fn to_toml_fragment(&self) -> String
Render this value as a TOML fragment.
Sourcepub fn as_datetime(&self) -> Option<&Datetime>
pub fn as_datetime(&self) -> Option<&Datetime>
Return the value as a TOML datetime if possible.
Sourcepub fn as_duration(&self) -> Option<Duration>
pub fn as_duration(&self) -> Option<Duration>
Return the value as a duration if possible.
Sourcepub fn as_array(&self) -> Option<&[ConfigValue]>
pub fn as_array(&self) -> Option<&[ConfigValue]>
Return the value as an array slice if possible.
This is useful when callers need to discover which array indices are present instead of probing individual indices with Index.
use kompact::config::parse_config_str;
let conf = parse_config_str("values = [1, 2, 3]").expect("config");
let values = conf["values"].as_array().expect("array");
assert_eq!(3, values.len());
assert_eq!(Some(2), values[1].as_i64());Trait Implementations§
Source§impl Clone for ConfigValue
impl Clone for ConfigValue
Source§fn clone(&self) -> ConfigValue
fn clone(&self) -> ConfigValue
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConfigValue
impl Debug for ConfigValue
Source§impl Index<&str> for ConfigValue
impl Index<&str> for ConfigValue
Source§impl Index<usize> for ConfigValue
impl Index<usize> for ConfigValue
Source§impl PartialEq for ConfigValue
impl PartialEq for ConfigValue
Source§fn eq(&self, other: &ConfigValue) -> bool
fn eq(&self, other: &ConfigValue) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ConfigValue
Auto Trait Implementations§
impl Freeze for ConfigValue
impl RefUnwindSafe for ConfigValue
impl Send for ConfigValue
impl Sync for ConfigValue
impl Unpin for ConfigValue
impl UnsafeUnpin for ConfigValue
impl UnwindSafe for ConfigValue
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