Attribute Macro config

Source
#[config]
Expand description

Convenience macro to quickly create an implementation of the Config trait. This also automatically implements the Serialize and Deserialize traits from the [serde] crate (requires the feature serde_derive)

§Example

#[config(file_name = "example.toml", save_dir = "example")]
pub struct ExampleConfig {
    string: String,
    number: u32,
    boolean: bool
}

impl Default for ExampleConfig {
    fn default() -> Self {
        Self {
            string: "string".into(),
            number: 100,
            boolean: true
        }
    }
}

§Options

§file_name = "<file name here>"

The file name of the config

§save_dir = "<save directory>"

The path of the config file’s folder relative to the config root (normally $HOME/.config/)

§cfg_type(<config type>) (optional)

The type of config the file will be saved as.

Valid options are toml and ron