macro_rules! xml_serde_enum {
(
$(#[$outer:meta])*
$name:ident {
$($f:ident => $s:literal,)*
}
) => { ... };
}Expand description
A macro to help you create mappings between string values in XML and Rust enums.
For example, we can define a mapping like this:
use xmlserde::xml_serde_enum;
xml_serde_enum!{
#[derive(Debug, Clone)]
Gender{
Male => "male",
Female => "female",
}
}After expansion, you can find an enum is defined like this:
#[derive(Debug, Clone)]
pub enum Gender {
Male,
Female,
}And string value of male will be deserialized as Gender::Male while female will be as Gender::Female.
In the same way, Gender will be serialized as male of female.
Panic if the given string is out of male and female.