macro_rules! schema_inner {
($nodes:expr, ) => { ... };
($nodes:expr, any $($rest:tt)*) => { ... };
($nodes:expr, [$ix_type:expr, $name:expr] $($rest:tt)*) => { ... };
($nodes:expr, [$ix_type:expr, $name:expr, [$($inner:tt)*]] $($rest:tt)*) => { ... };
}Expand description
Recursively constructs schema nodes within the schema! macro.
The schema_inner! macro is utilized internally by the schema! macro to
build a TransactionSchema structure by parsing tokens into individual
SchemaNode elements. This macro supports multiple node types, including
Any nodes and Instruction nodes with optional nested instructions. Each
parsed node is appended to the provided vector, forming a hierarchical
schema structure.
§Syntax
This macro supports three main syntax patterns:
any: Adds anAnynode to the schema, indicating a branch point that accepts multiple instructions of any type.[$ix_type:expr, $name:expr]: Adds anInstructionnode with the specified instruction type and name, without nested instructions.[$ix_type:expr, $name:expr, [$($inner:tt)*]]: Adds anInstructionnode with the specified instruction type and name, including inner instructions which are parsed recursively.
§Parameters
$nodes: A mutable reference to aVec<SchemaNode>. This vector accumulates the constructed schema nodes, which can include bothAnyandInstructionnode variants with nested instructions.$ix_type: The instruction type for the node, provided as an expression. This identifies the specific instruction type in the schema.$name: A string literal representing the name of the instruction. This name is associated with theInstructionnode for identification.
§Returns
This macro modifies the Vec<SchemaNode> passed as $nodes, adding each
parsed SchemaNode to the vector. Nodes can be nested, with the structure
reflecting any provided inner instructions.
§Notes
- This macro is intended for internal use within the
schema!macro and is not typically called directly by users. - Ensure that each
$ix_typecorresponds to a valid instruction type and that$nameis a string literal for compatibility withInstructionSchemaNode. - The recursive structure allows for complex, multi-level instruction schemas suitable for detailed transaction validation and processing.