zen_engine/handler/table/
mod.rs1pub mod zen;
2
3use zen_expression::variable::Variable;
4
5#[derive(Debug, Clone)]
6pub(crate) enum RowOutputKind {
7 Variable(Variable),
8}
9
10#[derive(Debug, Default)]
11pub(crate) struct RowOutput {
12 output: OutputMap,
13}
14
15type OutputMap = Vec<(String, RowOutputKind)>;
16
17impl RowOutput {
18 pub fn push<K: Into<String>>(&mut self, key: K, value: RowOutputKind) {
19 self.output.push((key.into(), value))
20 }
21
22 pub async fn to_json(&self) -> Variable {
23 let object = Variable::empty_object();
24
25 for (key, kind) in &self.output {
26 match kind {
27 RowOutputKind::Variable(variable) => {
28 object.dot_insert(key.as_str(), variable.clone());
29 }
30 }
31 }
32
33 object
34 }
35}