logo
pub struct Config { /* private fields */ }
Expand description

The pencil Config type, We provide ways to fill it from JSON files:

let mut app = sharp_pencil::Pencil::new("/demo");
app.config.from_jsonfile("yourconfig.json")

You can also load configurations from an environment variable pointing to a file:

let mut app = sharp_pencil::Pencil::new("/demo");
app.config.from_envvar("YOURAPPLICATION_SETTINGS")

In this case, you have to set this environment variable to the file you want to use. On Linux and OS X you can use the export statement:

export YOURAPPLICATION_SETTINGS="/path/to/config/file"

Implementations

Create a Config object.

Set a value for the key.

Returns a reference to the value corresponding to the key.

Get a boolean configuration value. If the key doesn’t exist or the value is not a Json::Boolean, the default value will be returned.

Loads a configuration from an environment variable pointing to a JSON configuration file.

Updates the values in the config from a JSON file.

Updates the values from the given Object.

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

Returns the “default value” for a type. 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 resulting type after obtaining ownership.

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

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.

Get the TypeId of this object.