Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/component-macro/tests/expanded/integers_tracing_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
use tracing::Instrument;
363
let span = tracing::span!(
364
tracing::Level::TRACE, "wit-bindgen import", module =
365
"integers", function = "a1",
366
);
367
wasmtime::component::__internal::Box::new(
368
async move {
369
tracing::event!(
370
tracing::Level::TRACE, x = tracing::field::debug(& arg0),
371
"call"
372
);
373
let host = &mut host_getter(caller.data_mut());
374
let r = Host::a1(host, arg0).await;
375
tracing::event!(
376
tracing::Level::TRACE, result = tracing::field::debug(& r),
377
"return"
378
);
379
Ok(r)
380
}
381
.instrument(span),
382
)
383
},
384
)?;
385
inst.func_wrap_async(
386
"a2",
387
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i8,)| {
388
use tracing::Instrument;
389
let span = tracing::span!(
390
tracing::Level::TRACE, "wit-bindgen import", module =
391
"integers", function = "a2",
392
);
393
wasmtime::component::__internal::Box::new(
394
async move {
395
tracing::event!(
396
tracing::Level::TRACE, x = tracing::field::debug(& arg0),
397
"call"
398
);
399
let host = &mut host_getter(caller.data_mut());
400
let r = Host::a2(host, arg0).await;
401
tracing::event!(
402
tracing::Level::TRACE, result = tracing::field::debug(& r),
403
"return"
404
);
405
Ok(r)
406
}
407
.instrument(span),
408
)
409
},
410
)?;
411
inst.func_wrap_async(
412
"a3",
413
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u16,)| {
414
use tracing::Instrument;
415
let span = tracing::span!(
416
tracing::Level::TRACE, "wit-bindgen import", module =
417
"integers", function = "a3",
418
);
419
wasmtime::component::__internal::Box::new(
420
async move {
421
tracing::event!(
422
tracing::Level::TRACE, x = tracing::field::debug(& arg0),
423
"call"
424
);
425
let host = &mut host_getter(caller.data_mut());
426
let r = Host::a3(host, arg0).await;
427
tracing::event!(
428
tracing::Level::TRACE, result = tracing::field::debug(& r),
429
"return"
430
);
431
Ok(r)
432
}
433
.instrument(span),
434
)
435
},
436
)?;
437
inst.func_wrap_async(
438
"a4",
439
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i16,)| {
440
use tracing::Instrument;
441
let span = tracing::span!(
442
tracing::Level::TRACE, "wit-bindgen import", module =
443
"integers", function = "a4",
444
);
445
wasmtime::component::__internal::Box::new(
446
async move {
447
tracing::event!(
448
tracing::Level::TRACE, x = tracing::field::debug(& arg0),
449
"call"
450
);
451
let host = &mut host_getter(caller.data_mut());
452
let r = Host::a4(host, arg0).await;
453
tracing::event!(
454
tracing::Level::TRACE, result = tracing::field::debug(& r),
455
"return"
456
);
457
Ok(r)
458
}
459
.instrument(span),
460
)
461
},
462
)?;
463
inst.func_wrap_async(
464
"a5",
465
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u32,)| {
466
use tracing::Instrument;
467
let span = tracing::span!(
468
tracing::Level::TRACE, "wit-bindgen import", module =
469
"integers", function = "a5",
470
);
471
wasmtime::component::__internal::Box::new(
472
async move {
473
tracing::event!(
474
tracing::Level::TRACE, x = tracing::field::debug(& arg0),
475
"call"
476
);
477
let host = &mut host_getter(caller.data_mut());
478
let r = Host::a5(host, arg0).await;
479
tracing::event!(
480
tracing::Level::TRACE, result = tracing::field::debug(& r),
481
"return"
482
);
483
Ok(r)
484
}
485
.instrument(span),
486
)
487
},
488
)?;
489
inst.func_wrap_async(
490
"a6",
491
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i32,)| {
492
use tracing::Instrument;
493
let span = tracing::span!(
494
tracing::Level::TRACE, "wit-bindgen import", module =
495
"integers", function = "a6",
496
);
497
wasmtime::component::__internal::Box::new(
498
async move {
499
tracing::event!(
500
tracing::Level::TRACE, x = tracing::field::debug(& arg0),
501
"call"
502
);
503
let host = &mut host_getter(caller.data_mut());
504
let r = Host::a6(host, arg0).await;
505
tracing::event!(
506
tracing::Level::TRACE, result = tracing::field::debug(& r),
507
"return"
508
);
509
Ok(r)
510
}
511
.instrument(span),
512
)
513
},
514
)?;
515
inst.func_wrap_async(
516
"a7",
517
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u64,)| {
518
use tracing::Instrument;
519
let span = tracing::span!(
520
tracing::Level::TRACE, "wit-bindgen import", module =
521
"integers", function = "a7",
522
);
523
wasmtime::component::__internal::Box::new(
524
async move {
525
tracing::event!(
526
tracing::Level::TRACE, x = tracing::field::debug(& arg0),
527
"call"
528
);
529
let host = &mut host_getter(caller.data_mut());
530
let r = Host::a7(host, arg0).await;
531
tracing::event!(
532
tracing::Level::TRACE, result = tracing::field::debug(& r),
533
"return"
534
);
535
Ok(r)
536
}
537
.instrument(span),
538
)
539
},
540
)?;
541
inst.func_wrap_async(
542
"a8",
543
move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i64,)| {
544
use tracing::Instrument;
545
let span = tracing::span!(
546
tracing::Level::TRACE, "wit-bindgen import", module =
547
"integers", function = "a8",
548
);
549
wasmtime::component::__internal::Box::new(
550
async move {
551
tracing::event!(
552
tracing::Level::TRACE, x = tracing::field::debug(& arg0),
553
"call"
554
);
555
let host = &mut host_getter(caller.data_mut());
556
let r = Host::a8(host, arg0).await;
557
tracing::event!(
558
tracing::Level::TRACE, result = tracing::field::debug(& r),
559
"return"
560
);
561
Ok(r)
562
}
563
.instrument(span),
564
)
565
},
566
)?;
567
inst.func_wrap_async(
568
"a9",
569
move |
570
mut caller: wasmtime::StoreContextMut<'_, T>,
571
(
572
arg0,
573
arg1,
574
arg2,
575
arg3,
576
arg4,
577
arg5,
578
arg6,
579
arg7,
580
): (u8, i8, u16, i16, u32, i32, u64, i64)|
581
{
582
use tracing::Instrument;
583
let span = tracing::span!(
584
tracing::Level::TRACE, "wit-bindgen import", module =
585
"integers", function = "a9",
586
);
587
wasmtime::component::__internal::Box::new(
588
async move {
589
tracing::event!(
590
tracing::Level::TRACE, p1 = tracing::field::debug(& arg0),
591
p2 = tracing::field::debug(& arg1), p3 =
592
tracing::field::debug(& arg2), p4 = tracing::field::debug(&
593
arg3), p5 = tracing::field::debug(& arg4), p6 =
594
tracing::field::debug(& arg5), p7 = tracing::field::debug(&
595
arg6), p8 = tracing::field::debug(& arg7), "call"
596
);
597
let host = &mut host_getter(caller.data_mut());
598
let r = Host::a9(
599
host,
600
arg0,
601
arg1,
602
arg2,
603
arg3,
604
arg4,
605
arg5,
606
arg6,
607
arg7,
608
)
609
.await;
610
tracing::event!(
611
tracing::Level::TRACE, result = tracing::field::debug(& r),
612
"return"
613
);
614
Ok(r)
615
}
616
.instrument(span),
617
)
618
},
619
)?;
620
inst.func_wrap_async(
621
"r1",
622
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
623
use tracing::Instrument;
624
let span = tracing::span!(
625
tracing::Level::TRACE, "wit-bindgen import", module =
626
"integers", function = "r1",
627
);
628
wasmtime::component::__internal::Box::new(
629
async move {
630
tracing::event!(tracing::Level::TRACE, "call");
631
let host = &mut host_getter(caller.data_mut());
632
let r = Host::r1(host).await;
633
tracing::event!(
634
tracing::Level::TRACE, result = tracing::field::debug(& r),
635
"return"
636
);
637
Ok((r,))
638
}
639
.instrument(span),
640
)
641
},
642
)?;
643
inst.func_wrap_async(
644
"r2",
645
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
646
use tracing::Instrument;
647
let span = tracing::span!(
648
tracing::Level::TRACE, "wit-bindgen import", module =
649
"integers", function = "r2",
650
);
651
wasmtime::component::__internal::Box::new(
652
async move {
653
tracing::event!(tracing::Level::TRACE, "call");
654
let host = &mut host_getter(caller.data_mut());
655
let r = Host::r2(host).await;
656
tracing::event!(
657
tracing::Level::TRACE, result = tracing::field::debug(& r),
658
"return"
659
);
660
Ok((r,))
661
}
662
.instrument(span),
663
)
664
},
665
)?;
666
inst.func_wrap_async(
667
"r3",
668
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
669
use tracing::Instrument;
670
let span = tracing::span!(
671
tracing::Level::TRACE, "wit-bindgen import", module =
672
"integers", function = "r3",
673
);
674
wasmtime::component::__internal::Box::new(
675
async move {
676
tracing::event!(tracing::Level::TRACE, "call");
677
let host = &mut host_getter(caller.data_mut());
678
let r = Host::r3(host).await;
679
tracing::event!(
680
tracing::Level::TRACE, result = tracing::field::debug(& r),
681
"return"
682
);
683
Ok((r,))
684
}
685
.instrument(span),
686
)
687
},
688
)?;
689
inst.func_wrap_async(
690
"r4",
691
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
692
use tracing::Instrument;
693
let span = tracing::span!(
694
tracing::Level::TRACE, "wit-bindgen import", module =
695
"integers", function = "r4",
696
);
697
wasmtime::component::__internal::Box::new(
698
async move {
699
tracing::event!(tracing::Level::TRACE, "call");
700
let host = &mut host_getter(caller.data_mut());
701
let r = Host::r4(host).await;
702
tracing::event!(
703
tracing::Level::TRACE, result = tracing::field::debug(& r),
704
"return"
705
);
706
Ok((r,))
707
}
708
.instrument(span),
709
)
710
},
711
)?;
712
inst.func_wrap_async(
713
"r5",
714
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
715
use tracing::Instrument;
716
let span = tracing::span!(
717
tracing::Level::TRACE, "wit-bindgen import", module =
718
"integers", function = "r5",
719
);
720
wasmtime::component::__internal::Box::new(
721
async move {
722
tracing::event!(tracing::Level::TRACE, "call");
723
let host = &mut host_getter(caller.data_mut());
724
let r = Host::r5(host).await;
725
tracing::event!(
726
tracing::Level::TRACE, result = tracing::field::debug(& r),
727
"return"
728
);
729
Ok((r,))
730
}
731
.instrument(span),
732
)
733
},
734
)?;
735
inst.func_wrap_async(
736
"r6",
737
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
738
use tracing::Instrument;
739
let span = tracing::span!(
740
tracing::Level::TRACE, "wit-bindgen import", module =
741
"integers", function = "r6",
742
);
743
wasmtime::component::__internal::Box::new(
744
async move {
745
tracing::event!(tracing::Level::TRACE, "call");
746
let host = &mut host_getter(caller.data_mut());
747
let r = Host::r6(host).await;
748
tracing::event!(
749
tracing::Level::TRACE, result = tracing::field::debug(& r),
750
"return"
751
);
752
Ok((r,))
753
}
754
.instrument(span),
755
)
756
},
757
)?;
758
inst.func_wrap_async(
759
"r7",
760
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
761
use tracing::Instrument;
762
let span = tracing::span!(
763
tracing::Level::TRACE, "wit-bindgen import", module =
764
"integers", function = "r7",
765
);
766
wasmtime::component::__internal::Box::new(
767
async move {
768
tracing::event!(tracing::Level::TRACE, "call");
769
let host = &mut host_getter(caller.data_mut());
770
let r = Host::r7(host).await;
771
tracing::event!(
772
tracing::Level::TRACE, result = tracing::field::debug(& r),
773
"return"
774
);
775
Ok((r,))
776
}
777
.instrument(span),
778
)
779
},
780
)?;
781
inst.func_wrap_async(
782
"r8",
783
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
784
use tracing::Instrument;
785
let span = tracing::span!(
786
tracing::Level::TRACE, "wit-bindgen import", module =
787
"integers", function = "r8",
788
);
789
wasmtime::component::__internal::Box::new(
790
async move {
791
tracing::event!(tracing::Level::TRACE, "call");
792
let host = &mut host_getter(caller.data_mut());
793
let r = Host::r8(host).await;
794
tracing::event!(
795
tracing::Level::TRACE, result = tracing::field::debug(& r),
796
"return"
797
);
798
Ok((r,))
799
}
800
.instrument(span),
801
)
802
},
803
)?;
804
inst.func_wrap_async(
805
"pair-ret",
806
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
807
use tracing::Instrument;
808
let span = tracing::span!(
809
tracing::Level::TRACE, "wit-bindgen import", module =
810
"integers", function = "pair-ret",
811
);
812
wasmtime::component::__internal::Box::new(
813
async move {
814
tracing::event!(tracing::Level::TRACE, "call");
815
let host = &mut host_getter(caller.data_mut());
816
let r = Host::pair_ret(host).await;
817
tracing::event!(
818
tracing::Level::TRACE, result = tracing::field::debug(& r),
819
"return"
820
);
821
Ok((r,))
822
}
823
.instrument(span),
824
)
825
},
826
)?;
827
Ok(())
828
}
829
}
830
}
831
}
832
pub mod exports {
833
pub mod foo {
834
pub mod foo {
835
#[allow(clippy::all)]
836
pub mod integers {
837
#[allow(unused_imports)]
838
use wasmtime::component::__internal::{anyhow, Box};
839
pub struct Guest {
840
a1: wasmtime::component::Func,
841
a2: wasmtime::component::Func,
842
a3: wasmtime::component::Func,
843
a4: wasmtime::component::Func,
844
a5: wasmtime::component::Func,
845
a6: wasmtime::component::Func,
846
a7: wasmtime::component::Func,
847
a8: wasmtime::component::Func,
848
a9: wasmtime::component::Func,
849
r1: wasmtime::component::Func,
850
r2: wasmtime::component::Func,
851
r3: wasmtime::component::Func,
852
r4: wasmtime::component::Func,
853
r5: wasmtime::component::Func,
854
r6: wasmtime::component::Func,
855
r7: wasmtime::component::Func,
856
r8: wasmtime::component::Func,
857
pair_ret: wasmtime::component::Func,
858
}
859
#[derive(Clone)]
860
pub struct GuestIndices {
861
a1: wasmtime::component::ComponentExportIndex,
862
a2: wasmtime::component::ComponentExportIndex,
863
a3: wasmtime::component::ComponentExportIndex,
864
a4: wasmtime::component::ComponentExportIndex,
865
a5: wasmtime::component::ComponentExportIndex,
866
a6: wasmtime::component::ComponentExportIndex,
867
a7: wasmtime::component::ComponentExportIndex,
868
a8: wasmtime::component::ComponentExportIndex,
869
a9: wasmtime::component::ComponentExportIndex,
870
r1: wasmtime::component::ComponentExportIndex,
871
r2: wasmtime::component::ComponentExportIndex,
872
r3: wasmtime::component::ComponentExportIndex,
873
r4: wasmtime::component::ComponentExportIndex,
874
r5: wasmtime::component::ComponentExportIndex,
875
r6: wasmtime::component::ComponentExportIndex,
876
r7: wasmtime::component::ComponentExportIndex,
877
r8: wasmtime::component::ComponentExportIndex,
878
pair_ret: wasmtime::component::ComponentExportIndex,
879
}
880
impl GuestIndices {
881
/// Constructor for [`GuestIndices`] which takes a
882
/// [`Component`](wasmtime::component::Component) as input and can be executed
883
/// before instantiation.
884
///
885
/// This constructor can be used to front-load string lookups to find exports
886
/// within a component.
887
pub fn new<_T>(
888
_instance_pre: &wasmtime::component::InstancePre<_T>,
889
) -> wasmtime::Result<GuestIndices> {
890
let instance = _instance_pre
891
.component()
892
.get_export_index(None, "foo:foo/integers")
893
.ok_or_else(|| {
894
anyhow::anyhow!(
895
"no exported instance named `foo:foo/integers`"
896
)
897
})?;
898
let mut lookup = move |name| {
899
_instance_pre
900
.component()
901
.get_export_index(Some(&instance), name)
902
.ok_or_else(|| {
903
anyhow::anyhow!(
904
"instance export `foo:foo/integers` does \
905
not have export `{name}`"
906
)
907
})
908
};
909
let _ = &mut lookup;
910
let a1 = lookup("a1")?;
911
let a2 = lookup("a2")?;
912
let a3 = lookup("a3")?;
913
let a4 = lookup("a4")?;
914
let a5 = lookup("a5")?;
915
let a6 = lookup("a6")?;
916
let a7 = lookup("a7")?;
917
let a8 = lookup("a8")?;
918
let a9 = lookup("a9")?;
919
let r1 = lookup("r1")?;
920
let r2 = lookup("r2")?;
921
let r3 = lookup("r3")?;
922
let r4 = lookup("r4")?;
923
let r5 = lookup("r5")?;
924
let r6 = lookup("r6")?;
925
let r7 = lookup("r7")?;
926
let r8 = lookup("r8")?;
927
let pair_ret = lookup("pair-ret")?;
928
Ok(GuestIndices {
929
a1,
930
a2,
931
a3,
932
a4,
933
a5,
934
a6,
935
a7,
936
a8,
937
a9,
938
r1,
939
r2,
940
r3,
941
r4,
942
r5,
943
r6,
944
r7,
945
r8,
946
pair_ret,
947
})
948
}
949
pub fn load(
950
&self,
951
mut store: impl wasmtime::AsContextMut,
952
instance: &wasmtime::component::Instance,
953
) -> wasmtime::Result<Guest> {
954
let _instance = instance;
955
let _instance_pre = _instance.instance_pre(&store);
956
let _instance_type = _instance_pre.instance_type();
957
let mut store = store.as_context_mut();
958
let _ = &mut store;
959
let a1 = *_instance
960
.get_typed_func::<(u8,), ()>(&mut store, &self.a1)?
961
.func();
962
let a2 = *_instance
963
.get_typed_func::<(i8,), ()>(&mut store, &self.a2)?
964
.func();
965
let a3 = *_instance
966
.get_typed_func::<(u16,), ()>(&mut store, &self.a3)?
967
.func();
968
let a4 = *_instance
969
.get_typed_func::<(i16,), ()>(&mut store, &self.a4)?
970
.func();
971
let a5 = *_instance
972
.get_typed_func::<(u32,), ()>(&mut store, &self.a5)?
973
.func();
974
let a6 = *_instance
975
.get_typed_func::<(i32,), ()>(&mut store, &self.a6)?
976
.func();
977
let a7 = *_instance
978
.get_typed_func::<(u64,), ()>(&mut store, &self.a7)?
979
.func();
980
let a8 = *_instance
981
.get_typed_func::<(i64,), ()>(&mut store, &self.a8)?
982
.func();
983
let a9 = *_instance
984
.get_typed_func::<
985
(u8, i8, u16, i16, u32, i32, u64, i64),
986
(),
987
>(&mut store, &self.a9)?
988
.func();
989
let r1 = *_instance
990
.get_typed_func::<(), (u8,)>(&mut store, &self.r1)?
991
.func();
992
let r2 = *_instance
993
.get_typed_func::<(), (i8,)>(&mut store, &self.r2)?
994
.func();
995
let r3 = *_instance
996
.get_typed_func::<(), (u16,)>(&mut store, &self.r3)?
997
.func();
998
let r4 = *_instance
999
.get_typed_func::<(), (i16,)>(&mut store, &self.r4)?
1000
.func();
1001
let r5 = *_instance
1002
.get_typed_func::<(), (u32,)>(&mut store, &self.r5)?
1003
.func();
1004
let r6 = *_instance
1005
.get_typed_func::<(), (i32,)>(&mut store, &self.r6)?
1006
.func();
1007
let r7 = *_instance
1008
.get_typed_func::<(), (u64,)>(&mut store, &self.r7)?
1009
.func();
1010
let r8 = *_instance
1011
.get_typed_func::<(), (i64,)>(&mut store, &self.r8)?
1012
.func();
1013
let pair_ret = *_instance
1014
.get_typed_func::<
1015
(),
1016
((i64, u8),),
1017
>(&mut store, &self.pair_ret)?
1018
.func();
1019
Ok(Guest {
1020
a1,
1021
a2,
1022
a3,
1023
a4,
1024
a5,
1025
a6,
1026
a7,
1027
a8,
1028
a9,
1029
r1,
1030
r2,
1031
r3,
1032
r4,
1033
r5,
1034
r6,
1035
r7,
1036
r8,
1037
pair_ret,
1038
})
1039
}
1040
}
1041
impl Guest {
1042
pub async fn call_a1<S: wasmtime::AsContextMut>(
1043
&self,
1044
mut store: S,
1045
arg0: u8,
1046
) -> wasmtime::Result<()>
1047
where
1048
<S as wasmtime::AsContext>::Data: Send,
1049
{
1050
use tracing::Instrument;
1051
let span = tracing::span!(
1052
tracing::Level::TRACE, "wit-bindgen export", module =
1053
"foo:foo/integers", function = "a1",
1054
);
1055
let callee = unsafe {
1056
wasmtime::component::TypedFunc::<
1057
(u8,),
1058
(),
1059
>::new_unchecked(self.a1)
1060
};
1061
let () = callee
1062
.call_async(store.as_context_mut(), (arg0,))
1063
.instrument(span.clone())
1064
.await?;
1065
callee
1066
.post_return_async(store.as_context_mut())
1067
.instrument(span)
1068
.await?;
1069
Ok(())
1070
}
1071
pub async fn call_a2<S: wasmtime::AsContextMut>(
1072
&self,
1073
mut store: S,
1074
arg0: i8,
1075
) -> wasmtime::Result<()>
1076
where
1077
<S as wasmtime::AsContext>::Data: Send,
1078
{
1079
use tracing::Instrument;
1080
let span = tracing::span!(
1081
tracing::Level::TRACE, "wit-bindgen export", module =
1082
"foo:foo/integers", function = "a2",
1083
);
1084
let callee = unsafe {
1085
wasmtime::component::TypedFunc::<
1086
(i8,),
1087
(),
1088
>::new_unchecked(self.a2)
1089
};
1090
let () = callee
1091
.call_async(store.as_context_mut(), (arg0,))
1092
.instrument(span.clone())
1093
.await?;
1094
callee
1095
.post_return_async(store.as_context_mut())
1096
.instrument(span)
1097
.await?;
1098
Ok(())
1099
}
1100
pub async fn call_a3<S: wasmtime::AsContextMut>(
1101
&self,
1102
mut store: S,
1103
arg0: u16,
1104
) -> wasmtime::Result<()>
1105
where
1106
<S as wasmtime::AsContext>::Data: Send,
1107
{
1108
use tracing::Instrument;
1109
let span = tracing::span!(
1110
tracing::Level::TRACE, "wit-bindgen export", module =
1111
"foo:foo/integers", function = "a3",
1112
);
1113
let callee = unsafe {
1114
wasmtime::component::TypedFunc::<
1115
(u16,),
1116
(),
1117
>::new_unchecked(self.a3)
1118
};
1119
let () = callee
1120
.call_async(store.as_context_mut(), (arg0,))
1121
.instrument(span.clone())
1122
.await?;
1123
callee
1124
.post_return_async(store.as_context_mut())
1125
.instrument(span)
1126
.await?;
1127
Ok(())
1128
}
1129
pub async fn call_a4<S: wasmtime::AsContextMut>(
1130
&self,
1131
mut store: S,
1132
arg0: i16,
1133
) -> wasmtime::Result<()>
1134
where
1135
<S as wasmtime::AsContext>::Data: Send,
1136
{
1137
use tracing::Instrument;
1138
let span = tracing::span!(
1139
tracing::Level::TRACE, "wit-bindgen export", module =
1140
"foo:foo/integers", function = "a4",
1141
);
1142
let callee = unsafe {
1143
wasmtime::component::TypedFunc::<
1144
(i16,),
1145
(),
1146
>::new_unchecked(self.a4)
1147
};
1148
let () = callee
1149
.call_async(store.as_context_mut(), (arg0,))
1150
.instrument(span.clone())
1151
.await?;
1152
callee
1153
.post_return_async(store.as_context_mut())
1154
.instrument(span)
1155
.await?;
1156
Ok(())
1157
}
1158
pub async fn call_a5<S: wasmtime::AsContextMut>(
1159
&self,
1160
mut store: S,
1161
arg0: u32,
1162
) -> wasmtime::Result<()>
1163
where
1164
<S as wasmtime::AsContext>::Data: Send,
1165
{
1166
use tracing::Instrument;
1167
let span = tracing::span!(
1168
tracing::Level::TRACE, "wit-bindgen export", module =
1169
"foo:foo/integers", function = "a5",
1170
);
1171
let callee = unsafe {
1172
wasmtime::component::TypedFunc::<
1173
(u32,),
1174
(),
1175
>::new_unchecked(self.a5)
1176
};
1177
let () = callee
1178
.call_async(store.as_context_mut(), (arg0,))
1179
.instrument(span.clone())
1180
.await?;
1181
callee
1182
.post_return_async(store.as_context_mut())
1183
.instrument(span)
1184
.await?;
1185
Ok(())
1186
}
1187
pub async fn call_a6<S: wasmtime::AsContextMut>(
1188
&self,
1189
mut store: S,
1190
arg0: i32,
1191
) -> wasmtime::Result<()>
1192
where
1193
<S as wasmtime::AsContext>::Data: Send,
1194
{
1195
use tracing::Instrument;
1196
let span = tracing::span!(
1197
tracing::Level::TRACE, "wit-bindgen export", module =
1198
"foo:foo/integers", function = "a6",
1199
);
1200
let callee = unsafe {
1201
wasmtime::component::TypedFunc::<
1202
(i32,),
1203
(),
1204
>::new_unchecked(self.a6)
1205
};
1206
let () = callee
1207
.call_async(store.as_context_mut(), (arg0,))
1208
.instrument(span.clone())
1209
.await?;
1210
callee
1211
.post_return_async(store.as_context_mut())
1212
.instrument(span)
1213
.await?;
1214
Ok(())
1215
}
1216
pub async fn call_a7<S: wasmtime::AsContextMut>(
1217
&self,
1218
mut store: S,
1219
arg0: u64,
1220
) -> wasmtime::Result<()>
1221
where
1222
<S as wasmtime::AsContext>::Data: Send,
1223
{
1224
use tracing::Instrument;
1225
let span = tracing::span!(
1226
tracing::Level::TRACE, "wit-bindgen export", module =
1227
"foo:foo/integers", function = "a7",
1228
);
1229
let callee = unsafe {
1230
wasmtime::component::TypedFunc::<
1231
(u64,),
1232
(),
1233
>::new_unchecked(self.a7)
1234
};
1235
let () = callee
1236
.call_async(store.as_context_mut(), (arg0,))
1237
.instrument(span.clone())
1238
.await?;
1239
callee
1240
.post_return_async(store.as_context_mut())
1241
.instrument(span)
1242
.await?;
1243
Ok(())
1244
}
1245
pub async fn call_a8<S: wasmtime::AsContextMut>(
1246
&self,
1247
mut store: S,
1248
arg0: i64,
1249
) -> wasmtime::Result<()>
1250
where
1251
<S as wasmtime::AsContext>::Data: Send,
1252
{
1253
use tracing::Instrument;
1254
let span = tracing::span!(
1255
tracing::Level::TRACE, "wit-bindgen export", module =
1256
"foo:foo/integers", function = "a8",
1257
);
1258
let callee = unsafe {
1259
wasmtime::component::TypedFunc::<
1260
(i64,),
1261
(),
1262
>::new_unchecked(self.a8)
1263
};
1264
let () = callee
1265
.call_async(store.as_context_mut(), (arg0,))
1266
.instrument(span.clone())
1267
.await?;
1268
callee
1269
.post_return_async(store.as_context_mut())
1270
.instrument(span)
1271
.await?;
1272
Ok(())
1273
}
1274
pub async fn call_a9<S: wasmtime::AsContextMut>(
1275
&self,
1276
mut store: S,
1277
arg0: u8,
1278
arg1: i8,
1279
arg2: u16,
1280
arg3: i16,
1281
arg4: u32,
1282
arg5: i32,
1283
arg6: u64,
1284
arg7: i64,
1285
) -> wasmtime::Result<()>
1286
where
1287
<S as wasmtime::AsContext>::Data: Send,
1288
{
1289
use tracing::Instrument;
1290
let span = tracing::span!(
1291
tracing::Level::TRACE, "wit-bindgen export", module =
1292
"foo:foo/integers", function = "a9",
1293
);
1294
let callee = unsafe {
1295
wasmtime::component::TypedFunc::<
1296
(u8, i8, u16, i16, u32, i32, u64, i64),
1297
(),
1298
>::new_unchecked(self.a9)
1299
};
1300
let () = callee
1301
.call_async(
1302
store.as_context_mut(),
1303
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7),
1304
)
1305
.instrument(span.clone())
1306
.await?;
1307
callee
1308
.post_return_async(store.as_context_mut())
1309
.instrument(span)
1310
.await?;
1311
Ok(())
1312
}
1313
pub async fn call_r1<S: wasmtime::AsContextMut>(
1314
&self,
1315
mut store: S,
1316
) -> wasmtime::Result<u8>
1317
where
1318
<S as wasmtime::AsContext>::Data: Send,
1319
{
1320
use tracing::Instrument;
1321
let span = tracing::span!(
1322
tracing::Level::TRACE, "wit-bindgen export", module =
1323
"foo:foo/integers", function = "r1",
1324
);
1325
let callee = unsafe {
1326
wasmtime::component::TypedFunc::<
1327
(),
1328
(u8,),
1329
>::new_unchecked(self.r1)
1330
};
1331
let (ret0,) = callee
1332
.call_async(store.as_context_mut(), ())
1333
.instrument(span.clone())
1334
.await?;
1335
callee
1336
.post_return_async(store.as_context_mut())
1337
.instrument(span)
1338
.await?;
1339
Ok(ret0)
1340
}
1341
pub async fn call_r2<S: wasmtime::AsContextMut>(
1342
&self,
1343
mut store: S,
1344
) -> wasmtime::Result<i8>
1345
where
1346
<S as wasmtime::AsContext>::Data: Send,
1347
{
1348
use tracing::Instrument;
1349
let span = tracing::span!(
1350
tracing::Level::TRACE, "wit-bindgen export", module =
1351
"foo:foo/integers", function = "r2",
1352
);
1353
let callee = unsafe {
1354
wasmtime::component::TypedFunc::<
1355
(),
1356
(i8,),
1357
>::new_unchecked(self.r2)
1358
};
1359
let (ret0,) = callee
1360
.call_async(store.as_context_mut(), ())
1361
.instrument(span.clone())
1362
.await?;
1363
callee
1364
.post_return_async(store.as_context_mut())
1365
.instrument(span)
1366
.await?;
1367
Ok(ret0)
1368
}
1369
pub async fn call_r3<S: wasmtime::AsContextMut>(
1370
&self,
1371
mut store: S,
1372
) -> wasmtime::Result<u16>
1373
where
1374
<S as wasmtime::AsContext>::Data: Send,
1375
{
1376
use tracing::Instrument;
1377
let span = tracing::span!(
1378
tracing::Level::TRACE, "wit-bindgen export", module =
1379
"foo:foo/integers", function = "r3",
1380
);
1381
let callee = unsafe {
1382
wasmtime::component::TypedFunc::<
1383
(),
1384
(u16,),
1385
>::new_unchecked(self.r3)
1386
};
1387
let (ret0,) = callee
1388
.call_async(store.as_context_mut(), ())
1389
.instrument(span.clone())
1390
.await?;
1391
callee
1392
.post_return_async(store.as_context_mut())
1393
.instrument(span)
1394
.await?;
1395
Ok(ret0)
1396
}
1397
pub async fn call_r4<S: wasmtime::AsContextMut>(
1398
&self,
1399
mut store: S,
1400
) -> wasmtime::Result<i16>
1401
where
1402
<S as wasmtime::AsContext>::Data: Send,
1403
{
1404
use tracing::Instrument;
1405
let span = tracing::span!(
1406
tracing::Level::TRACE, "wit-bindgen export", module =
1407
"foo:foo/integers", function = "r4",
1408
);
1409
let callee = unsafe {
1410
wasmtime::component::TypedFunc::<
1411
(),
1412
(i16,),
1413
>::new_unchecked(self.r4)
1414
};
1415
let (ret0,) = callee
1416
.call_async(store.as_context_mut(), ())
1417
.instrument(span.clone())
1418
.await?;
1419
callee
1420
.post_return_async(store.as_context_mut())
1421
.instrument(span)
1422
.await?;
1423
Ok(ret0)
1424
}
1425
pub async fn call_r5<S: wasmtime::AsContextMut>(
1426
&self,
1427
mut store: S,
1428
) -> wasmtime::Result<u32>
1429
where
1430
<S as wasmtime::AsContext>::Data: Send,
1431
{
1432
use tracing::Instrument;
1433
let span = tracing::span!(
1434
tracing::Level::TRACE, "wit-bindgen export", module =
1435
"foo:foo/integers", function = "r5",
1436
);
1437
let callee = unsafe {
1438
wasmtime::component::TypedFunc::<
1439
(),
1440
(u32,),
1441
>::new_unchecked(self.r5)
1442
};
1443
let (ret0,) = callee
1444
.call_async(store.as_context_mut(), ())
1445
.instrument(span.clone())
1446
.await?;
1447
callee
1448
.post_return_async(store.as_context_mut())
1449
.instrument(span)
1450
.await?;
1451
Ok(ret0)
1452
}
1453
pub async fn call_r6<S: wasmtime::AsContextMut>(
1454
&self,
1455
mut store: S,
1456
) -> wasmtime::Result<i32>
1457
where
1458
<S as wasmtime::AsContext>::Data: Send,
1459
{
1460
use tracing::Instrument;
1461
let span = tracing::span!(
1462
tracing::Level::TRACE, "wit-bindgen export", module =
1463
"foo:foo/integers", function = "r6",
1464
);
1465
let callee = unsafe {
1466
wasmtime::component::TypedFunc::<
1467
(),
1468
(i32,),
1469
>::new_unchecked(self.r6)
1470
};
1471
let (ret0,) = callee
1472
.call_async(store.as_context_mut(), ())
1473
.instrument(span.clone())
1474
.await?;
1475
callee
1476
.post_return_async(store.as_context_mut())
1477
.instrument(span)
1478
.await?;
1479
Ok(ret0)
1480
}
1481
pub async fn call_r7<S: wasmtime::AsContextMut>(
1482
&self,
1483
mut store: S,
1484
) -> wasmtime::Result<u64>
1485
where
1486
<S as wasmtime::AsContext>::Data: Send,
1487
{
1488
use tracing::Instrument;
1489
let span = tracing::span!(
1490
tracing::Level::TRACE, "wit-bindgen export", module =
1491
"foo:foo/integers", function = "r7",
1492
);
1493
let callee = unsafe {
1494
wasmtime::component::TypedFunc::<
1495
(),
1496
(u64,),
1497
>::new_unchecked(self.r7)
1498
};
1499
let (ret0,) = callee
1500
.call_async(store.as_context_mut(), ())
1501
.instrument(span.clone())
1502
.await?;
1503
callee
1504
.post_return_async(store.as_context_mut())
1505
.instrument(span)
1506
.await?;
1507
Ok(ret0)
1508
}
1509
pub async fn call_r8<S: wasmtime::AsContextMut>(
1510
&self,
1511
mut store: S,
1512
) -> wasmtime::Result<i64>
1513
where
1514
<S as wasmtime::AsContext>::Data: Send,
1515
{
1516
use tracing::Instrument;
1517
let span = tracing::span!(
1518
tracing::Level::TRACE, "wit-bindgen export", module =
1519
"foo:foo/integers", function = "r8",
1520
);
1521
let callee = unsafe {
1522
wasmtime::component::TypedFunc::<
1523
(),
1524
(i64,),
1525
>::new_unchecked(self.r8)
1526
};
1527
let (ret0,) = callee
1528
.call_async(store.as_context_mut(), ())
1529
.instrument(span.clone())
1530
.await?;
1531
callee
1532
.post_return_async(store.as_context_mut())
1533
.instrument(span)
1534
.await?;
1535
Ok(ret0)
1536
}
1537
pub async fn call_pair_ret<S: wasmtime::AsContextMut>(
1538
&self,
1539
mut store: S,
1540
) -> wasmtime::Result<(i64, u8)>
1541
where
1542
<S as wasmtime::AsContext>::Data: Send,
1543
{
1544
use tracing::Instrument;
1545
let span = tracing::span!(
1546
tracing::Level::TRACE, "wit-bindgen export", module =
1547
"foo:foo/integers", function = "pair-ret",
1548
);
1549
let callee = unsafe {
1550
wasmtime::component::TypedFunc::<
1551
(),
1552
((i64, u8),),
1553
>::new_unchecked(self.pair_ret)
1554
};
1555
let (ret0,) = callee
1556
.call_async(store.as_context_mut(), ())
1557
.instrument(span.clone())
1558
.await?;
1559
callee
1560
.post_return_async(store.as_context_mut())
1561
.instrument(span)
1562
.await?;
1563
Ok(ret0)
1564
}
1565
}
1566
}
1567
}
1568
}
1569
}
1570
1571