Skip to main content

structure_mapping

Macro structure_mapping 

Source
macro_rules! structure_mapping {
    ( $id:ident $(, $val:literal = $name:ident $desc:expr )* $(,)?) => { ... };
    ( $id:ident $(, $val:literal = $name:ident $desc:expr )*, $othername:ident $(,)?) => { ... };
}
Expand description

Macro for creating a public enum implementing StructureIdentifier.

The first argument is the enum’s identifier. Subsequent arguments are given in the form value = variant "longer name": that is, a signed integer literal, then an equals sign, then the identifier of the enum variant that literal represents, then a string literal describing the variant. There is an optional final argument which is the identifier of a variant which catches all other values, and stores the value originally given to it.

If the final argument is given, the enum implements From: otherwise, it only implements TryFrom, returning an error which contains the offending integer.