Struct nccl::config::Config[][src]

pub struct Config<'a> { /* fields omitted */ }
Expand description

A nccl configuration

Indexable with &str.

e.g.

// config.nccl:
// server
//     domain
//         example.com
//         www.example.com
//     port
//         80
//         443
//     root
//         /var/www/html

let content = std::fs::read_to_string("examples/config.nccl").unwrap();
let config = parse_config(&content).unwrap();

// get the value of a single node
assert_eq!(Some("/var/www/html"), config["server"]["root"].value());

// value always returns the value of the first child node
assert_eq!(Some("example.com"), config["server"]["domain"].value());

// get multiple values
assert_eq!(
    vec!["example.com", "www.example.com"],
    config["server"]["domain"].values().collect::<Vec<_>>()
);

// parse multiple values
assert_eq!(
    Ok(vec![80, 443]),
    config["server"]["port"]
        .values()
        .map(|value| value.parse::<u16>())
        .collect::<Result<Vec<_>, _>>()
);

Implementations

Check whether the config has the node.

Iterator for the children of a node.

The first child of the node.

// excerpt of long.nccl:
// strings
//    in which case
//       "just\nuse quotes"
let source = std::fs::read_to_string("examples/long.nccl").unwrap();
let config = parse_config(&source).unwrap();
assert_eq!(
    "just\nuse quotes",
    config["strings"]["in which case:"]
        .child()
        .unwrap()
        .parse_quoted()
        .unwrap()
);

Iterator for the child values of a node.

The first child value of a node.

Parse the string including escape sequences if it’s quoted.

See Config::child.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

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

This method tests for !=.

Converts the given value to a String. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.