-
Notifications
You must be signed in to change notification settings - Fork 14
/
idl.graphql
executable file
·122 lines (92 loc) · 2.36 KB
/
idl.graphql
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
# WIP IDL ideas...
spec {
id: "My Schema",
author: "Scoot Loot",
version: 1.2
}
import "../file"
# comment
struct self::position<X> () {
x: X,
y: X
}
struct user {
name: string (default: "Billy"),
age: u32,
email: Option<String>,
other_user: struct {
name: String,
email: String
},
position: self::position<u32>,
posts: list { post }
}
Vec<Vec<u32>> myType;
struct post {
title: string,
content: string
}
impl user () {
fn get_user() -> Result<self, String>
}
list self::user_list () { string }
union self::union () {
opt1: string
opt2: string2
}
enum myEnum () { red, orange, yellow }
enum Option<X> (dflt: None) {
None
Some(X)
}
enum Result<X, Y> (id: 12, dflt: Unset) {
Unset
Ok(X),
Err(Y),
Something { value: u32, another: u32 }
}
string namedString (id: 2, size: 20, default: 'hello')
tuple someTuple (id: 3, sorted: true) { string, string, string }
// // this is a comment
// struct({fiels: {
// name: string({default: "default value here", size: 20}),
// tags: list({of: string()}),
// tuple: tuple({sorted: true, values: [string(), string(), string()]}),
// map: map({values: string()}),
// // another comment
// enum: option({default: "red", choices: ["red", "blue", "orange"]}),
// p: portal({to: "map"}),
// nested: struct({fiels: {
// name: string(),
// value: u32({default: 20}),
// geo: geo({size: 4, default: {lat: 20, lng: 20.28}}),
// }})
// }});
// rpc_spec({
// name: "Test API",
// author: "hello",
// version: "1.0.0",
// spec: (self, mod) => {
// msg("send_name", struct());
// rpc("your_face", fn(self.send_name), option(self.send_name));
// rpc("your_face", fn(self.argument), result(self.send_name, self.error));
// rpc("your_face", fn(self.argument), empty());
// mod("mod_name", (self) => {
// });
// }
// });
// struct({
// name: string(),
// age: u16({default: 0}),
// tags: list({of: string()})
// });
//! let user_factory = NP_Factory::new(r#"{
//! "type": "struct",
//! "fields": [
//! ["name", {"type": "string"}],
//! ["age", {"type": "u16", "default": 0}],
//! ["tags", {"type": "list", "of": {
//! "type": "string"
//! }}]
//! ]
//! }"#)?;