Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

confy section not clear and leads to compilation errors #61

Open
Masber opened this issue May 8, 2022 · 0 comments
Open

confy section not clear and leads to compilation errors #61

Masber opened this issue May 8, 2022 · 0 comments

Comments

@Masber
Copy link

Masber commented May 8, 2022

confy requires serde for serialization and deserialization and the documentaion is not clear about this. Also confy will fail in file is missing my_app so Default trait was also added.

Add confy and serde to your cargo.toml

confy = "0.4.0"
serde = { version = "1.0", features = ["derive"] }

Add Default trait to generate a file with default values if missing.

use serde::{Serialize, Deserialize};

#[derive(Default, Debug, Serialize, Deserialize)]
struct MyConfig {
    name: String,
    comfy: bool,
    foo: i64,
}

fn main() -> Result<(), io::Error> {
    let cfg: MyConfig = confy::load("my_app")?;
    println!("{:#?}", cfg);
    Ok(())
}
RampedIndent added a commit to RampedIndent/confy that referenced this issue Feb 6, 2023
Updated README.md to address rust-cli#61
RampedIndent added a commit to RampedIndent/confy that referenced this issue Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant