Struct miau::configuration::Configuration[][src]

pub struct Configuration { /* fields omitted */ }

Owns configuration trees built from all sources.

Allows retrieving data stored in all trees, merging them, creating lenses and converting into strongly typed structs. Configuration should only be created by builder or sources. Most functions are public to server most bizzare needs.

To read values from Configuration you need to pull ConfigurationRead in scope.

Example

use miau::configuration::{Configuration, ConfigurationRead};

let configuration = Configuration::default(); //  aka empty
let word: Option<String> = configuration.get("word");
assert_eq!(None, word);

Implementations

impl Configuration[src]

pub fn new_singular(info: ConfigurationInfo, root: ConfigurationTree) -> Self[src]

Creates new Configuration from one tree and its associated information.

pub fn new_empty() -> Self[src]

Creates new empty Configuration.

pub fn lens(&self) -> Lens<'_>[src]

Creates Lens from this Configuration.

pub fn try_convert_into<T: DeserializeOwned>(
    self
) -> Result<T, ConfigurationError>
[src]

Deserializes Configuration into strongly typed struct.

It is only required that struct to be deserialized to implements Deserialize and contains no borrowed fields, for instance &str. Due to memory model of miau it is impossible to deserialize into such fields.

pub fn merge_owned(self) -> Result<ConfigurationTree, ConfigurationError>[src]

Merges trees contained in Configuration into one tree by consuming them.

To merge cloned, invoke lens function first.

pub fn infos(&self) -> impl Iterator<Item = &ConfigurationInfo>[src]

Retrives information about configuration trees, in order used internally by Configuration.

let configuration = Configuration::default(); // normally populated configuration should be used!

for info in configuration.infos() {
     println!("{}", info);
}

Trait Implementations

impl Clone for Configuration[src]

impl<'config, T, K> ConfigurationRead<'config, T, K> for Configuration where
    T: TryFrom<&'config Value, Error = ConfigurationError>,
    K: TryInto<CompoundKey, Error = ConfigurationError>, 
[src]

impl Debug for Configuration[src]

impl Default for Configuration[src]

impl<'de> Deserialize<'de> for Configuration[src]

impl<'config> From<&'config Configuration> for Lens<'config>[src]

impl From<ConfigurationTree> for Configuration[src]

impl From<HashMap<String, String, RandomState>> for Configuration[src]

impl Provider for Configuration[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.