use reifydb_transaction::transaction::Transaction;
use crate::{
Result,
ast::ast::AstDispatch,
bump::BumpBox,
expression::ExpressionCompiler,
plan::logical::{Compiler, DispatchNode, LogicalPlan},
};
impl<'bump> Compiler<'bump> {
pub(crate) fn compile_dispatch(
&self,
ast: AstDispatch<'bump>,
_tx: &mut Transaction<'_>,
) -> Result<LogicalPlan<'bump>> {
let mut fields = Vec::with_capacity(ast.fields.len());
for (name, expr_box) in ast.fields {
let expr = ExpressionCompiler::compile(BumpBox::into_inner(expr_box))?;
fields.push((name, expr));
}
Ok(LogicalPlan::Dispatch(DispatchNode {
on_event: ast.on_event,
variant: ast.variant,
fields,
}))
}
}