Expand description
The two enum shapes OCPI 2.3.0 distinguishes, as declarative macros.
OCPI 2.3.0 formalised the difference between an enum and an OpenEnum
(§types_enum_type, §types_openenum_type):
- An enum has “a finite number of strings … completely known at the time of writing of the specification”. An unknown value is a protocol error.
- An OpenEnum is for fields “for which the set of all possible values is not known at the time of writing”. Implementers are expected to add their own values, following RFC 6648.
ocpi_enum! and ocpi_open_enum! generate the
two shapes. The important difference is what happens to a value the crate has never heard of:
a closed enum refuses it, an open enum keeps it in a Custom variant so that a hub or a
pull-store-push pipeline hands it on untouched. Discarding it — which is what a plain
#[derive(Deserialize)] enum does — would make this crate lossy in exactly the place OCPI’s
extensibility chapter cares about.
Both macros are exported, so a party defining a custom module can use them for its own types.
Structs§
- Unknown
Variant - Why a string is not a member of a closed OCPI enum.