1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
use fmt;
use TemplarError;
use UnstructuredDataTrait;
pub type TestData = Unstructured;
// use unstructured::UnstructuredDataTrait;
// #[derive(Clone)]
// pub enum Node2 {
// Expr(Vec<NodeData>),
// Scope(Box<NodeData>),
// Operation(Arc<Operation>),
// }
// impl fmt::Display for Node2 {
// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// write!(f, "<Node>")
// }
// }
// impl UnstructuredDataTrait for Node2 {
// type ErrorType = TemplarError;
// type OtherType = Node2;
// }
// pub type NodeData = unstructured::Unstructured<Node2>;
// pub trait NodeTrait {
// fn exec(&self, ctx: &impl Context) -> NodeData;
// fn set_operation(self, op: Operations) -> NodeData;
// fn into_scope(self) -> NodeData;
// fn into_document(self) -> Result<NodeData>;
// fn render(&self, ctx: &impl Context) -> Result<String>;
// }
// impl NodeTrait for NodeData {
// fn exec(&self, ctx: &impl Context) -> NodeData {
// match self {
// // Self::Other(Node2::Operation(op)) => op.exec(ctx),
// // Self::Value(a) => {
// // let docs = a.iter().collect::<Vec<&Document>>();
// // ctx.get_path(&docs)
// // }
// Self::Other(Node2::Scope(i)) => {
// let local_context = ctx.create_scope();
// i.exec(&local_context)
// }
// Self::Other(Node2::Expr(a)) => {
// let mut res: Vec<NodeData> = a.iter().map(|n| n.exec(ctx)).collect();
// if res.is_empty() {
// Self::Unassigned
// } else if res.len() == 1 {
// res.pop().unwrap()
// } else {
// NodeData::from(res)
// }
// }
// _ => self.clone(),
// }
// }
// fn set_operation(self, op: Operations) -> NodeData {
// match self {
// // Self::Other(Node2::Expr(nodes)) => Node2::Operation(Arc::new(op.build(nodes))),
// _ => self,
// }
// }
// fn into_scope(self) -> NodeData {
// Self::Other(Node2::Scope(Box::new(self)))
// }
// fn into_document(self) -> Result<NodeData> {
// Ok(self)
// }
// fn render(&self, ctx: &impl Context) -> Result<String> {
// // self.exec(ctx).render()
// Ok("TODO".into())
// }
// }