Attribute Macro ebml_iterable_specification_derive::ebml_specification
source · #[ebml_specification]
Expand description
Attribute that derives implementations of EbmlSpecification
and EbmlTag
for an enum.
This macro is intended to make implementing the traits in ebml-iterable-specification easier to manage. Rather than requiring handwritten implementations for EbmlSpecification
and EbmlTag
methods, this macro understands attributes assigned to enum members and generates an implementation accordingly.
When deriving EbmlSpecification
for an enum, the following attributes are required for each variant:
- #[id(
u64
)] - This attribute specifies the “id” of the tag. e.g.0x1a45dfa3
- #[data_type(
TagDataType
)] - This attribute specifies the type of data contained in the tag. e.g.TagDataType::UnsignedInt
The following attribute is optional for each variant:
- #[doc_path(Path/To/Element)] - This attribute specifies the document path of the current element. If this attribute is not present, the variant is treated as a Root element. Global elements can be defined with wildcard paths, e.g. #[doc_path(Segment/(1-)/)].
Note
This attribute modifies the variants in the enumeration by adding fields to them. It also will add the following variants to the enum:
Crc32(Vec<u8>)
- global tag defined in the EBML specVoid(Vec<u8>)
- global tag defined in the EBML specRawTag(u64, Vec<u8>)
- used to support reading “unknown” tags that aren’t in the spec