rustEnum static method
enum values
Implementation
static Layout rustEnum(List<Layout> variants, Layout? discriminant,
{String? property}) {
final unionLayout = Union((discriminant != null) ? discriminant : u8());
variants.asMap().forEach((index, variant) => unionLayout.addVariant(
variant: index, layout: variant, property: variant.property));
return CustomLayout<Map<String, dynamic>, dynamic>(
layout: unionLayout,
decoder: (value) {
return {"key": value.keys.first, "value": value.values.first};
},
encoder: (src) {
return src;
},
property: property);
}