pub struct Config {
    pub collection: HashMap<String, Value>,
}
Expand description

The object that keeps the data collection.

This is the yaml file to be used in the following tests:

# tests/settings.yaml

user:
  name: John
  is_real: false
  age: 39
  height: 1.78
  children:
    - Huey
    - Dewey
    - Louie

Fields

collection: HashMap<String, Value>

Implementations

Creates and return the Config instance given the data source path (can be a file or a folder).

Examples:
use kalgan_config::Config;

let config: Config = Config::new("tests/settings.yaml");

Returns the serde_yaml::Value for the given parameter.

Examples:
assert_eq!(config.get("user.name").unwrap(), "John");

Returns the value as a String for the given parameter.

Examples:
assert_eq!(config.get_string("user.name").unwrap(), "John".to_string());

Returns the value as a bool for the given parameter.

Examples:
assert_eq!(config.get_bool("user.is_real").unwrap(), false);

Returns the value as a i64 for the given parameter.

Examples:
assert_eq!(config.get_number("user.age").unwrap(), 39);

Returns the value as a f64 for the given parameter.

Examples:
assert_eq!(config.get_float("user.height").unwrap(), 1.78);

Returns the value as a Vec<serde_yaml::Value> for the given parameter.

Examples:
assert_eq!(config.get_vec("user.children").unwrap(), vec!["Huey", "Dewey", "Louie"]);

Trait Implementations

Formats the value using the given formatter. 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.