Struct libconfig::types::Config [] [src]

pub struct Config { /* fields omitted */ }

The top-level Config type that represents a configuration

Methods

impl Config
[src]

Creates a new wrapper Config to hold a SettingsList

Looks up a value in a configuration. A path is a dot-separated list of settings describing the path of the desired value in the configuration. Returns None if the path is invalid. A path is invalid if it is not syntactically well-formed, if it attempts to index an array or list beyond the limit, or if it includes an unknown setting.

Examples

Suppose we have loaded a configuration that consists of:

my_string = "hello";
a_list = ([1, 2, 3], true, { x = 4; }, "good bye");

Then, the path to retrieve "hello" is my_string. The path to retrieve true inside a_list would be a_list.[1]. The path to retrieve the setting x inside a_list would be alist.[2].x.

Here's a small demonstration:

use config::reader::from_str;

let my_conf = from_str("my_string = \"hello\"; a_list = ([1, 2, 3], true, { x = 4; }, \"good_bye\");").unwrap();

let my_str_value = my_conf.lookup("my_string");
assert!(my_str_value.is_some());

let my_boolean_value = my_conf.lookup("a_list.[1]");
assert!(my_boolean_value.is_some());

let my_x_setting = my_conf.lookup("a_list.[2].x");
assert!(my_x_setting.is_some());

A convenient wrapper around lookup() that unwraps the underlying primitive type of a generic Value.

Returns None in the same way lookup() does; or if the underlying Value type does not match with the requested type - in this case, bool.

A convenient wrapper around lookup() that unwraps the underlying primitive type of a generic Value.

Returns None in the same way lookup() does; or if the underlying Value type does not match with the requested type - in this case, i32.

A convenient wrapper around lookup() that unwraps the underlying primitive type of a generic Value.

Returns None in the same way lookup() does; or if the underlying Value type does not match with the requested type - in this case, i64.

A convenient wrapper around lookup() that unwraps the underlying primitive type of a generic Value.

Returns None in the same way lookup() does; or if the underlying Value type does not match with the requested type - in this case, f32.

A convenient wrapper around lookup() that unwraps the underlying primitive type of a generic Value.

Returns None in the same way lookup() does; or if the underlying Value type does not match with the requested type - in this case, f64.

A convenient wrapper around lookup() that unwraps the underlying primitive type of a generic Value.

Returns None in the same way lookup() does; or if the underlying Value type does not match with the requested type - in this case, String.

A convenient wrapper around lookup_boolean() that unwraps the underlying primitive type of a boolean Value.

If either of lookup_boolean() or lookup return None, then the user-provided default value is returned.

A convenient wrapper around lookup_integer32() that unwraps the underlying primitive type of an integer32 Value.

If either of lookup_integer32() or lookup return None, then the user-provided default value is returned.

A convenient wrapper around lookup_integer64() that unwraps the underlying primitive type of an integer64 Value.

If either of lookup_integer64() or lookup return None, then the user-provided default value is returned.

A convenient wrapper around lookup_floating32() that unwraps the underlying primitive type of an floating32 Value.

If either of lookup_floating32() or lookup return None, then the user-provided default value is returned.

A convenient wrapper around lookup_floating64() that unwraps the underlying primitive type of an floating64 Value. If either of lookup_floating64() or lookup return None, then the user-provided default value is returned.

A convenient wrapper around lookup_str() that unwraps the underlying primitive type of a string Value.

If either of lookup_str() or lookup return None, then the user-provided default value is returned.

Trait Implementations

impl PartialEq for Config
[src]

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

This method tests for !=.

impl Debug for Config
[src]

Formats the value using the given formatter.

impl FromStr for Config
[src]

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more