-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpkg.generated.mbti
More file actions
336 lines (280 loc) · 9.2 KB
/
pkg.generated.mbti
File metadata and controls
336 lines (280 loc) · 9.2 KB
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
324
325
326
327
328
329
330
331
332
333
334
335
// Generated using `moon info`, DON'T EDIT IT
package "oboard/mocket"
import {
"moonbitlang/core/buffer",
"oboard/mocket/native",
}
// Values
pub fn __ws_emit(@native.CStr, @native.CStr, @native.CStr) -> Unit
pub fn async_run(async () -> Unit noraise) -> Unit
pub fn cookie_to_string(Array[CookieItem]) -> String
pub async fn execute_middlewares(Array[(String, async (MocketEvent, async () -> &Responder noraise) -> &Responder noraise)], MocketEvent, async (MocketEvent) -> &Responder noraise) -> &Responder noraise
pub async fn fetch(String, body? : String, HttpMethod, data? : &Responder, headers? : Map[String, String], credentials? : FetchCredentials, mode? : FetchMode) -> HttpResponse
pub fn form_encode(Map[String, String]) -> String
pub fn handle_not_found() -> async (MocketEvent) -> &Responder noraise
pub fn html(&Show) -> &Responder
pub fn new(base_path? : String) -> Mocket
pub fn parse_cookie(StringView) -> Map[String, CookieItem]
pub fn parse_form_data(BytesView) -> Map[String, String]
pub fn parse_multipart(BytesView, String) -> Map[String, MultipartFormValue]
pub fn register_ws_handler(Mocket, Int) -> Unit
pub fn serve_ffi(Mocket, port~ : Int) -> Unit
pub async fn[T, E : Error] suspend(((T) -> Unit, (E) -> Unit) -> Unit) -> T raise E
pub fn text(&Show) -> &Responder
pub fn url_decode(BytesView) -> String
pub fn url_encode(String) -> String
pub fn ws_pong(String) -> Unit
pub fn ws_publish(String, String) -> Unit
pub fn ws_send(String, String) -> Unit
pub fn ws_send_bytes(String, Bytes) -> Unit
pub fn ws_subscribe(String, String) -> Unit
pub fn ws_unsubscribe(String, String) -> Unit
// Errors
pub suberror ExecError derive(Show)
pub suberror FetchError {
RequestFailed(String)
} derive(Show)
pub suberror IOError derive(Show)
pub suberror NetworkError derive(Show)
// Types and methods
pub(all) struct CookieItem {
name : String
value : String
max_age : Int?
path : String?
domain : String?
secure : Bool?
http_only : Bool?
same_site : SameSiteOption?
} derive(Eq)
pub impl Show for CookieItem
pub(all) enum FetchCredentials {
Omit
SameOrigin
Include
} derive(Eq, Show)
pub fn FetchCredentials::to_string(Self) -> String
pub(all) enum FetchMode {
Cors
NoCors
SameOrigin
Navigate
} derive(Eq, Show)
pub fn FetchMode::to_string(Self) -> String
type Html
pub impl Responder for Html
pub(all) enum HttpMethod {
GET
POST
PUT
PATCH
DELETE
HEAD
OPTIONS
TRACE
CONNECT
} derive(Eq, Show)
pub(all) struct HttpRequest {
http_method : String
url : String
headers : Map[StringView, StringView]
mut raw_body : Bytes
}
pub fn[T : BodyReader] HttpRequest::body(Self) -> T raise
pub fn HttpRequest::get_cookie(Self, String) -> CookieItem?
pub impl Responder for HttpRequest
#external
pub type HttpRequestInternal
pub fn HttpRequestInternal::on_complete(Self, FuncRef[() -> Unit]) -> Unit
pub fn HttpRequestInternal::on_headers(Self, FuncRef[(@native.CStr) -> Unit]) -> Unit
pub(all) struct HttpResponse {
mut status_code : StatusCode
headers : Map[StringView, StringView]
cookies : Map[String, CookieItem]
mut raw_body : Bytes
}
pub fn HttpResponse::body(Self, &Responder) -> Self
pub fn HttpResponse::delete_cookie(Self, String) -> Unit
pub fn HttpResponse::json(Self, &ToJson) -> Self
pub fn HttpResponse::new(StatusCode, headers? : Map[StringView, StringView], cookies? : Map[String, CookieItem], raw_body? : Bytes) -> Self
pub fn[T : BodyReader] HttpResponse::read_body(Self) -> T raise
pub fn HttpResponse::set_cookie(Self, String, String, max_age? : Int, path? : String, domain? : String, secure? : Bool, http_only? : Bool, same_site? : SameSiteOption) -> Unit
pub fn HttpResponse::to_responder(Self) -> &Responder
pub impl Responder for HttpResponse
#external
pub type HttpResponseInternal
#external
pub type HttpServerInternal
#alias(T)
pub(all) struct Mocket {
base_path : String
mappings : Map[(String, String), async (MocketEvent) -> &Responder noraise]
middlewares : Array[(String, async (MocketEvent, async () -> &Responder noraise) -> &Responder noraise)]
static_routes : Map[String, Map[String, async (MocketEvent) -> &Responder noraise]]
dynamic_routes : Map[String, Array[(String, async (MocketEvent) -> &Responder noraise)]]
ws_static_routes : Map[String, (WebSocketEvent) -> Unit]
ws_dynamic_routes : Array[(String, (WebSocketEvent) -> Unit)]
ws_clients : Map[String, Unit]
ws_channels : Map[String, Map[String, Unit]]
ws_client_port : Map[String, Int]
}
pub fn Mocket::all(Self, String, async (MocketEvent) -> &Responder noraise) -> Unit
pub fn Mocket::connect(Self, String, async (MocketEvent) -> &Responder noraise) -> Unit
pub fn Mocket::delete(Self, String, async (MocketEvent) -> &Responder noraise) -> Unit
pub fn Mocket::get(Self, String, async (MocketEvent) -> &Responder noraise) -> Unit
pub fn Mocket::group(Self, String, (Self) -> Unit) -> Unit
pub fn Mocket::head(Self, String, async (MocketEvent) -> &Responder noraise) -> Unit
pub fn Mocket::on(Self, String, String, async (MocketEvent) -> &Responder noraise) -> Unit
pub fn Mocket::options(Self, String, async (MocketEvent) -> &Responder noraise) -> Unit
pub fn Mocket::patch(Self, String, async (MocketEvent) -> &Responder noraise) -> Unit
pub fn Mocket::post(Self, String, async (MocketEvent) -> &Responder noraise) -> Unit
pub fn Mocket::put(Self, String, async (MocketEvent) -> &Responder noraise) -> Unit
pub fn Mocket::serve(Self, port~ : Int) -> Unit
pub fn Mocket::static_assets(Self, String, &ServeStaticProvider) -> Unit
pub fn Mocket::trace(Self, String, async (MocketEvent) -> &Responder noraise) -> Unit
pub fn Mocket::use_middleware(Self, async (MocketEvent, async () -> &Responder noraise) -> &Responder noraise, base_path? : String) -> Unit
pub fn Mocket::ws(Self, String, (WebSocketEvent) -> Unit) -> Unit
pub(all) struct MocketEvent {
req : HttpRequest
res : HttpResponse
params : Map[String, StringView]
}
pub(all) struct MultipartFormValue {
filename : String?
content_type : String?
data : BytesView
}
pub(all) enum SameSiteOption {
Lax
Strict
SameSiteNone
} derive(Eq, Show)
pub impl ToJson for SameSiteOption
pub(all) struct StaticAssetMeta {
asset_type : String?
etag : String?
mtime : Int64?
path : String?
size : Int64?
encoding : String?
}
pub fn StaticAssetMeta::new(asset_type? : String, etag? : String, mtime? : Int64, path? : String, size? : Int64, encoding? : String) -> Self
pub(all) enum StatusCode {
Continue
SwitchingProtocols
Processing
EarlyHints
OK
Created
Accepted
NonAuthoritativeInfo
NoContent
ResetContent
PartialContent
MultiStatus
AlreadyReported
IMUsed
MultipleChoices
MovedPermanently
Found
SeeOther
NotModified
UseProxy
TemporaryRedirect
PermanentRedirect
BadRequest
Unauthorized
PaymentRequired
Forbidden
NotFound
MethodNotAllowed
NotAcceptable
ProxyAuthRequired
RequestTimeout
Conflict
Gone
LengthRequired
PreconditionFailed
RequestEntityTooLarge
RequestUriTooLong
UnsupportedMediaType
RequestedRangeNotSatisfiable
ExpectationFailed
Teapot
MisdirectedRequest
UnprocessableEntity
Locked
FailedDependency
TooEarly
UpgradeRequired
PreconditionRequired
TooManyRequests
RequestHeaderFieldsTooLarge
UnavailableForLegalReasons
InternalServerError
NotImplemented
BadGateway
ServiceUnavailable
GatewayTimeout
HttpVersionNotSupported
VariantAlsoNegotiates
InsufficientStorage
LoopDetected
NotExtended
NetworkAuthenticationRequired
Custom(Int)
} derive(Eq, Show, ToJson)
pub fn StatusCode::from_int(Int) -> Self
pub fn StatusCode::to_int(Self) -> Int
pub enum WebSocketAggregatedMessage {
Text(String)
Binary(Bytes)
Ping
}
pub enum WebSocketEvent {
Open(WebSocketPeer)
Message(WebSocketPeer, WebSocketAggregatedMessage)
Close(WebSocketPeer)
}
pub(all) struct WebSocketPeer {
connection_id : String
mut subscribed_channels : Array[String]
}
pub fn WebSocketPeer::binary(Self, Bytes) -> Unit
pub fn WebSocketPeer::pong(Self) -> Unit
pub fn WebSocketPeer::publish(String, String) -> Unit
pub fn WebSocketPeer::subscribe(Self, String) -> Unit
pub fn WebSocketPeer::text(Self, String) -> Unit
pub fn WebSocketPeer::to_string(Self) -> String
pub fn WebSocketPeer::unsubscribe(Self, String) -> Unit
// Type aliases
pub type HttpHandler = async (MocketEvent) -> &Responder noraise
pub type Middleware = async (MocketEvent, async () -> &Responder noraise) -> &Responder noraise
pub type MiddlewareNext = async () -> &Responder noraise
pub type WebSocketHandler = (WebSocketEvent) -> Unit
// Traits
pub(open) trait BodyReader {
from_request(HttpRequest) -> Self raise
}
pub impl BodyReader for String
pub impl BodyReader for FixedArray[Byte]
pub impl BodyReader for Bytes
pub impl BodyReader for Array[Byte]
pub impl BodyReader for Json
pub(open) trait Responder {
options(Self, HttpResponse) -> Unit
output(Self, @buffer.Buffer) -> Unit
}
pub impl Responder for String
pub impl Responder for Bytes
pub impl Responder for Json
pub impl Responder for &ToJson
pub impl Responder for StringView
pub(open) trait ServeStaticProvider {
get_meta(Self, String) -> StaticAssetMeta?
get_contents(Self, String) -> &Responder
get_type(Self, String) -> String?
get_encodings(Self) -> Map[String, String]
get_index_names(Self) -> Array[String]
get_fallthrough(Self) -> Bool
}