Struct jconfig::config::Config
[−]
[src]
pub struct Config { /* fields omitted */ }
A map of the configuration entries
Methods
impl Config
[src]
fn new() -> Self
Creates a new, empty configuration
fn from_str<'a>(s: &'a str) -> Result<Self>
Load a Config
from a JSON string
fn load<P: AsRef<Path>>(path: P) -> Result<Self>
Load a Config
from a file
fn set<V: Field>(&mut self, value: V)
Set a config field to the corresponding value.
The field is determined by the type of the value being set.
fn get_raw(&self, name: &str) -> Option<RawValue>
Access the raw value of a field.
Prefer to use the typed getters instead.
fn set_raw<K: Into<Cow<'static, str>>>(&mut self, name: K, value: RawValue)
Set the raw value of a field, bypassing any typed fields.
fn remove_raw(&mut self, name: &str)
Remove a field by name
fn get<V: Field>(&self) -> Option<&V>
Get a reference to a field's value, if it exists.
fn get_mut<V: Field>(&mut self) -> Option<&mut V>
Get a mutable reference to a field's value, if it exists.
fn has<V: Field>(&self) -> bool
Returns a boolean of whether a certain field is in the config.
fn remove<V: Field>(&mut self) -> bool
Removes a field from the config, if one existed. Returns true if field has been removed.
fn iter(&self) -> ConfigItems
Returns an iterator over the fields.
fn len(&self) -> usize
Returns the number of fields in the config.
fn clear(&mut self)
Remove all fields from the config.
Trait Implementations
impl Default for Config
[src]
impl FieldRef for Config
[src]
fn get<V: Field>(&self) -> Option<&V>
View a reference to a field if it exists.
fn get_raw(&self, name: &str) -> Option<RawValue>
View a reference to the RawValue
of the field if it exists.
impl FieldMut for Config
[src]
fn set<V: Field>(&mut self, value: V)
Set a field to the given value.
fn set_raw<K>(&mut self, name: K, value: RawValue) where
K: Into<Cow<'static, str>>,
K: Into<Cow<'static, str>>,
Set a field to the given raw value.
impl<'a> Extend<FieldView<'a>> for Config
[src]
fn extend<I: IntoIterator<Item = FieldView<'a>>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
impl<'a> FromIterator<FieldView<'a>> for Config
[src]
fn from_iter<I: IntoIterator<Item = FieldView<'a>>>(iter: I) -> Config
Creates a value from an iterator. Read more