ConfigData

Derive Macro ConfigData 

Source
#[derive(ConfigData)]
{
    // Attributes available to this derive:
    #[config_data]
}
Expand description

Defines a data structure that can be converted directly from a compatible container.

One needs to ensure all field types, if containing custom types, shall inherit ConfigData as well. Use structs with unnamed fields to access from arrays; use structs with named fields to access from tables. The fields do not necessarily need to be “full” - it may only contain a subset of fields in source data.

To avoid non-identifier key names occurred in source config (e.g. contains -), use #[config_data(rename = "...")] on certain fields.

use inline_config::ConfigData;

#[derive(ConfigData)]
struct MyStruct {
    name: String, // matches "name"
    #[config_data(rename = "date-of-birth")]
    date_of_birth: String, // matches "date-of-birth"
    r#mod: String, // matches "mod"
}