#[derive(FromConfig)]
{
// Attributes available to this derive:
#[config]
}
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 FromConfig 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(name = "...")] on certain named fields.
Symmetrically, on unnamed fields you may want to use #[config(index = ...)] to remap array indices.
use inline_config::FromConfig;
#[derive(FromConfig)]
struct MyStruct {
name: String, // matches "name"
#[config(name = "date-of-birth")]
date_of_birth: String, // matches "date-of-birth"
r#mod: String, // matches "mod"
}