derpscfg
A brief, incomplete, and mostly wrong derive implementation for scfg.
A fork of scfg-rs with simple but powerful derive capabilities.
Example
use *;
Status
Can currently only derive implementations for regular struct types with named fields. Simple enums (without fields) can be used as scalar values. No support for tuples, newtypes, or more complex enums.
Supports parsing to most standard library types that implement FromStr and to
Option, Vec, VecDeque, and LinkedList of such types.
Field names with underscores are tried from both field_name and field-name.
Overriding field names is not currently implemented. Enum values can be written
in both camel or snake case.
Fields annotated with #[scfg(param)] are taken from a directive's parameters
in order of declaration. Be careful with cardinality. A Vec will always take
all available params, so there can only be one, and it must be the last field
from parameters.
The toplevel derpscfg::parse() function can only be used on types that do not
declare any fields with param, as the toplevel element does not have any.
If you need the map-style genericity of scfg in parts of your data you can parse
a field to derpscfg::Directive (or Option/Vec/etc. thereof).
A list of scalars can come from either repeated directives, or a directive with multiple parameters, hence the following are equivalent:
config {
value: 5
value: 6
}
and
config {
value: 5 6
}
Both would parse fine to a field value: Vec<u64>.
Contributing
Please send patches to the mailing list.
License
MIT OR Apache-2.0