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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
mod impls;
mod se_de;
use crate::JValue;
use crate::TracePos;
use air_interpreter_cid::CID;
use polyplets::SecurityTetraplet;
use se_de::par_serializer;
use serde::Deserialize;
use serde::Serialize;
use std::fmt::Formatter;
use std::rc::Rc;
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct ParResult {
pub left_size: u32,
pub right_size: u32,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum Sender {
PeerId(Rc<String>),
PeerIdWithCallId { peer_id: Rc<String>, call_id: u32 },
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum CallResult {
#[serde(rename = "sent_by")]
RequestSentBy(Sender),
Executed(ValueRef),
Failed(Rc<CID<ServiceResultAggregate>>),
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ValueRef {
Scalar(Rc<CID<ServiceResultAggregate>>),
Stream {
cid: Rc<CID<ServiceResultAggregate>>,
generation: u32,
},
Unused(Rc<CID<JValue>>),
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct CallServiceFailed {
pub ret_code: i32,
pub message: Rc<String>,
}
impl CallServiceFailed {
pub fn new(ret_code: i32, message: Rc<String>) -> Self {
Self { ret_code, message }
}
pub fn to_value(&self) -> JValue {
serde_json::to_value(self).expect("default serializer shouldn't fail")
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct ServiceResultAggregate {
pub value_cid: Rc<CID<JValue>>,
pub argument_hash: Rc<str>,
pub tetraplet_cid: Rc<CID<SecurityTetraplet>>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct FoldSubTraceLore {
#[serde(rename = "pos")]
pub value_pos: TracePos,
#[serde(rename = "desc")]
pub subtraces_desc: Vec<SubTraceDesc>,
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct SubTraceDesc {
#[serde(rename = "pos")]
pub begin_pos: TracePos,
#[serde(rename = "len")]
pub subtrace_len: u32,
}
pub type FoldLore = Vec<FoldSubTraceLore>;
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct FoldResult {
pub lore: FoldLore,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct ApResult {
#[serde(rename = "gens")]
pub res_generations: Vec<u32>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct CanonResult {
pub tetraplet: Rc<CID<SecurityTetraplet>>,
pub values: Vec<Rc<CID<CanonCidAggregate>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct CanonCidAggregate {
pub value: Rc<CID<serde_json::Value>>,
pub tetraplet: Rc<CID<SecurityTetraplet>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ExecutedState {
#[serde(with = "par_serializer")]
Par(ParResult),
Call(CallResult),
Fold(FoldResult),
Ap(ApResult),
Canon(CanonResult),
}