6 stable releases

2.3.0 Oct 6, 2024
2.2.0 Jul 26, 2024
2.1.1 Feb 16, 2024
1.0.0 Feb 6, 2024

#333 in Configuration

Download history 19/week @ 2024-11-13 18/week @ 2024-11-20 30/week @ 2024-11-27 15/week @ 2024-12-04 36/week @ 2024-12-11 8/week @ 2024-12-18 6/week @ 2025-01-01 4/week @ 2025-01-08 14/week @ 2025-02-05 6/week @ 2025-02-12 8/week @ 2025-02-19 23/week @ 2025-02-26

51 downloads per month
Used in github-socialify-preview

MIT license

5KB
53 lines

Derive Config

My simple configuration library

use derive_config::DeriveTomlConfig;
use serde::{Deserialize, Serialize};

#[derive(Debug, Default, DeriveTomlConfig, Deserialize, Serialize)]
struct ExampleConfig {
    foo: String,
}

fn main() {
    let mut config = ExampleConfig::load().unwrap_or_default();
    println!("{}", config.foo);

    config.foo = String::from(if config.foo == "bar" { "baz" } else { "bar" });
    config.save().expect("Failed to save");
    println!("{}", config.foo);
}

Dependencies

~0.2–11MB
~71K SLoC