Struct chilli::config::Config
[−]
[src]
pub struct Config { /* fields omitted */ }
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"
Methods
impl Config
[src]
pub fn new() -> Config
[src]
Create a Config
object.
pub fn set(&mut self, key: &str, value: Value)
[src]
Set a value for the key.
pub fn get(&self, key: &str) -> Option<&Value>
[src]
Returns a reference to the value corresponding to the key.
pub fn get_boolean(&self, key: &str, default: bool) -> bool
[src]
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.
pub fn from_envvar(&mut self, variable_name: &str)
[src]
Loads a configuration from an environment variable pointing to a JSON configuration file.
pub fn from_jsonfile(&mut self, filepath: &str)
[src]
Updates the values in the config from a JSON file.
pub fn from_object(&mut self, object: Map<String, Value>)
[src]
Updates the values from the given Object
.
Trait Implementations
impl Clone for Config
[src]
fn clone(&self) -> Config
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more