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::<i64>().unwrap();

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

Methods

impl Pair
[src]

[src]

Creates a new Pair.

[src]

Adds a value to a Pair.

Examples:

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

[src]

Recursively adds a slice to a Pair.

[src]

Adds a Pair to a Pair.

[src]

Test if a pair has a key.

Examples:

use nccl::NcclError;
let mut p = nccl::parse_file("examples/config.nccl").unwrap();
assert!(p.has_key("server"));
assert!(p["server"]["port"].has_key(80));

[src]

Test if a pair has a path of values. Use vec_into! to make this method easier to use.

Examples:

let mut p = nccl::parse_file("examples/config.nccl").unwrap();
assert!(p.has_path(vec_into!["server", "port", 80]));

[src]

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

[src]

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();

[src]

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(32);
p.get(32).unwrap();

[src]

Returns the value of a pair as a string. let config = nccl::parse_file("examples/long.nccl").unwrap(); assert_eq!(config["bool too"].value().unwrap(), "false");

[src]

Returns the value of the key or a default value.

[src]

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!(!p["bool too"].value_as::<bool>().unwrap());

[src]

Gets the value of a key as a specified type or a default value.

[src]

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::<i64>().unwrap();
assert_eq!(ports, vec![80, 443]);

[src]

Gets keys of a value as a vector of T or returns a default vector.

[src]

Pretty-prints a Pair.

Examples:

let config = nccl::parse_file("examples/config.nccl").unwrap();
config.pretty_print();

// String("__top_level__")
//     String("server")
//         String("domain")
//             String("example.com")
//             String("www.example.com")
//         String("port")
//             Integer(80)
//             Integer(443)
//         String("root")
//             String("/var/www/html")

Trait Implementations

impl Clone for Pair
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Pair
[src]

[src]

Formats the value using the given formatter.

impl PartialEq for Pair
[src]

[src]

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

[src]

This method tests for !=.

impl<T> Index<T> for Pair where
    Value: From<T>, 
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<T> IndexMut<T> for Pair where
    Value: From<T>, 
[src]

[src]

Performs the mutable indexing (container[index]) operation.