summaryrefslogtreecommitdiff
path: root/src/msg.fbs
blob: 37a48e2dfddce6c2453fa5503984ede9627f5eaf (plain)
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
union Any {
  Start,
  StartRes,
  CodeFetch,
  CodeFetchRes,
  CodeCache,
  Exit,
  TimerStart,
  TimerReady,
  TimerClear,
  Environ,
  EnvironRes,
  FetchReq,
  FetchRes,
  MakeTempDir,
  MakeTempDirRes,
  Mkdir,
  Remove,
  ReadFile,
  ReadFileRes,
  WriteFile,
  Rename,
  Stat,
  StatRes,
  SetEnv,
}

enum ErrorKind: byte {
  NoError = 0,

  // io errors

  NotFound,
  PermissionDenied,
  ConnectionRefused,
  ConnectionReset,
  ConnectionAborted,
  NotConnected,
  AddrInUse,
  AddrNotAvailable,
  BrokenPipe,
  AlreadyExists,
  WouldBlock,
  InvalidInput,
  InvalidData,
  TimedOut,
  Interrupted,
  WriteZero,
  Other,
  UnexpectedEof,

  // url errors

  EmptyHost,
  IdnaError,
  InvalidPort,
  InvalidIpv4Address,
  InvalidIpv6Address,
  InvalidDomainCharacter,
  RelativeUrlWithoutBase,
  RelativeUrlWithCannotBeABaseBase,
  SetHostOnCannotBeABaseUrl,
  Overflow,

  // hyper errors

  HttpUser,
  HttpClosed,
  HttpCanceled,
  HttpParse,
  HttpOther,
}

table Base {
  cmd_id: uint32;
  sync: bool = true; // TODO(ry) Change default to false.
  error_kind: ErrorKind = NoError;
  error: string;
  msg: Any;
}

table Start {
  unused: int8;
}

table StartRes {
  cwd: string;
  argv: [string];
  debug_flag: bool;
  deps_flag: bool;
}

table CodeFetch {
  module_specifier: string;
  containing_file: string;
}

table CodeFetchRes {
  // If it's a non-http module, moduleName and filename will be the same.
  // For http modules, moduleName is its resolved http URL, and filename
  // is the location of the locally downloaded source code.
  module_name: string;
  filename: string;
  source_code: string;
  output_code: string; // Non-empty only if cached.
}

table CodeCache {
  filename: string;
  source_code: string;
  output_code: string;
}

table Exit {
  code: int;
}

table TimerStart {
  id: uint;
  delay: uint;
}

table TimerReady {
  id: uint;
  canceled: bool;
}

table TimerClear {
  id: uint;
}

table Environ {}

table SetEnv {
  key: string;
  value: string;
}

table EnvironRes {
  map: [EnvPair];
}

table EnvPair {
  key: string;
  value: string;
}

table FetchReq {
  id: uint;
  url: string;
  // header_line: [string];
}

table FetchRes {
  id: uint;
  status: int;
  header_key: [string];
  header_value: [string];
  body: [ubyte];
}

table MakeTempDir {
  dir: string;
  prefix: string;
  suffix: string;
}

table MakeTempDirRes {
  path: string;
}

table Mkdir {
  path: string;
  mode: uint;
  // mode specified by https://godoc.org/os#FileMode
}

table Remove {
  path: string;
  recursive: bool;
}

table ReadFile {
  filename: string;
}

table ReadFileRes {
  data: [ubyte];
}

table WriteFile {
  filename: string;
  data: [ubyte];
  perm: uint;
  // perm specified by https://godoc.org/os#FileMode
}

table Rename {
  oldpath: string;
  newpath: string;
}

table Stat {
  filename: string;
  lstat: bool;
}

table StatRes {
  is_file: bool;
  is_symlink: bool;
  len: ulong;
  modified:ulong;
  accessed:ulong;
  created:ulong;
  mode: uint;
  has_mode: bool; // false on windows
}

root_type Base;