Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/component-macro/tests/expanded/integers_async.rs
1692 views
1
/// Auto-generated bindings for a pre-instantiated version of a
2
/// component which implements the world `the-world`.
3
///
4
/// This structure is created through [`TheWorldPre::new`] which
5
/// takes a [`InstancePre`](wasmtime::component::InstancePre) that
6
/// has been created through a [`Linker`](wasmtime::component::Linker).
7
///
8
/// For more information see [`TheWorld`] as well.
9
pub struct TheWorldPre<T: 'static> {
10
instance_pre: wasmtime::component::InstancePre<T>,
11
indices: TheWorldIndices,
12
}
13
impl<T: 'static> Clone for TheWorldPre<T> {
14
fn clone(&self) -> Self {
15
Self {
16
instance_pre: self.instance_pre.clone(),
17
indices: self.indices.clone(),
18
}
19
}
20
}
21
impl<_T: 'static> TheWorldPre<_T> {
22
/// Creates a new copy of `TheWorldPre` bindings which can then
23
/// be used to instantiate into a particular store.
24
///
25
/// This method may fail if the component behind `instance_pre`
26
/// does not have the required exports.
27
pub fn new(
28
instance_pre: wasmtime::component::InstancePre<_T>,
29
) -> wasmtime::Result<Self> {
30
let indices = TheWorldIndices::new(&instance_pre)?;
31
Ok(Self { instance_pre, indices })
32
}
33
pub fn engine(&self) -> &wasmtime::Engine {
34
self.instance_pre.engine()
35
}
36
pub fn instance_pre(&self) -> &wasmtime::component::InstancePre<_T> {
37
&self.instance_pre
38
}
39
/// Instantiates a new instance of [`TheWorld`] within the
40
/// `store` provided.
41
///
42
/// This function will use `self` as the pre-instantiated
43
/// instance to perform instantiation. Afterwards the preloaded
44
/// indices in `self` are used to lookup all exports on the
45
/// resulting instance.
46
pub fn instantiate(
47
&self,
48
mut store: impl wasmtime::AsContextMut<Data = _T>,
49
) -> wasmtime::Result<TheWorld> {
50
let mut store = store.as_context_mut();
51
let instance = self.instance_pre.instantiate(&mut store)?;
52
self.indices.load(&mut store, &instance)
53
}
54
}
55
impl<_T: Send + 'static> TheWorldPre<_T> {
56
/// Same as [`Self::instantiate`], except with `async`.
57
pub async fn instantiate_async(
58
&self,
59
mut store: impl wasmtime::AsContextMut<Data = _T>,
60
) -> wasmtime::Result<TheWorld> {
61
let mut store = store.as_context_mut();
62
let instance = self.instance_pre.instantiate_async(&mut store).await?;
63
self.indices.load(&mut store, &instance)
64
}
65
}
66
/// Auto-generated bindings for index of the exports of
67
/// `the-world`.
68
///
69
/// This is an implementation detail of [`TheWorldPre`] and can
70
/// be constructed if needed as well.
71
///
72
/// For more information see [`TheWorld`] as well.
73
#[derive(Clone)]
74
pub struct TheWorldIndices {
75
interface0: exports::foo::foo::integers::GuestIndices,
76
}
77
/// Auto-generated bindings for an instance a component which
78
/// implements the world `the-world`.
79
///
80
/// This structure can be created through a number of means
81
/// depending on your requirements and what you have on hand:
82
///
83
/// * The most convenient way is to use
84
/// [`TheWorld::instantiate`] which only needs a
85
/// [`Store`], [`Component`], and [`Linker`].
86
///
87
/// * Alternatively you can create a [`TheWorldPre`] ahead of
88
/// time with a [`Component`] to front-load string lookups
89
/// of exports once instead of per-instantiation. This
90
/// method then uses [`TheWorldPre::instantiate`] to
91
/// create a [`TheWorld`].
92
///
93
/// * If you've instantiated the instance yourself already
94
/// then you can use [`TheWorld::new`].
95
///
96
/// These methods are all equivalent to one another and move
97
/// around the tradeoff of what work is performed when.
98
///
99
/// [`Store`]: wasmtime::Store
100
/// [`Component`]: wasmtime::component::Component
101
/// [`Linker`]: wasmtime::component::Linker
102
pub struct TheWorld {
103
interface0: exports::foo::foo::integers::Guest,
104
}
105
const _: () = {
106
#[allow(unused_imports)]
107
use wasmtime::component::__internal::anyhow;
108
impl TheWorldIndices {
109
/// Creates a new copy of `TheWorldIndices` bindings which can then
110
/// be used to instantiate into a particular store.
111
///
112
/// This method may fail if the component does not have the
113
/// required exports.
114
pub fn new<_T>(
115
_instance_pre: &wasmtime::component::InstancePre<_T>,
116
) -> wasmtime::Result<Self> {
117
let _component = _instance_pre.component();
118
let _instance_type = _instance_pre.instance_type();
119
let interface0 = exports::foo::foo::integers::GuestIndices::new(
120
_instance_pre,
121
)?;
122
Ok(TheWorldIndices { interface0 })
123
}
124
/// Uses the indices stored in `self` to load an instance
125
/// of [`TheWorld`] from the instance provided.
126
///
127
/// Note that at this time this method will additionally
128
/// perform type-checks of all exports.
129
pub fn load(
130
&self,
131
mut store: impl wasmtime::AsContextMut,
132
instance: &wasmtime::component::Instance,
133
) -> wasmtime::Result<TheWorld> {
134
let _ = &mut store;
135
let _instance = instance;
136
let interface0 = self.interface0.load(&mut store, &_instance)?;
137
Ok(TheWorld { interface0 })
138
}
139
}
140
impl TheWorld {
141
/// Convenience wrapper around [`TheWorldPre::new`] and
142
/// [`TheWorldPre::instantiate`].
143
pub fn instantiate<_T>(
144
store: impl wasmtime::AsContextMut<Data = _T>,
145
component: &wasmtime::component::Component,
146
linker: &wasmtime::component::Linker<_T>,
147
) -> wasmtime::Result<TheWorld> {
148
let pre = linker.instantiate_pre(component)?;
149
TheWorldPre::new(pre)?.instantiate(store)
150
}
151
/// Convenience wrapper around [`TheWorldIndices::new`] and
152
/// [`TheWorldIndices::load`].
153
pub fn new(
154
mut store: impl wasmtime::AsContextMut,
155
instance: &wasmtime::component::Instance,
156
) -> wasmtime::Result<TheWorld> {
157
let indices = TheWorldIndices::new(&instance.instance_pre(&store))?;
158
indices.load(&mut store, instance)
159
}
160
/// Convenience wrapper around [`TheWorldPre::new`] and
161
/// [`TheWorldPre::instantiate_async`].
162
pub async fn instantiate_async<_T>(
163
store: impl wasmtime::AsContextMut<Data = _T>,
164
component: &wasmtime::component::Component,
165
linker: &wasmtime::component::Linker<_T>,
166
) -> wasmtime::Result<TheWorld>
167
where
168
_T: Send,
169
{
170
let pre = linker.instantiate_pre(component)?;
171
TheWorldPre::new(pre)?.instantiate_async(store).await
172
}
173
pub fn add_to_linker<T, D>(
174
linker: &mut wasmtime::component::Linker<T>,
175
host_getter: fn(&mut T) -> D::Data<'_>,
176
) -> wasmtime::Result<()>
177
where
178
D: foo::foo::integers::HostWithStore + Send,
179
for<'a> D::Data<'a>: foo::foo::integers::Host + Send,
180
T: 'static + Send,
181
{
182
foo::foo::integers::add_to_linker::<T, D>(linker, host_getter)?;
183
Ok(())
184
}
185
pub fn foo_foo_integers(&self) -> &exports::foo::foo::integers::Guest {
186
&self.interface0
187
}
188
}
189
};
190
pub mod foo {
191
pub mod foo {
192
#[allow(clippy::all)]
193
pub mod integers {
194
#[allow(unused_imports)]
195
use wasmtime::component::__internal::{anyhow, Box};
196
pub trait HostWithStore: wasmtime::component::HasData + Send {}
197
impl<_T: ?Sized> HostWithStore for _T
198
where
199
_T: wasmtime::component::HasData + Send,
200
{}
201
pub trait Host: Send {
202
fn a1(
203
&mut self,
204
x: u8,
205
) -> impl ::core::future::Future<Output = ()> + Send;
206
fn a2(
207
&mut self,
208
x: i8,
209
) -> impl ::core::future::Future<Output = ()> + Send;
210
fn a3(
211
&mut self,
212
x: u16,
213
) -> impl ::core::future::Future<Output = ()> + Send;
214
fn a4(
215
&mut self,
216
x: i16,
217
) -> impl ::core::future::Future<Output = ()> + Send;
218
fn a5(
219
&mut self,
220
x: u32,
221
) -> impl ::core::future::Future<Output = ()> + Send;
222
fn a6(
223
&mut self,
224
x: i32,
225
) -> impl ::core::future::Future<Output = ()> + Send;
226
fn a7(
227
&mut self,
228
x: u64,
229
) -> impl ::core::future::Future<Output = ()> + Send;
230
fn a8(
231
&mut self,
232
x: i64,
233
) -> impl ::core::future::Future<Output = ()> + Send;
234
fn a9(
235
&mut self,
236
p1: u8,
237
p2: i8,
238
p3: u16,
239
p4: i16,
240
p5: u32,
241
p6: i32,
242
p7: u64,
243
p8: i64,
244
) -> impl ::core::future::Future<Output = ()> + Send;
245
fn r1(&mut self) -> impl ::core::future::Future<Output = u8> + Send;
246
fn r2(&mut self) -> impl ::core::future::Future<Output = i8> + Send;
247
fn r3(&mut self) -> impl ::core::future::Future<Output = u16> + Send;
248
fn r4(&mut self) -> impl ::core::future::Future<Output = i16> + Send;
249
fn r5(&mut self) -> impl ::core::future::Future<Output = u32> + Send;
250
fn r6(&mut self) -> impl ::core::future::Future<Output = i32> + Send;
251
fn r7(&mut self) -> impl ::core::future::Future<Output = u64> + Send;
252
fn r8(&mut self) -> impl ::core::future::Future<Output = i64> + Send;
253
fn pair_ret(
254
&mut self,
255
) -> impl ::core::future::Future<Output = (i64, u8)> + Send;
256
}
257
impl<_T: Host + ?Sized + Send> Host for &mut _T {
258
fn a1(
259
&mut self,
260
x: u8,
261
) -> impl ::core::future::Future<Output = ()> + Send {
262
async move { Host::a1(*self, x).await }
263
}
264
fn a2(
265
&mut self,
266
x: i8,
267
) -> impl ::core::future::Future<Output = ()> + Send {
268
async move { Host::a2(*self, x).await }
269
}
270
fn a3(
271
&mut self,
272
x: u16,
273
) -> impl ::core::future::Future<Output = ()> + Send {
274
async move { Host::a3(*self, x).await }
275
}
276
fn a4(
277
&mut self,
278
x: i16,
279
) -> impl ::core::future::Future<Output = ()> + Send {
280
async move { Host::a4(*self, x).await }
281
}
282
fn a5(
283
&mut self,
284
x: u32,
285
) -> impl ::core::future::Future<Output = ()> + Send {
286
async move { Host::a5(*self, x).await }
287
}
288
fn a6(
289
&mut self,
290
x: i32,
291
) -> impl ::core::future::Future<Output = ()> + Send {
292
async move { Host::a6(*self, x).await }
293
}
294
fn a7(
295
&mut self,
296
x: u64,
297
) -> impl ::core::future::Future<Output = ()> + Send {
298
async move { Host::a7(*self, x).await }
299
}
300
fn a8(
301
&mut self,
302
x: i64,
303
) -> impl ::core::future::Future<Output = ()> + Send {
304
async move { Host::a8(*self, x).await }
305
}
306
fn a9(
307
&mut self,
308
p1: u8,
309
p2: i8,
310
p3: u16,
311
p4: i16,
312
p5: u32,
313
p6: i32,
314
p7: u64,
315
p8: i64,
316
) -> impl ::core::future::Future<Output = ()> + Send {
317
async move { Host::a9(*self, p1, p2, p3, p4, p5, p6, p7, p8).await }
318
}
319
fn r1(&mut self) -> impl ::core::future::Future<Output = u8> + Send {
320
async move { Host::r1(*self).await }
321
}
322
fn r2(&mut self) -> impl ::core::future::Future<Output = i8> + Send {
323
async move { Host::r2(*self).await }
324
}
325
fn r3(&mut self) -> impl ::core::future::Future<Output = u16> + Send {
326
async move { Host::r3(*self).await }
327
}
328
fn r4(&mut self) -> impl ::core::future::Future<Output = i16> + Send {
329
async move { Host::r4(*self).await }
330
}
331
fn r5(&mut self) -> impl ::core::future::Future<Output = u32> + Send {
332
async move { Host::r5(*self).await }
333
}
334
fn r6(&mut self) -> impl ::core::future::Future<Output = i32> + Send {
335
async move { Host::r6(*self).await }
336
}
337
fn r7(&mut self) -> impl ::core::future::Future<Output = u64> + Send {
338
async move { Host::r7(*self).await }
339
}
340
fn r8(&mut self) -> impl ::core::future::Future<Output = i64> + Send {
341
async move { Host::r8(*self).await }
342
}
343
fn pair_ret(
344
&mut self,
345
) -> impl ::core::future::Future<Output = (i64, u8)> + Send {
346
async move { Host::pair_ret(*self).await }
347
}
348
}
349
pub fn add_to_linker<T, D>(
350
linker: &mut wasmtime::component::Linker<T>,
351
host_getter: fn(&mut T) -> D::Data<'_>,
352
) -> wasmtime::Result<()>
353
where
354
D: HostWithStore,
355
for<'a> D::Data<'a>: Host,
356
T: 'static + Send,
357
{
358
let mut inst = linker.instance("foo:foo/integers")?;
359
inst.func_wrap_async(
360
"a1",
361
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u8,)| {
362
wasmtime::component::__internal::Box::new(async move {
363
let host = &mut host_getter(caller.data_mut());
364
let r = Host::a1(host, arg0).await;
365
Ok(r)
366
})
367
},
368
)?;
369
inst.func_wrap_async(
370
"a2",
371
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i8,)| {
372
wasmtime::component::__internal::Box::new(async move {
373
let host = &mut host_getter(caller.data_mut());
374
let r = Host::a2(host, arg0).await;
375
Ok(r)
376
})
377
},
378
)?;
379
inst.func_wrap_async(
380
"a3",
381
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u16,)| {
382
wasmtime::component::__internal::Box::new(async move {
383
let host = &mut host_getter(caller.data_mut());
384
let r = Host::a3(host, arg0).await;
385
Ok(r)
386
})
387
},
388
)?;
389
inst.func_wrap_async(
390
"a4",
391
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i16,)| {
392
wasmtime::component::__internal::Box::new(async move {
393
let host = &mut host_getter(caller.data_mut());
394
let r = Host::a4(host, arg0).await;
395
Ok(r)
396
})
397
},
398
)?;
399
inst.func_wrap_async(
400
"a5",
401
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u32,)| {
402
wasmtime::component::__internal::Box::new(async move {
403
let host = &mut host_getter(caller.data_mut());
404
let r = Host::a5(host, arg0).await;
405
Ok(r)
406
})
407
},
408
)?;
409
inst.func_wrap_async(
410
"a6",
411
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i32,)| {
412
wasmtime::component::__internal::Box::new(async move {
413
let host = &mut host_getter(caller.data_mut());
414
let r = Host::a6(host, arg0).await;
415
Ok(r)
416
})
417
},
418
)?;
419
inst.func_wrap_async(
420
"a7",
421
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u64,)| {
422
wasmtime::component::__internal::Box::new(async move {
423
let host = &mut host_getter(caller.data_mut());
424
let r = Host::a7(host, arg0).await;
425
Ok(r)
426
})
427
},
428
)?;
429
inst.func_wrap_async(
430
"a8",
431
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i64,)| {
432
wasmtime::component::__internal::Box::new(async move {
433
let host = &mut host_getter(caller.data_mut());
434
let r = Host::a8(host, arg0).await;
435
Ok(r)
436
})
437
},
438
)?;
439
inst.func_wrap_async(
440
"a9",
441
move |
442
mut caller: wasmtime::StoreContextMut<'_, T>,
443
(
444
arg0,
445
arg1,
446
arg2,
447
arg3,
448
arg4,
449
arg5,
450
arg6,
451
arg7,
452
): (u8, i8, u16, i16, u32, i32, u64, i64)|
453
{
454
wasmtime::component::__internal::Box::new(async move {
455
let host = &mut host_getter(caller.data_mut());
456
let r = Host::a9(
457
host,
458
arg0,
459
arg1,
460
arg2,
461
arg3,
462
arg4,
463
arg5,
464
arg6,
465
arg7,
466
)
467
.await;
468
Ok(r)
469
})
470
},
471
)?;
472
inst.func_wrap_async(
473
"r1",
474
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
475
wasmtime::component::__internal::Box::new(async move {
476
let host = &mut host_getter(caller.data_mut());
477
let r = Host::r1(host).await;
478
Ok((r,))
479
})
480
},
481
)?;
482
inst.func_wrap_async(
483
"r2",
484
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
485
wasmtime::component::__internal::Box::new(async move {
486
let host = &mut host_getter(caller.data_mut());
487
let r = Host::r2(host).await;
488
Ok((r,))
489
})
490
},
491
)?;
492
inst.func_wrap_async(
493
"r3",
494
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
495
wasmtime::component::__internal::Box::new(async move {
496
let host = &mut host_getter(caller.data_mut());
497
let r = Host::r3(host).await;
498
Ok((r,))
499
})
500
},
501
)?;
502
inst.func_wrap_async(
503
"r4",
504
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
505
wasmtime::component::__internal::Box::new(async move {
506
let host = &mut host_getter(caller.data_mut());
507
let r = Host::r4(host).await;
508
Ok((r,))
509
})
510
},
511
)?;
512
inst.func_wrap_async(
513
"r5",
514
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
515
wasmtime::component::__internal::Box::new(async move {
516
let host = &mut host_getter(caller.data_mut());
517
let r = Host::r5(host).await;
518
Ok((r,))
519
})
520
},
521
)?;
522
inst.func_wrap_async(
523
"r6",
524
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
525
wasmtime::component::__internal::Box::new(async move {
526
let host = &mut host_getter(caller.data_mut());
527
let r = Host::r6(host).await;
528
Ok((r,))
529
})
530
},
531
)?;
532
inst.func_wrap_async(
533
"r7",
534
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
535
wasmtime::component::__internal::Box::new(async move {
536
let host = &mut host_getter(caller.data_mut());
537
let r = Host::r7(host).await;
538
Ok((r,))
539
})
540
},
541
)?;
542
inst.func_wrap_async(
543
"r8",
544
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
545
wasmtime::component::__internal::Box::new(async move {
546
let host = &mut host_getter(caller.data_mut());
547
let r = Host::r8(host).await;
548
Ok((r,))
549
})
550
},
551
)?;
552
inst.func_wrap_async(
553
"pair-ret",
554
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
555
wasmtime::component::__internal::Box::new(async move {
556
let host = &mut host_getter(caller.data_mut());
557
let r = Host::pair_ret(host).await;
558
Ok((r,))
559
})
560
},
561
)?;
562
Ok(())
563
}
564
}
565
}
566
}
567
pub mod exports {
568
pub mod foo {
569
pub mod foo {
570
#[allow(clippy::all)]
571
pub mod integers {
572
#[allow(unused_imports)]
573
use wasmtime::component::__internal::{anyhow, Box};
574
pub struct Guest {
575
a1: wasmtime::component::Func,
576
a2: wasmtime::component::Func,
577
a3: wasmtime::component::Func,
578
a4: wasmtime::component::Func,
579
a5: wasmtime::component::Func,
580
a6: wasmtime::component::Func,
581
a7: wasmtime::component::Func,
582
a8: wasmtime::component::Func,
583
a9: wasmtime::component::Func,
584
r1: wasmtime::component::Func,
585
r2: wasmtime::component::Func,
586
r3: wasmtime::component::Func,
587
r4: wasmtime::component::Func,
588
r5: wasmtime::component::Func,
589
r6: wasmtime::component::Func,
590
r7: wasmtime::component::Func,
591
r8: wasmtime::component::Func,
592
pair_ret: wasmtime::component::Func,
593
}
594
#[derive(Clone)]
595
pub struct GuestIndices {
596
a1: wasmtime::component::ComponentExportIndex,
597
a2: wasmtime::component::ComponentExportIndex,
598
a3: wasmtime::component::ComponentExportIndex,
599
a4: wasmtime::component::ComponentExportIndex,
600
a5: wasmtime::component::ComponentExportIndex,
601
a6: wasmtime::component::ComponentExportIndex,
602
a7: wasmtime::component::ComponentExportIndex,
603
a8: wasmtime::component::ComponentExportIndex,
604
a9: wasmtime::component::ComponentExportIndex,
605
r1: wasmtime::component::ComponentExportIndex,
606
r2: wasmtime::component::ComponentExportIndex,
607
r3: wasmtime::component::ComponentExportIndex,
608
r4: wasmtime::component::ComponentExportIndex,
609
r5: wasmtime::component::ComponentExportIndex,
610
r6: wasmtime::component::ComponentExportIndex,
611
r7: wasmtime::component::ComponentExportIndex,
612
r8: wasmtime::component::ComponentExportIndex,
613
pair_ret: wasmtime::component::ComponentExportIndex,
614
}
615
impl GuestIndices {
616
/// Constructor for [`GuestIndices`] which takes a
617
/// [`Component`](wasmtime::component::Component) as input and can be executed
618
/// before instantiation.
619
///
620
/// This constructor can be used to front-load string lookups to find exports
621
/// within a component.
622
pub fn new<_T>(
623
_instance_pre: &wasmtime::component::InstancePre<_T>,
624
) -> wasmtime::Result<GuestIndices> {
625
let instance = _instance_pre
626
.component()
627
.get_export_index(None, "foo:foo/integers")
628
.ok_or_else(|| {
629
anyhow::anyhow!(
630
"no exported instance named `foo:foo/integers`"
631
)
632
})?;
633
let mut lookup = move |name| {
634
_instance_pre
635
.component()
636
.get_export_index(Some(&instance), name)
637
.ok_or_else(|| {
638
anyhow::anyhow!(
639
"instance export `foo:foo/integers` does \
640
not have export `{name}`"
641
)
642
})
643
};
644
let _ = &mut lookup;
645
let a1 = lookup("a1")?;
646
let a2 = lookup("a2")?;
647
let a3 = lookup("a3")?;
648
let a4 = lookup("a4")?;
649
let a5 = lookup("a5")?;
650
let a6 = lookup("a6")?;
651
let a7 = lookup("a7")?;
652
let a8 = lookup("a8")?;
653
let a9 = lookup("a9")?;
654
let r1 = lookup("r1")?;
655
let r2 = lookup("r2")?;
656
let r3 = lookup("r3")?;
657
let r4 = lookup("r4")?;
658
let r5 = lookup("r5")?;
659
let r6 = lookup("r6")?;
660
let r7 = lookup("r7")?;
661
let r8 = lookup("r8")?;
662
let pair_ret = lookup("pair-ret")?;
663
Ok(GuestIndices {
664
a1,
665
a2,
666
a3,
667
a4,
668
a5,
669
a6,
670
a7,
671
a8,
672
a9,
673
r1,
674
r2,
675
r3,
676
r4,
677
r5,
678
r6,
679
r7,
680
r8,
681
pair_ret,
682
})
683
}
684
pub fn load(
685
&self,
686
mut store: impl wasmtime::AsContextMut,
687
instance: &wasmtime::component::Instance,
688
) -> wasmtime::Result<Guest> {
689
let _instance = instance;
690
let _instance_pre = _instance.instance_pre(&store);
691
let _instance_type = _instance_pre.instance_type();
692
let mut store = store.as_context_mut();
693
let _ = &mut store;
694
let a1 = *_instance
695
.get_typed_func::<(u8,), ()>(&mut store, &self.a1)?
696
.func();
697
let a2 = *_instance
698
.get_typed_func::<(i8,), ()>(&mut store, &self.a2)?
699
.func();
700
let a3 = *_instance
701
.get_typed_func::<(u16,), ()>(&mut store, &self.a3)?
702
.func();
703
let a4 = *_instance
704
.get_typed_func::<(i16,), ()>(&mut store, &self.a4)?
705
.func();
706
let a5 = *_instance
707
.get_typed_func::<(u32,), ()>(&mut store, &self.a5)?
708
.func();
709
let a6 = *_instance
710
.get_typed_func::<(i32,), ()>(&mut store, &self.a6)?
711
.func();
712
let a7 = *_instance
713
.get_typed_func::<(u64,), ()>(&mut store, &self.a7)?
714
.func();
715
let a8 = *_instance
716
.get_typed_func::<(i64,), ()>(&mut store, &self.a8)?
717
.func();
718
let a9 = *_instance
719
.get_typed_func::<
720
(u8, i8, u16, i16, u32, i32, u64, i64),
721
(),
722
>(&mut store, &self.a9)?
723
.func();
724
let r1 = *_instance
725
.get_typed_func::<(), (u8,)>(&mut store, &self.r1)?
726
.func();
727
let r2 = *_instance
728
.get_typed_func::<(), (i8,)>(&mut store, &self.r2)?
729
.func();
730
let r3 = *_instance
731
.get_typed_func::<(), (u16,)>(&mut store, &self.r3)?
732
.func();
733
let r4 = *_instance
734
.get_typed_func::<(), (i16,)>(&mut store, &self.r4)?
735
.func();
736
let r5 = *_instance
737
.get_typed_func::<(), (u32,)>(&mut store, &self.r5)?
738
.func();
739
let r6 = *_instance
740
.get_typed_func::<(), (i32,)>(&mut store, &self.r6)?
741
.func();
742
let r7 = *_instance
743
.get_typed_func::<(), (u64,)>(&mut store, &self.r7)?
744
.func();
745
let r8 = *_instance
746
.get_typed_func::<(), (i64,)>(&mut store, &self.r8)?
747
.func();
748
let pair_ret = *_instance
749
.get_typed_func::<
750
(),
751
((i64, u8),),
752
>(&mut store, &self.pair_ret)?
753
.func();
754
Ok(Guest {
755
a1,
756
a2,
757
a3,
758
a4,
759
a5,
760
a6,
761
a7,
762
a8,
763
a9,
764
r1,
765
r2,
766
r3,
767
r4,
768
r5,
769
r6,
770
r7,
771
r8,
772
pair_ret,
773
})
774
}
775
}
776
impl Guest {
777
pub async fn call_a1<S: wasmtime::AsContextMut>(
778
&self,
779
mut store: S,
780
arg0: u8,
781
) -> wasmtime::Result<()>
782
where
783
<S as wasmtime::AsContext>::Data: Send,
784
{
785
let callee = unsafe {
786
wasmtime::component::TypedFunc::<
787
(u8,),
788
(),
789
>::new_unchecked(self.a1)
790
};
791
let () = callee
792
.call_async(store.as_context_mut(), (arg0,))
793
.await?;
794
callee.post_return_async(store.as_context_mut()).await?;
795
Ok(())
796
}
797
pub async fn call_a2<S: wasmtime::AsContextMut>(
798
&self,
799
mut store: S,
800
arg0: i8,
801
) -> wasmtime::Result<()>
802
where
803
<S as wasmtime::AsContext>::Data: Send,
804
{
805
let callee = unsafe {
806
wasmtime::component::TypedFunc::<
807
(i8,),
808
(),
809
>::new_unchecked(self.a2)
810
};
811
let () = callee
812
.call_async(store.as_context_mut(), (arg0,))
813
.await?;
814
callee.post_return_async(store.as_context_mut()).await?;
815
Ok(())
816
}
817
pub async fn call_a3<S: wasmtime::AsContextMut>(
818
&self,
819
mut store: S,
820
arg0: u16,
821
) -> wasmtime::Result<()>
822
where
823
<S as wasmtime::AsContext>::Data: Send,
824
{
825
let callee = unsafe {
826
wasmtime::component::TypedFunc::<
827
(u16,),
828
(),
829
>::new_unchecked(self.a3)
830
};
831
let () = callee
832
.call_async(store.as_context_mut(), (arg0,))
833
.await?;
834
callee.post_return_async(store.as_context_mut()).await?;
835
Ok(())
836
}
837
pub async fn call_a4<S: wasmtime::AsContextMut>(
838
&self,
839
mut store: S,
840
arg0: i16,
841
) -> wasmtime::Result<()>
842
where
843
<S as wasmtime::AsContext>::Data: Send,
844
{
845
let callee = unsafe {
846
wasmtime::component::TypedFunc::<
847
(i16,),
848
(),
849
>::new_unchecked(self.a4)
850
};
851
let () = callee
852
.call_async(store.as_context_mut(), (arg0,))
853
.await?;
854
callee.post_return_async(store.as_context_mut()).await?;
855
Ok(())
856
}
857
pub async fn call_a5<S: wasmtime::AsContextMut>(
858
&self,
859
mut store: S,
860
arg0: u32,
861
) -> wasmtime::Result<()>
862
where
863
<S as wasmtime::AsContext>::Data: Send,
864
{
865
let callee = unsafe {
866
wasmtime::component::TypedFunc::<
867
(u32,),
868
(),
869
>::new_unchecked(self.a5)
870
};
871
let () = callee
872
.call_async(store.as_context_mut(), (arg0,))
873
.await?;
874
callee.post_return_async(store.as_context_mut()).await?;
875
Ok(())
876
}
877
pub async fn call_a6<S: wasmtime::AsContextMut>(
878
&self,
879
mut store: S,
880
arg0: i32,
881
) -> wasmtime::Result<()>
882
where
883
<S as wasmtime::AsContext>::Data: Send,
884
{
885
let callee = unsafe {
886
wasmtime::component::TypedFunc::<
887
(i32,),
888
(),
889
>::new_unchecked(self.a6)
890
};
891
let () = callee
892
.call_async(store.as_context_mut(), (arg0,))
893
.await?;
894
callee.post_return_async(store.as_context_mut()).await?;
895
Ok(())
896
}
897
pub async fn call_a7<S: wasmtime::AsContextMut>(
898
&self,
899
mut store: S,
900
arg0: u64,
901
) -> wasmtime::Result<()>
902
where
903
<S as wasmtime::AsContext>::Data: Send,
904
{
905
let callee = unsafe {
906
wasmtime::component::TypedFunc::<
907
(u64,),
908
(),
909
>::new_unchecked(self.a7)
910
};
911
let () = callee
912
.call_async(store.as_context_mut(), (arg0,))
913
.await?;
914
callee.post_return_async(store.as_context_mut()).await?;
915
Ok(())
916
}
917
pub async fn call_a8<S: wasmtime::AsContextMut>(
918
&self,
919
mut store: S,
920
arg0: i64,
921
) -> wasmtime::Result<()>
922
where
923
<S as wasmtime::AsContext>::Data: Send,
924
{
925
let callee = unsafe {
926
wasmtime::component::TypedFunc::<
927
(i64,),
928
(),
929
>::new_unchecked(self.a8)
930
};
931
let () = callee
932
.call_async(store.as_context_mut(), (arg0,))
933
.await?;
934
callee.post_return_async(store.as_context_mut()).await?;
935
Ok(())
936
}
937
pub async fn call_a9<S: wasmtime::AsContextMut>(
938
&self,
939
mut store: S,
940
arg0: u8,
941
arg1: i8,
942
arg2: u16,
943
arg3: i16,
944
arg4: u32,
945
arg5: i32,
946
arg6: u64,
947
arg7: i64,
948
) -> wasmtime::Result<()>
949
where
950
<S as wasmtime::AsContext>::Data: Send,
951
{
952
let callee = unsafe {
953
wasmtime::component::TypedFunc::<
954
(u8, i8, u16, i16, u32, i32, u64, i64),
955
(),
956
>::new_unchecked(self.a9)
957
};
958
let () = callee
959
.call_async(
960
store.as_context_mut(),
961
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7),
962
)
963
.await?;
964
callee.post_return_async(store.as_context_mut()).await?;
965
Ok(())
966
}
967
pub async fn call_r1<S: wasmtime::AsContextMut>(
968
&self,
969
mut store: S,
970
) -> wasmtime::Result<u8>
971
where
972
<S as wasmtime::AsContext>::Data: Send,
973
{
974
let callee = unsafe {
975
wasmtime::component::TypedFunc::<
976
(),
977
(u8,),
978
>::new_unchecked(self.r1)
979
};
980
let (ret0,) = callee
981
.call_async(store.as_context_mut(), ())
982
.await?;
983
callee.post_return_async(store.as_context_mut()).await?;
984
Ok(ret0)
985
}
986
pub async fn call_r2<S: wasmtime::AsContextMut>(
987
&self,
988
mut store: S,
989
) -> wasmtime::Result<i8>
990
where
991
<S as wasmtime::AsContext>::Data: Send,
992
{
993
let callee = unsafe {
994
wasmtime::component::TypedFunc::<
995
(),
996
(i8,),
997
>::new_unchecked(self.r2)
998
};
999
let (ret0,) = callee
1000
.call_async(store.as_context_mut(), ())
1001
.await?;
1002
callee.post_return_async(store.as_context_mut()).await?;
1003
Ok(ret0)
1004
}
1005
pub async fn call_r3<S: wasmtime::AsContextMut>(
1006
&self,
1007
mut store: S,
1008
) -> wasmtime::Result<u16>
1009
where
1010
<S as wasmtime::AsContext>::Data: Send,
1011
{
1012
let callee = unsafe {
1013
wasmtime::component::TypedFunc::<
1014
(),
1015
(u16,),
1016
>::new_unchecked(self.r3)
1017
};
1018
let (ret0,) = callee
1019
.call_async(store.as_context_mut(), ())
1020
.await?;
1021
callee.post_return_async(store.as_context_mut()).await?;
1022
Ok(ret0)
1023
}
1024
pub async fn call_r4<S: wasmtime::AsContextMut>(
1025
&self,
1026
mut store: S,
1027
) -> wasmtime::Result<i16>
1028
where
1029
<S as wasmtime::AsContext>::Data: Send,
1030
{
1031
let callee = unsafe {
1032
wasmtime::component::TypedFunc::<
1033
(),
1034
(i16,),
1035
>::new_unchecked(self.r4)
1036
};
1037
let (ret0,) = callee
1038
.call_async(store.as_context_mut(), ())
1039
.await?;
1040
callee.post_return_async(store.as_context_mut()).await?;
1041
Ok(ret0)
1042
}
1043
pub async fn call_r5<S: wasmtime::AsContextMut>(
1044
&self,
1045
mut store: S,
1046
) -> wasmtime::Result<u32>
1047
where
1048
<S as wasmtime::AsContext>::Data: Send,
1049
{
1050
let callee = unsafe {
1051
wasmtime::component::TypedFunc::<
1052
(),
1053
(u32,),
1054
>::new_unchecked(self.r5)
1055
};
1056
let (ret0,) = callee
1057
.call_async(store.as_context_mut(), ())
1058
.await?;
1059
callee.post_return_async(store.as_context_mut()).await?;
1060
Ok(ret0)
1061
}
1062
pub async fn call_r6<S: wasmtime::AsContextMut>(
1063
&self,
1064
mut store: S,
1065
) -> wasmtime::Result<i32>
1066
where
1067
<S as wasmtime::AsContext>::Data: Send,
1068
{
1069
let callee = unsafe {
1070
wasmtime::component::TypedFunc::<
1071
(),
1072
(i32,),
1073
>::new_unchecked(self.r6)
1074
};
1075
let (ret0,) = callee
1076
.call_async(store.as_context_mut(), ())
1077
.await?;
1078
callee.post_return_async(store.as_context_mut()).await?;
1079
Ok(ret0)
1080
}
1081
pub async fn call_r7<S: wasmtime::AsContextMut>(
1082
&self,
1083
mut store: S,
1084
) -> wasmtime::Result<u64>
1085
where
1086
<S as wasmtime::AsContext>::Data: Send,
1087
{
1088
let callee = unsafe {
1089
wasmtime::component::TypedFunc::<
1090
(),
1091
(u64,),
1092
>::new_unchecked(self.r7)
1093
};
1094
let (ret0,) = callee
1095
.call_async(store.as_context_mut(), ())
1096
.await?;
1097
callee.post_return_async(store.as_context_mut()).await?;
1098
Ok(ret0)
1099
}
1100
pub async fn call_r8<S: wasmtime::AsContextMut>(
1101
&self,
1102
mut store: S,
1103
) -> wasmtime::Result<i64>
1104
where
1105
<S as wasmtime::AsContext>::Data: Send,
1106
{
1107
let callee = unsafe {
1108
wasmtime::component::TypedFunc::<
1109
(),
1110
(i64,),
1111
>::new_unchecked(self.r8)
1112
};
1113
let (ret0,) = callee
1114
.call_async(store.as_context_mut(), ())
1115
.await?;
1116
callee.post_return_async(store.as_context_mut()).await?;
1117
Ok(ret0)
1118
}
1119
pub async fn call_pair_ret<S: wasmtime::AsContextMut>(
1120
&self,
1121
mut store: S,
1122
) -> wasmtime::Result<(i64, u8)>
1123
where
1124
<S as wasmtime::AsContext>::Data: Send,
1125
{
1126
let callee = unsafe {
1127
wasmtime::component::TypedFunc::<
1128
(),
1129
((i64, u8),),
1130
>::new_unchecked(self.pair_ret)
1131
};
1132
let (ret0,) = callee
1133
.call_async(store.as_context_mut(), ())
1134
.await?;
1135
callee.post_return_async(store.as_context_mut()).await?;
1136
Ok(ret0)
1137
}
1138
}
1139
}
1140
}
1141
}
1142
}
1143
1144