Skip to main content

load

Function load 

Source
pub fn load<T: DeserializeOwned>(path: impl Into<PathBuf>) -> Result<T>
Expand description

Load one path with default options — the shortest way in. An existing file loads as a single file source; anything else is treated as a folder (a missing path is Error::NotFound). The annotated target type decides what you get back:

#[derive(serde::Deserialize)]
struct MyConfig {
    host: String,
    port: u16,
}

let value: c4::Value = c4::load("config")?;   // a folder …
let value: c4::Value = c4::load("app.yml")?;  // … or one file
let cfg: MyConfig = c4::load("config")?;