Crate nccl[][src]

Expand description

Nccl is an easy way to add minimal configuration to your crate without having to deal with complicated interfaces, obnoxious syntax, or outdated languages. Nccl makes it easy for a user to pick up your configuration. It’s as easy as five cents.

Nccl was motivated by the fact that other configuration languages are too complicated for both end-users and developers. Everyone loves types, but in a configuration language, there’s too much room for interpretation There are no types here.

This is a nice approach for smaller, non-semantic configurations; you shouldn’t be accidentally implementing a DSL with nccl, and if you are, it should feel painful.

For interacting with a parsed configuration, see config::Config.

Syntax

The single most important feature:

key
    value

Results in config["key"].value() == Some("value"). Note that there is no semantic difference between a key and a value, so config.value() == Some("key"). For most of this document and the library source code, the words key, value, and node are used almost interchangeably.

There are no types:

threads
    16
is this a problem?
    no 🇳🇴
end of the world
    2012-12-21

Interpret the data however you want.

Indentation is significant. Each top-level key-value pair must use the same type of indentation for each sub-value. You may mix indentation per-file.

a
    1
b
 2

Comments exist on their own line or after a quoted value, otherwise they become part of the value.

hello # this part of the key!
    # this is not
    world
    "y'all" # this isn't either

Duplicate keys have their values merged.

oh christmas tree
    o tannenbaum

oh christmas tree
    o tannenbaum
    five golden rings
    wait wrong song

Results in one key “oh christmas tree” with three values. This property enables parse_config_with to merge two configurations together. Say if you wanted to enable an end user to be able to override some default values, first you would parse the user’s configuration, and then parse the default on top of that. config::Config::value always returns the first value, which would be the user’s value.

Re-exports

pub use config::Config;

Modules

Contains the configuration struct

Enums

Errors that may occur while parsing

Functions

Parse a nccl configuration

Parse a new nccl configuration on top of another