#serde-derive #derive #serde

macro derive-macros

My personal configuration library

4 stable releases

2.1.1 Feb 16, 2024
2.1.0 Feb 15, 2024
2.0.0 Feb 6, 2024
1.0.0 Feb 6, 2024

#818 in Configuration

Download history 3/week @ 2024-02-07 243/week @ 2024-02-14 52/week @ 2024-02-21 8/week @ 2024-02-28 4/week @ 2024-03-06 6/week @ 2024-03-13 17/week @ 2024-03-27 16/week @ 2024-04-03

69 downloads per month
Used in 2 crates (via derive-config)

MIT license

11KB
192 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

~315–770KB
~18K SLoC