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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
#![doc(html_logo_url = "https://avatars2.githubusercontent.com/u/52050279?s=200&v=4")]
extern crate serde_derive;
pub mod http {
include!(concat!(env!("OUT_DIR"), "/http.rs"));
use prost::Message;
use serde::ser::Serialize;
use std::collections::HashMap;
pub const OP_PERFORM_REQUEST: &str = "PerformRequest";
pub const OP_HANDLE_REQUEST: &str = "HandleRequest";
impl Into<Request> for &[u8] {
fn into(self) -> Request {
Request::decode(self).unwrap()
}
}
impl Into<Response> for &[u8] {
fn into(self) -> Response {
Response::decode(self).unwrap()
}
}
impl Response {
pub fn json<T>(payload: T, status_code: u32, status: &str) -> Response
where
T: Serialize,
{
Response {
body: serde_json::to_string(&payload).unwrap().into_bytes(),
header: HashMap::new(),
status: status.to_string(),
status_code,
}
}
pub fn not_found() -> Response {
Response {
status: "Not Found".to_string(),
status_code: 404,
..Default::default()
}
}
pub fn ok() -> Response {
Response {
status: "OK".to_string(),
status_code: 200,
..Default::default()
}
}
pub fn internal_server_error(msg: &str) -> Response {
Response {
status: "Internal Server Error".to_string(),
status_code: 500,
body: msg.to_string().as_bytes().into(),
..Default::default()
}
}
pub fn bad_request() -> Response {
Response {
status: "Bad Request".to_string(),
status_code: 400,
..Default::default()
}
}
}
}
pub mod core {
use prost::Message;
include!(concat!(env!("OUT_DIR"), "/core.rs"));
pub const OP_PERFORM_LIVE_UPDATE: &str = "PerformLiveUpdate";
pub const OP_IDENTIFY_CAPABILITY: &str = "IdentifyCapability";
pub const OP_HEALTH_REQUEST: &str = "HealthRequest";
pub const OP_INITIALIZE: &str = "Initialize";
pub const OP_CONFIGURE: &str = "Configure";
pub const OP_REMOVE_ACTOR: &str = "RemoveActor";
impl Into<CapabilityConfiguration> for &[u8] {
fn into(self) -> CapabilityConfiguration {
CapabilityConfiguration::decode(self).unwrap()
}
}
}
pub mod extras {
use prost::Message;
include!(concat!(env!("OUT_DIR"), "/extras.rs"));
pub const OP_REQUEST_GUID: &str = "RequestGuid";
pub const OP_REQUEST_SEQUENCE: &str = "RequestSequence";
pub const OP_REQUEST_RANDOM: &str = "RequestRandom";
impl Into<GeneratorResult> for &[u8] {
fn into(self) -> GeneratorResult {
GeneratorResult::decode(self).unwrap()
}
}
impl Into<GeneratorRequest> for &[u8] {
fn into(self) -> GeneratorRequest {
GeneratorRequest::decode(self).unwrap()
}
}
}
pub mod eventstreams {
use prost::Message;
include!(concat!(env!("OUT_DIR"), "/eventstream.rs"));
pub const OP_DELIVER_EVENT: &str = "DeliverEvent";
pub const OP_WRITE_EVENT: &str = "WriteEvent";
pub const OP_QUERY_STREAM: &str = "QueryStream";
impl Into<Event> for &[u8] {
fn into(self) -> Event {
Event::decode(self).unwrap()
}
}
impl Into<StreamQuery> for &[u8] {
fn into(self) -> StreamQuery {
StreamQuery::decode(self).unwrap()
}
}
impl Into<TimeRange> for &[u8] {
fn into(self) -> TimeRange {
TimeRange::decode(self).unwrap()
}
}
impl Into<WriteResponse> for &[u8] {
fn into(self) -> WriteResponse {
WriteResponse::decode(self).unwrap()
}
}
impl Into<StreamResults> for &[u8] {
fn into(self) -> StreamResults {
StreamResults::decode(self).unwrap()
}
}
}
pub mod blobstore {
use prost::Message;
include!(concat!(env!("OUT_DIR"), "/blobstore.rs"));
pub const OP_CREATE_CONTAINER: &str = "CreateContainer";
pub const OP_REMOVE_CONTAINER: &str = "RemoveContainer";
pub const OP_REMOVE_OBJECT: &str = "RemoveObject";
pub const OP_LIST_OBJECTS: &str = "ListObjects";
pub const OP_UPLOAD_CHUNK: &str = "UploadChunk";
pub const OP_START_DOWNLOAD: &str = "StartDownload";
pub const OP_START_UPLOAD: &str = "StartUpload";
pub const OP_RECEIVE_CHUNK: &str = "ReceiveChunk";
pub const OP_GET_OBJECT_INFO: &str = "GetObjectInfo";
impl Into<FileChunk> for &[u8] {
fn into(self) -> FileChunk {
FileChunk::decode(self).unwrap()
}
}
impl Into<Container> for &[u8] {
fn into(self) -> Container {
Container::decode(self).unwrap()
}
}
impl Into<Blob> for &[u8] {
fn into(self) -> Blob {
Blob::decode(self).unwrap()
}
}
impl Into<ContainerList> for &[u8] {
fn into(self) -> ContainerList {
ContainerList::decode(self).unwrap()
}
}
impl Into<BlobList> for &[u8] {
fn into(self) -> BlobList {
BlobList::decode(self).unwrap()
}
}
impl Into<StreamRequest> for &[u8] {
fn into(self) -> StreamRequest {
StreamRequest::decode(self).unwrap()
}
}
}
pub mod messaging {
use prost::Message;
include!(concat!(env!("OUT_DIR"), "/messaging.rs"));
pub const OP_PUBLISH_MESSAGE: &str = "Publish";
pub const OP_DELIVER_MESSAGE: &str = "DeliverMessage";
pub const OP_PERFORM_REQUEST: &str = "Request";
impl Into<DeliverMessage> for &[u8] {
fn into(self) -> DeliverMessage {
DeliverMessage::decode(self).unwrap()
}
}
impl Into<PublishMessage> for &[u8] {
fn into(self) -> PublishMessage {
PublishMessage::decode(self).unwrap()
}
}
impl Into<RequestMessage> for &[u8] {
fn into(self) -> RequestMessage {
RequestMessage::decode(self).unwrap()
}
}
}
pub mod keyvalue {
include!(concat!(env!("OUT_DIR"), "/keyvalue.rs"));
pub const OP_ADD: &str = "Add";
pub const OP_GET: &str = "Get";
pub const OP_SET: &str = "Set";
pub const OP_DEL: &str = "Del";
pub const OP_CLEAR: &str = "Clear";
pub const OP_RANGE: &str = "Range";
pub const OP_PUSH: &str = "Push";
pub const OP_LIST_DEL: &str = "ListItemDelete";
pub const OP_SET_ADD: &str = "SetAdd";
pub const OP_SET_REMOVE: &str = "SetRemove";
pub const OP_SET_UNION: &str = "SetUnion";
pub const OP_SET_INTERSECT: &str = "SetIntersection";
pub const OP_SET_QUERY: &str = "SetQuery";
pub const OP_KEY_EXISTS: &str = "KeyExists";
}
pub mod capabilities;