Struct nccl::Pair [] [src]

pub struct Pair { /* fields omitted */ }

Struct that contains configuration information.

Examples:

let p = nccl::parse_file("examples/config.nccl").unwrap();
let ports = p["server"]["port"].keys_as::<u32>().unwrap();

println!("Operating on ports:");
for port in ports.iter() {
    println!("  {}", port);
}

Methods

impl Pair
[src]

Creates a new Pair.

Adds a value to a Pair.

Examples:

let mut p = nccl::Pair::new("hello");
p.add("world");

Recursively adds a slice to a Pair.

Adds a Pair to a Pair.

Test if a pair has a key.

Examples:

let p = nccl::parse_file("examples/config.nccl").unwrap();
assert!(p.has_key("server"));

Traverses a Pair using a slice, adding the item if it does not exist.

Gets a child Pair from a Pair. Used by Pair's implementation of Index.

let mut p = nccl::Pair::new("top_level");
p.add("hello!");
p.get("hello!").unwrap();

Gets a mutable child Pair from a Pair. Used by Pair's implementation of IndexMut.

let mut p = nccl::Pair::new("top_level");
p.add("hello!");
p.get("hello!").unwrap();

Gets the value of a key if there is only one.

Examples:

let p = nccl::parse_file("examples/config.nccl").unwrap();
assert_eq!(p["server"]["root"].value().unwrap(), "/var/www/html");

Gets the value of a key as a specified type, if there is only one.

Examples:

let p = nccl::parse_file("examples/long.nccl").unwrap();
assert_eq!(p["bool too"].value_as::<bool>().unwrap(), false);

Gets keys of a value as a vector of Strings.

Examples:

let v: Vec<String> = vec!["bologne".into(), "ham".into()];
let p = nccl::parse_file("examples/inherit.nccl").unwrap();
assert_eq!(p["sandwich"]["meat"].keys(), v);

Gets keys of a value as a vector of T.

Examples:

let config = nccl::parse_file("examples/config.nccl").unwrap();
let ports = config["server"]["port"].keys_as::<i32>().unwrap();
assert_eq!(ports, vec![80, 443]);

Pretty-prints a Pair.

Trait Implementations

impl Clone for Pair
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Pair
[src]

Formats the value using the given formatter.

impl PartialEq for Pair
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<'a> Index<&'a str> for Pair
[src]

The returned type after indexing

The method for the indexing (container[index]) operation

impl<'a> IndexMut<&'a str> for Pair
[src]

The method for the mutable indexing (container[index]) operation