Macro schema_inner

Source
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:

  1. any: Adds an Any node to the schema, indicating a branch point that accepts multiple instructions of any type.
  2. [$ix_type:expr, $name:expr]: Adds an Instruction node with the specified instruction type and name, without nested instructions.
  3. [$ix_type:expr, $name:expr, [$($inner:tt)*]]: Adds an Instruction node with the specified instruction type and name, including inner instructions which are parsed recursively.

§Parameters

  • $nodes: A mutable reference to a Vec<SchemaNode>. This vector accumulates the constructed schema nodes, which can include both Any and Instruction node 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 the Instruction node 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_type corresponds to a valid instruction type and that $name is a string literal for compatibility with InstructionSchemaNode.
  • The recursive structure allows for complex, multi-level instruction schemas suitable for detailed transaction validation and processing.