Struct libconfig::types::Setting [] [src]

pub struct Setting {
    pub name: String,
    pub value: Value,
}

A Setting representation. Settings have a name and a value.

Fields

Setting name, as read from the configuration file

This setting's value. A value can be a scalar, an array, a list, or a group.

Methods

impl Setting
[src]

Creates a new setting with a given name and value

Examples

Let's say we want to create a setting to store an i32. We start by creating a ScalarValue:

use config::types::ScalarValue;

let setting_scalarvalue = ScalarValue::Integer32(1);

Then, we wrap it into a Value, because settings store generic values:

use config::types::Value;

let setting_value = Value::Svalue(setting_scalarvalue);

And then we choose a name for our setting and create it:

use config::types::Setting;

let setting_name = "my_setting".to_string();
let my_setting = Setting::new(setting_name, setting_value);

Here's the complete example:

use config::types::ScalarValue;
use config::types::Value;
use config::types::Setting;

let setting_scalarvalue = ScalarValue::Integer32(1);
let setting_value = Value::Svalue(setting_scalarvalue);
let setting_name = "my_setting".to_string();
let my_setting = Setting::new(setting_name, setting_value);

Trait Implementations

impl PartialEq for Setting
[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 Setting
[src]

Formats the value using the given formatter.