pub enum CompiledNode {
Value {
value: Value,
},
Array {
nodes: Box<[CompiledNode]>,
},
BuiltinOperator {
opcode: OpCode,
args: Vec<CompiledNode>,
},
CustomOperator {
name: String,
args: Vec<CompiledNode>,
},
StructuredObject {
fields: Vec<(String, CompiledNode)>,
},
}Expand description
A compiled node representing a single operation or value in the logic tree.
Nodes are created during the compilation phase and evaluated during execution. Each node type is optimized for its specific purpose:
- Value: Static JSON values that don’t require evaluation
- Array: Collections of nodes evaluated sequentially
- BuiltinOperator: Fast OpCode-based dispatch for built-in operators
- CustomOperator: User-defined operators with dynamic dispatch
- StructuredObject: Template objects for structure preservation
Variants§
Value
A static JSON value that requires no evaluation.
Used for literals like numbers, strings, booleans, and null.
Array
An array of compiled nodes.
Each node is evaluated in sequence, and the results are collected into a JSON array.
Uses Box<[CompiledNode]> for memory efficiency.
Fields
nodes: Box<[CompiledNode]>BuiltinOperator
A built-in operator optimized with OpCode dispatch.
The OpCode enum enables direct dispatch without string lookups, significantly improving performance for the 50+ built-in operators.
CustomOperator
A custom operator registered via DataLogic::add_operator.
Custom operators use dynamic dispatch and are looked up by name from the engine’s operator registry.
StructuredObject
A structured object template for preserve_structure mode.
When structure preservation is enabled, objects with keys that are not built-in operators or registered custom operators are preserved as templates. Each field is evaluated independently, allowing for dynamic object generation.
Note: Custom operators are checked before treating keys as structured fields, ensuring they work correctly within preserved structures.
Fields
fields: Vec<(String, CompiledNode)>Trait Implementations§
Source§impl Clone for CompiledNode
impl Clone for CompiledNode
Source§fn clone(&self) -> CompiledNode
fn clone(&self) -> CompiledNode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more