Derive Macro kfl::DecodeScalar
source · #[derive(DecodeScalar)]
{
// Attributes available to this derive:
#[kfl]
}
Expand description
Currently DecodeScalar
derive is only implemented for enums
Enums
Only enums that contain no data are supported:
use kfl::DecodeScalar;
#[derive(DecodeScalar)]
enum ColourKind {
Red,
Blue,
Green,
InfraRed,
}
This will match scalar values in kebab-case
. For example, this node decoder:
#[derive(Decode)]
struct Document {
#[kfl(children)]
colour: Vec<Colour>,
}
#[derive(Decode)]
struct Colour(#[kfl(argument)] ColourKind);
Can be populated from the following text:
colour "red"
colour "blue"
colour "green"
colour "infra-red"