Function confy::load

source ·
pub fn load<'a, T: Serialize + DeserializeOwned + Default>(
    app_name: &str,
    config_name: impl Into<Option<&'a str>>
) -> Result<T, ConfyError>
Expand description

Load an application configuration from disk

A new configuration file is created with default values if none exists.

Errors that are returned from this function are I/O related, for example if the writing of the new configuration fails or confy encounters an operating system or environment that it does not support.

Note: The type of configuration needs to be declared in some way that is inferable by the compiler. Also note that your configuration needs to implement Default.

#[derive(Default, Serialize, Deserialize)]
struct MyConfig {}

let cfg: MyConfig = confy::load("my-app-name", None)?;