Skip to main content

read_existing

Function read_existing 

Source
pub fn read_existing<P, T>(path: P) -> Result<T, Error>
where P: AsRef<Path>, T: DeserializeOwned,
Expand description

Read config from an existing TOML, JSON, or JSONC file.

.jsonc accepts both // line comments and /* ... */ block comments.

use cloudiful_config::read_existing;
use serde::Deserialize;

#[derive(Deserialize)]
struct AppConfig {
    port: u16,
}

let path = std::env::temp_dir().join("config-crate-read-existing.toml");
let _config: AppConfig = read_existing(&path).unwrap();