@@ -50,6 +50,37 @@ pub(crate) struct ChildElementDescriptor {
50
50
pub ( crate ) data_type : ElementDataType ,
51
51
}
52
52
53
+ // This macro helps us define the EBML master elements and their children.
54
+ //
55
+ // It will generate the `ElementIdent` enum, and the `master_elements` function.
56
+ //
57
+ // The `ElementIdent` enum is used to represent **ONLY** the elements that we care about.
58
+ // When one of these elements is encountered, `ElementReader::next()` will return an
59
+ // `ElementReaderYield::Master` or `ElementReaderYield::Child`. Otherwise, it will return
60
+ // `ElementReaderYield::Unknown`.
61
+ //
62
+ // The `master_elements` function is used to map the element IDs to their respective
63
+ // `MasterElement` struct, which contains the element's identifier and its children.
64
+ // This is used to determine the children of a master element when it is encountered.
65
+ //
66
+ // If a master element is a child to another master element, it will be defined BOTH as a
67
+ // child element in the parent master element, and as a top level master element.
68
+ //
69
+ // To define a master element, use the following syntax:
70
+ //
71
+ // ELEMENT_IDENT_VARIANT: {
72
+ // id: 0x1234_5678,
73
+ // children: [
74
+ // CHILD_ELEMENT_VARIANT: { 0x1234_5679, DataType },
75
+ // CHILD_ELEMENT_VARIANT2: { 0x1234_567A, DataType },
76
+ // ],
77
+ // },
78
+ //
79
+ // If `CHILD_ELEMENT_VARIANT2` is a master element, it should ALSO be defined at the top level with
80
+ // its own children.
81
+ //
82
+ // Then when parsing, `ELEMENT_IDENT_VARIANT`, `CHILD_ELEMENT_VARIANT`, and `CHILD_ELEMENT_VARIANT2`
83
+ // will be available as `ElementIdent` variants.
53
84
ebml_master_elements ! {
54
85
EBML : {
55
86
id: 0x1A45_DFA3 ,
0 commit comments