1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Malleable tree structure.
//!
//! ```
//! let tree = configuration::format::TOML::parse(r#"
//!     message = "one"
//!
//!     [foo.bar]
//!     message = "two"
//!
//!     [foo.baz]
//!     answer = 42
//! "#).unwrap();
//!
//! assert_eq!(tree.get::<String>("message").unwrap(), "one");
//! assert_eq!(tree.get::<String>("foo.message").unwrap(), "one");
//! assert_eq!(tree.get::<String>("foo.bar.message").unwrap(), "two");
//! assert_eq!(tree.get::<String>("foo.baz.message").unwrap(), "one");
//!
//! let tree = tree.branch("foo.baz").unwrap();
//!
//! assert_eq!(tree.get::<i64>("answer").unwrap(), &42);
//! ```

extern crate options;

#[cfg(feature = "toml")]
extern crate toml;

macro_rules! ok(
    ($result:expr) => (match $result {
        Ok(result) => result,
        Err(error) => raise!(error),
    });
);

macro_rules! raise(
    ($message:expr) => (return Err(::Error($message.to_string())));
    ($($argument:tt)*) => (return Err(::Error(format!($($argument)*))));
);

pub mod format;

mod node;
mod result;
mod tree;

pub use node::Node;
pub use result::{Error, Result};
pub use tree::Tree;