ts-gen 0.1.0

Generate wasm-bindgen Rust bindings from TypeScript .d.ts files
Documentation
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
#[allow(unused_imports)]
use wasm_bindgen::prelude::*;
#[allow(unused_imports)]
use js_sys::*;
/// Extension trait for awaiting `js_sys::Promise<T>`.
///
/// Since `IntoFuture` can't be implemented for `js_sys::Promise` from
/// generated code (orphan rule), use `.into_future().await` instead:
/// ```ignore
/// use bindings::PromiseExt;
/// let data: ArrayBuffer = promise.into_future().await?;
/// ```
pub trait PromiseExt {
    type Output;
    fn into_future(self) -> wasm_bindgen_futures::JsFuture<Self::Output>;
}
impl<T: 'static + wasm_bindgen::convert::FromWasmAbi> PromiseExt for js_sys::Promise<T> {
    type Output = T;
    fn into_future(self) -> wasm_bindgen_futures::JsFuture<T> {
        wasm_bindgen_futures::JsFuture::from(self)
    }
}
#[allow(dead_code)]
use JsValue as Blob;
#[allow(dead_code)]
use JsValue as DurableObjectState;
#[allow(dead_code)]
use JsValue as FormData;
#[allow(dead_code)]
use JsValue as Headers;
#[allow(dead_code)]
use JsValue as Navigator;
#[allow(dead_code)]
use JsValue as ReadableStream;
#[allow(dead_code)]
use JsValue as RequestInfo;
#[allow(dead_code)]
use JsValue as RequestInit;
#[allow(dead_code)]
use JsValue as ServiceWorkerGlobalScope;
#[allow(dead_code)]
use JsValue as URLSearchParams;
#[allow(dead_code)]
use JsValue as WebSocket;
#[allow(dead_code)]
use JsValue as WritableStream;
#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(extends = Object)]
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub type DOMException;
    #[wasm_bindgen(constructor, catch)]
    pub fn new() -> Result<DOMException, JsValue>;
    #[wasm_bindgen(constructor, catch, js_name = "DOMException")]
    pub fn new_with_message(message: &str) -> Result<DOMException, JsValue>;
    #[wasm_bindgen(constructor, catch, js_name = "DOMException")]
    pub fn new_with_message_and_name(
        message: &str,
        name: &str,
    ) -> Result<DOMException, JsValue>;
    /// The error message.
    #[wasm_bindgen(method, getter)]
    pub fn message(this: &DOMException) -> String;
    #[wasm_bindgen(method, getter)]
    pub fn name(this: &DOMException) -> String;
    #[wasm_bindgen(method, getter)]
    pub fn code(this: &DOMException) -> f64;
}
#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(extends = Body, extends = Object)]
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub type Response;
    #[wasm_bindgen(constructor, catch)]
    pub fn new() -> Result<Response, JsValue>;
    #[wasm_bindgen(constructor, catch, js_name = "Response")]
    pub fn new_with_readable_stream(
        body: Option<&ReadableStream>,
    ) -> Result<Response, JsValue>;
    #[wasm_bindgen(constructor, catch, js_name = "Response")]
    pub fn new_with_str(body: Option<&str>) -> Result<Response, JsValue>;
    #[wasm_bindgen(constructor, catch, js_name = "Response")]
    pub fn new_with_array_buffer(
        body: Option<&ArrayBuffer>,
    ) -> Result<Response, JsValue>;
    #[wasm_bindgen(constructor, catch, js_name = "Response")]
    pub fn new_with_blob(body: Option<&Blob>) -> Result<Response, JsValue>;
    #[wasm_bindgen(constructor, catch, js_name = "Response")]
    pub fn new_with_url_search_params(
        body: Option<&URLSearchParams>,
    ) -> Result<Response, JsValue>;
    #[wasm_bindgen(constructor, catch, js_name = "Response")]
    pub fn new_with_form_data(body: Option<&FormData>) -> Result<Response, JsValue>;
    #[wasm_bindgen(constructor, catch, js_name = "Response")]
    pub fn new_with_readable_stream_and_init(
        body: Option<&ReadableStream>,
        init: &ResponseInit,
    ) -> Result<Response, JsValue>;
    #[wasm_bindgen(constructor, catch, js_name = "Response")]
    pub fn new_with_str_and_init(
        body: Option<&str>,
        init: &ResponseInit,
    ) -> Result<Response, JsValue>;
    #[wasm_bindgen(constructor, catch, js_name = "Response")]
    pub fn new_with_array_buffer_and_init(
        body: Option<&ArrayBuffer>,
        init: &ResponseInit,
    ) -> Result<Response, JsValue>;
    #[wasm_bindgen(constructor, catch, js_name = "Response")]
    pub fn new_with_blob_and_init(
        body: Option<&Blob>,
        init: &ResponseInit,
    ) -> Result<Response, JsValue>;
    #[wasm_bindgen(constructor, catch, js_name = "Response")]
    pub fn new_with_url_search_params_and_init(
        body: Option<&URLSearchParams>,
        init: &ResponseInit,
    ) -> Result<Response, JsValue>;
    #[wasm_bindgen(constructor, catch, js_name = "Response")]
    pub fn new_with_form_data_and_init(
        body: Option<&FormData>,
        init: &ResponseInit,
    ) -> Result<Response, JsValue>;
    /// Returns a new Response with a network error.
    #[wasm_bindgen(static_method_of = Response)]
    pub fn error() -> Response;
    #[wasm_bindgen(static_method_of = Response, catch, js_name = "error")]
    pub fn try_error() -> Result<Response, JsValue>;
    #[wasm_bindgen(static_method_of = Response)]
    pub fn redirect(url: &str) -> Response;
    #[wasm_bindgen(static_method_of = Response, catch, js_name = "redirect")]
    pub fn try_redirect(url: &str) -> Result<Response, JsValue>;
    #[wasm_bindgen(static_method_of = Response, js_name = "redirect")]
    pub fn redirect_with_status(url: &str, status: f64) -> Response;
    #[wasm_bindgen(static_method_of = Response, catch, js_name = "redirect")]
    pub fn try_redirect_with_status(url: &str, status: f64) -> Result<Response, JsValue>;
    #[wasm_bindgen(static_method_of = Response)]
    pub fn json(any: &JsValue) -> Response;
    #[wasm_bindgen(static_method_of = Response, catch, js_name = "json")]
    pub fn try_json(any: &JsValue) -> Result<Response, JsValue>;
    #[wasm_bindgen(static_method_of = Response, js_name = "json")]
    pub fn json_with_response_init(any: &JsValue, maybe_init: &ResponseInit) -> Response;
    #[wasm_bindgen(static_method_of = Response, catch, js_name = "json")]
    pub fn try_json_with_response_init(
        any: &JsValue,
        maybe_init: &ResponseInit,
    ) -> Result<Response, JsValue>;
    #[wasm_bindgen(static_method_of = Response, js_name = "json")]
    pub fn json_with_response(any: &JsValue, maybe_init: &Response) -> Response;
    #[wasm_bindgen(static_method_of = Response, catch, js_name = "json")]
    pub fn try_json_with_response(
        any: &JsValue,
        maybe_init: &Response,
    ) -> Result<Response, JsValue>;
    /// Creates a clone of this response.
    #[wasm_bindgen(method)]
    pub fn clone(this: &Response) -> Response;
    #[wasm_bindgen(method, catch, js_name = "clone")]
    pub fn try_clone(this: &Response) -> Result<Response, JsValue>;
    /// The HTTP status code.
    #[wasm_bindgen(method, getter)]
    pub fn status(this: &Response) -> f64;
    #[wasm_bindgen(method, getter, js_name = "statusText")]
    pub fn status_text(this: &Response) -> String;
    #[wasm_bindgen(method, getter)]
    pub fn headers(this: &Response) -> Headers;
    #[wasm_bindgen(method, getter)]
    pub fn ok(this: &Response) -> bool;
    #[wasm_bindgen(method, getter)]
    pub fn url(this: &Response) -> String;
    #[wasm_bindgen(method, getter)]
    pub fn body(this: &Response) -> Option<ReadableStream>;
}
#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(extends = Object)]
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub type Body;
    #[wasm_bindgen(method, getter)]
    pub fn body(this: &Body) -> Option<ReadableStream>;
    #[wasm_bindgen(method, getter, js_name = "bodyUsed")]
    pub fn body_used(this: &Body) -> bool;
    /// Returns the body as an ArrayBuffer.
    #[wasm_bindgen(method, js_name = "arrayBuffer")]
    pub fn array_buffer(this: &Body) -> Promise<ArrayBuffer>;
    #[wasm_bindgen(method, catch, js_name = "arrayBuffer")]
    pub fn try_array_buffer(this: &Body) -> Result<Promise<ArrayBuffer>, JsValue>;
    #[wasm_bindgen(method)]
    pub fn text(this: &Body) -> Promise<JsString>;
    #[wasm_bindgen(method, catch, js_name = "text")]
    pub fn try_text(this: &Body) -> Result<Promise<JsString>, JsValue>;
    #[wasm_bindgen(method)]
    pub fn json(this: &Body) -> Promise;
    #[wasm_bindgen(method, catch, js_name = "json")]
    pub fn try_json(this: &Body) -> Result<Promise, JsValue>;
    #[wasm_bindgen(method)]
    pub fn blob(this: &Body) -> Promise<Blob>;
    #[wasm_bindgen(method, catch, js_name = "blob")]
    pub fn try_blob(this: &Body) -> Result<Promise<Blob>, JsValue>;
    #[wasm_bindgen(method, js_name = "formData")]
    pub fn form_data(this: &Body) -> Promise<FormData>;
    #[wasm_bindgen(method, catch, js_name = "formData")]
    pub fn try_form_data(this: &Body) -> Result<Promise<FormData>, JsValue>;
}
#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(extends = Object)]
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub type ResponseInit;
    #[wasm_bindgen(method, getter)]
    pub fn status(this: &ResponseInit) -> Option<f64>;
    #[wasm_bindgen(method, setter)]
    pub fn set_status(this: &ResponseInit, val: f64);
    #[wasm_bindgen(method, getter, js_name = "statusText")]
    pub fn status_text(this: &ResponseInit) -> Option<String>;
    #[wasm_bindgen(method, setter, js_name = "statusText")]
    pub fn set_status_text(this: &ResponseInit, val: &str);
    #[wasm_bindgen(method, getter)]
    pub fn headers(this: &ResponseInit) -> Option<JsValue>;
    #[wasm_bindgen(method, setter)]
    pub fn set_headers(this: &ResponseInit, val: &Headers);
    #[wasm_bindgen(method, setter, js_name = "headers")]
    pub fn set_headers_with_array(this: &ResponseInit, val: &Array<Array<JsString>>);
    #[wasm_bindgen(method, setter, js_name = "headers")]
    pub fn set_headers_with_record(this: &ResponseInit, val: &Object<JsString>);
}
impl ResponseInit {
    #[allow(clippy::new_without_default)]
    pub fn new() -> Self {
        #[allow(unused_imports)]
        use wasm_bindgen::JsCast;
        JsCast::unchecked_into(js_sys::Object::new())
    }
    pub fn builder() -> ResponseInitBuilder {
        ResponseInitBuilder {
            inner: Self::new(),
        }
    }
}
pub struct ResponseInitBuilder {
    inner: ResponseInit,
}
#[allow(unused_mut)]
impl ResponseInitBuilder {
    pub fn status(mut self, val: f64) -> Self {
        self.inner.set_status(val);
        self
    }
    pub fn status_text(mut self, val: &str) -> Self {
        self.inner.set_status_text(val);
        self
    }
    pub fn headers(mut self, val: &Headers) -> Self {
        self.inner.set_headers(val);
        self
    }
    pub fn headers_with_array(mut self, val: &Array<Array<JsString>>) -> Self {
        self.inner.set_headers_with_array(val);
        self
    }
    pub fn headers_with_record(mut self, val: &Object<JsString>) -> Self {
        self.inner.set_headers_with_record(val);
        self
    }
    pub fn build(self) -> ResponseInit {
        self.inner
    }
}
#[wasm_bindgen]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum QueueContentType {
    #[wasm_bindgen(js_name = "text")]
    Text,
    #[wasm_bindgen(js_name = "bytes")]
    Bytes,
    #[wasm_bindgen(js_name = "json")]
    Json,
    #[wasm_bindgen(js_name = "v8")]
    V8,
}
#[allow(dead_code)]
pub type BodyInit = JsValue;
#[allow(dead_code)]
pub type HeadersInit = JsValue;
#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(extends = Object)]
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub type DurableObject;
    #[wasm_bindgen(method, getter)]
    pub fn ctx(this: &DurableObject) -> DurableObjectState;
    #[wasm_bindgen(method, setter)]
    pub fn set_ctx(this: &DurableObject, val: &DurableObjectState);
    #[wasm_bindgen(method, getter)]
    pub fn env(this: &DurableObject) -> Object;
    #[wasm_bindgen(method, setter)]
    pub fn set_env(this: &DurableObject, val: &Object);
    #[wasm_bindgen(method)]
    pub fn alarm(this: &DurableObject) -> Promise<Undefined>;
    #[wasm_bindgen(method, catch, js_name = "alarm")]
    pub fn try_alarm(this: &DurableObject) -> Result<Promise<Undefined>, JsValue>;
    #[wasm_bindgen(method, js_name = "webSocketMessage")]
    pub fn web_socket_message(
        this: &DurableObject,
        ws: &WebSocket,
        message: &str,
    ) -> Promise<Undefined>;
    #[wasm_bindgen(method, catch, js_name = "webSocketMessage")]
    pub fn try_web_socket_message(
        this: &DurableObject,
        ws: &WebSocket,
        message: &str,
    ) -> Result<Promise<Undefined>, JsValue>;
    #[wasm_bindgen(method, js_name = "webSocketMessage")]
    pub fn web_socket_message_with_array_buffer(
        this: &DurableObject,
        ws: &WebSocket,
        message: &ArrayBuffer,
    ) -> Promise<Undefined>;
    #[wasm_bindgen(method, catch, js_name = "webSocketMessage")]
    pub fn try_web_socket_message_with_array_buffer(
        this: &DurableObject,
        ws: &WebSocket,
        message: &ArrayBuffer,
    ) -> Result<Promise<Undefined>, JsValue>;
}
pub mod web_assembly {
    use wasm_bindgen::prelude::*;
    #[wasm_bindgen]
    extern "C" {
        #[wasm_bindgen(extends = Object, js_namespace = "WebAssembly")]
        #[derive(Debug, Clone, PartialEq, Eq)]
        pub type Module;
        #[wasm_bindgen(constructor, catch)]
        pub fn new(bytes: &ArrayBuffer) -> Result<Module, JsValue>;
    }
    #[wasm_bindgen]
    extern "C" {
        #[wasm_bindgen(extends = Object, js_namespace = "WebAssembly")]
        #[derive(Debug, Clone, PartialEq, Eq)]
        pub type Instance;
        #[wasm_bindgen(constructor, catch)]
        pub fn new(module: &Module) -> Result<Instance, JsValue>;
        #[wasm_bindgen(constructor, catch, js_name = "Instance")]
        pub fn new_with_imports(
            module: &Module,
            imports: &Object,
        ) -> Result<Instance, JsValue>;
        #[wasm_bindgen(method, getter)]
        pub fn exports(this: &Instance) -> Object;
    }
    #[wasm_bindgen]
    extern "C" {
        #[wasm_bindgen(js_namespace = "WebAssembly")]
        pub fn compile(bytes: &ArrayBuffer) -> Promise<Module>;
    }
    #[wasm_bindgen]
    extern "C" {
        #[wasm_bindgen(catch, js_name = "compile", js_namespace = "WebAssembly")]
        pub fn try_compile(bytes: &ArrayBuffer) -> Result<Promise<Module>, JsValue>;
    }
    #[wasm_bindgen]
    extern "C" {
        #[wasm_bindgen(js_namespace = "WebAssembly")]
        pub fn instantiate(module: &Module) -> Promise<Instance>;
    }
    #[wasm_bindgen]
    extern "C" {
        #[wasm_bindgen(catch, js_name = "instantiate", js_namespace = "WebAssembly")]
        pub fn try_instantiate(module: &Module) -> Result<Promise<Instance>, JsValue>;
    }
    #[wasm_bindgen]
    extern "C" {
        #[wasm_bindgen(js_name = "instantiate", js_namespace = "WebAssembly")]
        pub fn instantiate_with_imports(
            module: &Module,
            imports: &Object,
        ) -> Promise<Instance>;
    }
    #[wasm_bindgen]
    extern "C" {
        #[wasm_bindgen(catch, js_name = "instantiate", js_namespace = "WebAssembly")]
        pub fn try_instantiate_with_imports(
            module: &Module,
            imports: &Object,
        ) -> Result<Promise<Instance>, JsValue>;
    }
}
#[wasm_bindgen]
extern "C" {
    pub fn fetch(input: &RequestInfo) -> Promise<Response>;
}
#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(catch, js_name = "fetch")]
    pub fn try_fetch(input: &RequestInfo) -> Result<Promise<Response>, JsValue>;
}
#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(js_name = "fetch")]
    pub fn fetch_with_init(input: &RequestInfo, init: &RequestInit) -> Promise<Response>;
}
#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(catch, js_name = "fetch")]
    pub fn try_fetch_with_init(
        input: &RequestInfo,
        init: &RequestInit,
    ) -> Result<Promise<Response>, JsValue>;
}
#[wasm_bindgen]
extern "C" {
    pub fn atob(data: &str) -> String;
}
#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(catch, js_name = "atob")]
    pub fn try_atob(data: &str) -> Result<String, JsValue>;
}
#[wasm_bindgen]
extern "C" {
    pub fn btoa(data: &str) -> String;
}
#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(catch, js_name = "btoa")]
    pub fn try_btoa(data: &str) -> Result<String, JsValue>;
}
#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(thread_local_v2)]
    pub static navigator: Navigator;
}
#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(thread_local_v2)]
    pub static self_: ServiceWorkerGlobalScope;
}
pub mod sockets {
    use wasm_bindgen::prelude::*;
    use js_sys::*;
    use super::*;
    #[wasm_bindgen(module = "cloudflare:sockets")]
    extern "C" {
        pub fn connect(address: &str) -> Socket;
    }
    #[wasm_bindgen(module = "cloudflare:sockets")]
    extern "C" {
        #[wasm_bindgen(catch, js_name = "connect")]
        pub fn try_connect(address: &str) -> Result<Socket, JsValue>;
    }
    #[wasm_bindgen(module = "cloudflare:sockets")]
    extern "C" {
        #[wasm_bindgen(js_name = "connect")]
        pub fn connect_with_options(address: &str, options: &SocketOptions) -> Socket;
    }
    #[wasm_bindgen(module = "cloudflare:sockets")]
    extern "C" {
        #[wasm_bindgen(catch, js_name = "connect")]
        pub fn try_connect_with_options(
            address: &str,
            options: &SocketOptions,
        ) -> Result<Socket, JsValue>;
    }
    #[wasm_bindgen(module = "cloudflare:sockets")]
    extern "C" {
        #[wasm_bindgen(extends = Object)]
        #[derive(Debug, Clone, PartialEq, Eq)]
        pub type Socket;
        #[wasm_bindgen(method)]
        pub fn close(this: &Socket) -> Promise<Undefined>;
        #[wasm_bindgen(method, catch, js_name = "close")]
        pub fn try_close(this: &Socket) -> Result<Promise<Undefined>, JsValue>;
        #[wasm_bindgen(method, getter)]
        pub fn closed(this: &Socket) -> Promise<Undefined>;
        #[wasm_bindgen(method, getter)]
        pub fn opened(this: &Socket) -> Promise<Undefined>;
        #[wasm_bindgen(method, getter)]
        pub fn readable(this: &Socket) -> ReadableStream;
        #[wasm_bindgen(method, getter)]
        pub fn writable(this: &Socket) -> WritableStream;
        #[wasm_bindgen(method, js_name = "startTls")]
        pub fn start_tls(this: &Socket) -> Socket;
        #[wasm_bindgen(method, catch, js_name = "startTls")]
        pub fn try_start_tls(this: &Socket) -> Result<Socket, JsValue>;
    }
    #[wasm_bindgen(module = "cloudflare:sockets")]
    extern "C" {
        #[wasm_bindgen(extends = Object)]
        #[derive(Debug, Clone, PartialEq, Eq)]
        pub type SocketOptions;
        #[wasm_bindgen(method, getter, js_name = "secureTransport")]
        pub fn secure_transport(this: &SocketOptions) -> Option<String>;
        #[wasm_bindgen(method, setter, js_name = "secureTransport")]
        pub fn set_secure_transport(this: &SocketOptions, val: &str);
        #[wasm_bindgen(method, getter, js_name = "allowHalfOpen")]
        pub fn allow_half_open(this: &SocketOptions) -> Option<bool>;
        #[wasm_bindgen(method, setter, js_name = "allowHalfOpen")]
        pub fn set_allow_half_open(this: &SocketOptions, val: bool);
    }
    impl SocketOptions {
        #[allow(clippy::new_without_default)]
        pub fn new() -> Self {
            #[allow(unused_imports)]
            use wasm_bindgen::JsCast;
            JsCast::unchecked_into(js_sys::Object::new())
        }
        pub fn builder() -> SocketOptionsBuilder {
            SocketOptionsBuilder {
                inner: Self::new(),
            }
        }
    }
    pub struct SocketOptionsBuilder {
        inner: SocketOptions,
    }
    #[allow(unused_mut)]
    impl SocketOptionsBuilder {
        pub fn secure_transport(mut self, val: &str) -> Self {
            self.inner.set_secure_transport(val);
            self
        }
        pub fn allow_half_open(mut self, val: bool) -> Self {
            self.inner.set_allow_half_open(val);
            self
        }
        pub fn build(self) -> SocketOptions {
            self.inner
        }
    }
}