Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/component-macro/tests/expanded/integers_concurrent.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
fn a1<T>(
198
accessor: &wasmtime::component::Accessor<T, Self>,
199
x: u8,
200
) -> impl ::core::future::Future<Output = ()> + Send;
201
fn a2<T>(
202
accessor: &wasmtime::component::Accessor<T, Self>,
203
x: i8,
204
) -> impl ::core::future::Future<Output = ()> + Send;
205
fn a3<T>(
206
accessor: &wasmtime::component::Accessor<T, Self>,
207
x: u16,
208
) -> impl ::core::future::Future<Output = ()> + Send;
209
fn a4<T>(
210
accessor: &wasmtime::component::Accessor<T, Self>,
211
x: i16,
212
) -> impl ::core::future::Future<Output = ()> + Send;
213
fn a5<T>(
214
accessor: &wasmtime::component::Accessor<T, Self>,
215
x: u32,
216
) -> impl ::core::future::Future<Output = ()> + Send;
217
fn a6<T>(
218
accessor: &wasmtime::component::Accessor<T, Self>,
219
x: i32,
220
) -> impl ::core::future::Future<Output = ()> + Send;
221
fn a7<T>(
222
accessor: &wasmtime::component::Accessor<T, Self>,
223
x: u64,
224
) -> impl ::core::future::Future<Output = ()> + Send;
225
fn a8<T>(
226
accessor: &wasmtime::component::Accessor<T, Self>,
227
x: i64,
228
) -> impl ::core::future::Future<Output = ()> + Send;
229
fn a9<T>(
230
accessor: &wasmtime::component::Accessor<T, Self>,
231
p1: u8,
232
p2: i8,
233
p3: u16,
234
p4: i16,
235
p5: u32,
236
p6: i32,
237
p7: u64,
238
p8: i64,
239
) -> impl ::core::future::Future<Output = ()> + Send;
240
fn r1<T>(
241
accessor: &wasmtime::component::Accessor<T, Self>,
242
) -> impl ::core::future::Future<Output = u8> + Send;
243
fn r2<T>(
244
accessor: &wasmtime::component::Accessor<T, Self>,
245
) -> impl ::core::future::Future<Output = i8> + Send;
246
fn r3<T>(
247
accessor: &wasmtime::component::Accessor<T, Self>,
248
) -> impl ::core::future::Future<Output = u16> + Send;
249
fn r4<T>(
250
accessor: &wasmtime::component::Accessor<T, Self>,
251
) -> impl ::core::future::Future<Output = i16> + Send;
252
fn r5<T>(
253
accessor: &wasmtime::component::Accessor<T, Self>,
254
) -> impl ::core::future::Future<Output = u32> + Send;
255
fn r6<T>(
256
accessor: &wasmtime::component::Accessor<T, Self>,
257
) -> impl ::core::future::Future<Output = i32> + Send;
258
fn r7<T>(
259
accessor: &wasmtime::component::Accessor<T, Self>,
260
) -> impl ::core::future::Future<Output = u64> + Send;
261
fn r8<T>(
262
accessor: &wasmtime::component::Accessor<T, Self>,
263
) -> impl ::core::future::Future<Output = i64> + Send;
264
fn pair_ret<T>(
265
accessor: &wasmtime::component::Accessor<T, Self>,
266
) -> impl ::core::future::Future<Output = (i64, u8)> + Send;
267
}
268
pub trait Host: Send {}
269
impl<_T: Host + ?Sized + Send> Host for &mut _T {}
270
pub fn add_to_linker<T, D>(
271
linker: &mut wasmtime::component::Linker<T>,
272
host_getter: fn(&mut T) -> D::Data<'_>,
273
) -> wasmtime::Result<()>
274
where
275
D: HostWithStore,
276
for<'a> D::Data<'a>: Host,
277
T: 'static + Send,
278
{
279
let mut inst = linker.instance("foo:foo/integers")?;
280
inst.func_wrap_concurrent(
281
"a1",
282
move |caller: &wasmtime::component::Accessor<T>, (arg0,): (u8,)| {
283
wasmtime::component::__internal::Box::pin(async move {
284
let host = &caller.with_getter(host_getter);
285
let r = <D as HostWithStore>::a1(host, arg0).await;
286
Ok(r)
287
})
288
},
289
)?;
290
inst.func_wrap_concurrent(
291
"a2",
292
move |caller: &wasmtime::component::Accessor<T>, (arg0,): (i8,)| {
293
wasmtime::component::__internal::Box::pin(async move {
294
let host = &caller.with_getter(host_getter);
295
let r = <D as HostWithStore>::a2(host, arg0).await;
296
Ok(r)
297
})
298
},
299
)?;
300
inst.func_wrap_concurrent(
301
"a3",
302
move |caller: &wasmtime::component::Accessor<T>, (arg0,): (u16,)| {
303
wasmtime::component::__internal::Box::pin(async move {
304
let host = &caller.with_getter(host_getter);
305
let r = <D as HostWithStore>::a3(host, arg0).await;
306
Ok(r)
307
})
308
},
309
)?;
310
inst.func_wrap_concurrent(
311
"a4",
312
move |caller: &wasmtime::component::Accessor<T>, (arg0,): (i16,)| {
313
wasmtime::component::__internal::Box::pin(async move {
314
let host = &caller.with_getter(host_getter);
315
let r = <D as HostWithStore>::a4(host, arg0).await;
316
Ok(r)
317
})
318
},
319
)?;
320
inst.func_wrap_concurrent(
321
"a5",
322
move |caller: &wasmtime::component::Accessor<T>, (arg0,): (u32,)| {
323
wasmtime::component::__internal::Box::pin(async move {
324
let host = &caller.with_getter(host_getter);
325
let r = <D as HostWithStore>::a5(host, arg0).await;
326
Ok(r)
327
})
328
},
329
)?;
330
inst.func_wrap_concurrent(
331
"a6",
332
move |caller: &wasmtime::component::Accessor<T>, (arg0,): (i32,)| {
333
wasmtime::component::__internal::Box::pin(async move {
334
let host = &caller.with_getter(host_getter);
335
let r = <D as HostWithStore>::a6(host, arg0).await;
336
Ok(r)
337
})
338
},
339
)?;
340
inst.func_wrap_concurrent(
341
"a7",
342
move |caller: &wasmtime::component::Accessor<T>, (arg0,): (u64,)| {
343
wasmtime::component::__internal::Box::pin(async move {
344
let host = &caller.with_getter(host_getter);
345
let r = <D as HostWithStore>::a7(host, arg0).await;
346
Ok(r)
347
})
348
},
349
)?;
350
inst.func_wrap_concurrent(
351
"a8",
352
move |caller: &wasmtime::component::Accessor<T>, (arg0,): (i64,)| {
353
wasmtime::component::__internal::Box::pin(async move {
354
let host = &caller.with_getter(host_getter);
355
let r = <D as HostWithStore>::a8(host, arg0).await;
356
Ok(r)
357
})
358
},
359
)?;
360
inst.func_wrap_concurrent(
361
"a9",
362
move |
363
caller: &wasmtime::component::Accessor<T>,
364
(
365
arg0,
366
arg1,
367
arg2,
368
arg3,
369
arg4,
370
arg5,
371
arg6,
372
arg7,
373
): (u8, i8, u16, i16, u32, i32, u64, i64)|
374
{
375
wasmtime::component::__internal::Box::pin(async move {
376
let host = &caller.with_getter(host_getter);
377
let r = <D as HostWithStore>::a9(
378
host,
379
arg0,
380
arg1,
381
arg2,
382
arg3,
383
arg4,
384
arg5,
385
arg6,
386
arg7,
387
)
388
.await;
389
Ok(r)
390
})
391
},
392
)?;
393
inst.func_wrap_concurrent(
394
"r1",
395
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
396
wasmtime::component::__internal::Box::pin(async move {
397
let host = &caller.with_getter(host_getter);
398
let r = <D as HostWithStore>::r1(host).await;
399
Ok((r,))
400
})
401
},
402
)?;
403
inst.func_wrap_concurrent(
404
"r2",
405
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
406
wasmtime::component::__internal::Box::pin(async move {
407
let host = &caller.with_getter(host_getter);
408
let r = <D as HostWithStore>::r2(host).await;
409
Ok((r,))
410
})
411
},
412
)?;
413
inst.func_wrap_concurrent(
414
"r3",
415
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
416
wasmtime::component::__internal::Box::pin(async move {
417
let host = &caller.with_getter(host_getter);
418
let r = <D as HostWithStore>::r3(host).await;
419
Ok((r,))
420
})
421
},
422
)?;
423
inst.func_wrap_concurrent(
424
"r4",
425
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
426
wasmtime::component::__internal::Box::pin(async move {
427
let host = &caller.with_getter(host_getter);
428
let r = <D as HostWithStore>::r4(host).await;
429
Ok((r,))
430
})
431
},
432
)?;
433
inst.func_wrap_concurrent(
434
"r5",
435
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
436
wasmtime::component::__internal::Box::pin(async move {
437
let host = &caller.with_getter(host_getter);
438
let r = <D as HostWithStore>::r5(host).await;
439
Ok((r,))
440
})
441
},
442
)?;
443
inst.func_wrap_concurrent(
444
"r6",
445
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
446
wasmtime::component::__internal::Box::pin(async move {
447
let host = &caller.with_getter(host_getter);
448
let r = <D as HostWithStore>::r6(host).await;
449
Ok((r,))
450
})
451
},
452
)?;
453
inst.func_wrap_concurrent(
454
"r7",
455
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
456
wasmtime::component::__internal::Box::pin(async move {
457
let host = &caller.with_getter(host_getter);
458
let r = <D as HostWithStore>::r7(host).await;
459
Ok((r,))
460
})
461
},
462
)?;
463
inst.func_wrap_concurrent(
464
"r8",
465
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
466
wasmtime::component::__internal::Box::pin(async move {
467
let host = &caller.with_getter(host_getter);
468
let r = <D as HostWithStore>::r8(host).await;
469
Ok((r,))
470
})
471
},
472
)?;
473
inst.func_wrap_concurrent(
474
"pair-ret",
475
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
476
wasmtime::component::__internal::Box::pin(async move {
477
let host = &caller.with_getter(host_getter);
478
let r = <D as HostWithStore>::pair_ret(host).await;
479
Ok((r,))
480
})
481
},
482
)?;
483
Ok(())
484
}
485
}
486
}
487
}
488
pub mod exports {
489
pub mod foo {
490
pub mod foo {
491
#[allow(clippy::all)]
492
pub mod integers {
493
#[allow(unused_imports)]
494
use wasmtime::component::__internal::{anyhow, Box};
495
pub struct Guest {
496
a1: wasmtime::component::Func,
497
a2: wasmtime::component::Func,
498
a3: wasmtime::component::Func,
499
a4: wasmtime::component::Func,
500
a5: wasmtime::component::Func,
501
a6: wasmtime::component::Func,
502
a7: wasmtime::component::Func,
503
a8: wasmtime::component::Func,
504
a9: wasmtime::component::Func,
505
r1: wasmtime::component::Func,
506
r2: wasmtime::component::Func,
507
r3: wasmtime::component::Func,
508
r4: wasmtime::component::Func,
509
r5: wasmtime::component::Func,
510
r6: wasmtime::component::Func,
511
r7: wasmtime::component::Func,
512
r8: wasmtime::component::Func,
513
pair_ret: wasmtime::component::Func,
514
}
515
#[derive(Clone)]
516
pub struct GuestIndices {
517
a1: wasmtime::component::ComponentExportIndex,
518
a2: wasmtime::component::ComponentExportIndex,
519
a3: wasmtime::component::ComponentExportIndex,
520
a4: wasmtime::component::ComponentExportIndex,
521
a5: wasmtime::component::ComponentExportIndex,
522
a6: wasmtime::component::ComponentExportIndex,
523
a7: wasmtime::component::ComponentExportIndex,
524
a8: wasmtime::component::ComponentExportIndex,
525
a9: wasmtime::component::ComponentExportIndex,
526
r1: wasmtime::component::ComponentExportIndex,
527
r2: wasmtime::component::ComponentExportIndex,
528
r3: wasmtime::component::ComponentExportIndex,
529
r4: wasmtime::component::ComponentExportIndex,
530
r5: wasmtime::component::ComponentExportIndex,
531
r6: wasmtime::component::ComponentExportIndex,
532
r7: wasmtime::component::ComponentExportIndex,
533
r8: wasmtime::component::ComponentExportIndex,
534
pair_ret: wasmtime::component::ComponentExportIndex,
535
}
536
impl GuestIndices {
537
/// Constructor for [`GuestIndices`] which takes a
538
/// [`Component`](wasmtime::component::Component) as input and can be executed
539
/// before instantiation.
540
///
541
/// This constructor can be used to front-load string lookups to find exports
542
/// within a component.
543
pub fn new<_T>(
544
_instance_pre: &wasmtime::component::InstancePre<_T>,
545
) -> wasmtime::Result<GuestIndices> {
546
let instance = _instance_pre
547
.component()
548
.get_export_index(None, "foo:foo/integers")
549
.ok_or_else(|| {
550
anyhow::anyhow!(
551
"no exported instance named `foo:foo/integers`"
552
)
553
})?;
554
let mut lookup = move |name| {
555
_instance_pre
556
.component()
557
.get_export_index(Some(&instance), name)
558
.ok_or_else(|| {
559
anyhow::anyhow!(
560
"instance export `foo:foo/integers` does \
561
not have export `{name}`"
562
)
563
})
564
};
565
let _ = &mut lookup;
566
let a1 = lookup("a1")?;
567
let a2 = lookup("a2")?;
568
let a3 = lookup("a3")?;
569
let a4 = lookup("a4")?;
570
let a5 = lookup("a5")?;
571
let a6 = lookup("a6")?;
572
let a7 = lookup("a7")?;
573
let a8 = lookup("a8")?;
574
let a9 = lookup("a9")?;
575
let r1 = lookup("r1")?;
576
let r2 = lookup("r2")?;
577
let r3 = lookup("r3")?;
578
let r4 = lookup("r4")?;
579
let r5 = lookup("r5")?;
580
let r6 = lookup("r6")?;
581
let r7 = lookup("r7")?;
582
let r8 = lookup("r8")?;
583
let pair_ret = lookup("pair-ret")?;
584
Ok(GuestIndices {
585
a1,
586
a2,
587
a3,
588
a4,
589
a5,
590
a6,
591
a7,
592
a8,
593
a9,
594
r1,
595
r2,
596
r3,
597
r4,
598
r5,
599
r6,
600
r7,
601
r8,
602
pair_ret,
603
})
604
}
605
pub fn load(
606
&self,
607
mut store: impl wasmtime::AsContextMut,
608
instance: &wasmtime::component::Instance,
609
) -> wasmtime::Result<Guest> {
610
let _instance = instance;
611
let _instance_pre = _instance.instance_pre(&store);
612
let _instance_type = _instance_pre.instance_type();
613
let mut store = store.as_context_mut();
614
let _ = &mut store;
615
let a1 = *_instance
616
.get_typed_func::<(u8,), ()>(&mut store, &self.a1)?
617
.func();
618
let a2 = *_instance
619
.get_typed_func::<(i8,), ()>(&mut store, &self.a2)?
620
.func();
621
let a3 = *_instance
622
.get_typed_func::<(u16,), ()>(&mut store, &self.a3)?
623
.func();
624
let a4 = *_instance
625
.get_typed_func::<(i16,), ()>(&mut store, &self.a4)?
626
.func();
627
let a5 = *_instance
628
.get_typed_func::<(u32,), ()>(&mut store, &self.a5)?
629
.func();
630
let a6 = *_instance
631
.get_typed_func::<(i32,), ()>(&mut store, &self.a6)?
632
.func();
633
let a7 = *_instance
634
.get_typed_func::<(u64,), ()>(&mut store, &self.a7)?
635
.func();
636
let a8 = *_instance
637
.get_typed_func::<(i64,), ()>(&mut store, &self.a8)?
638
.func();
639
let a9 = *_instance
640
.get_typed_func::<
641
(u8, i8, u16, i16, u32, i32, u64, i64),
642
(),
643
>(&mut store, &self.a9)?
644
.func();
645
let r1 = *_instance
646
.get_typed_func::<(), (u8,)>(&mut store, &self.r1)?
647
.func();
648
let r2 = *_instance
649
.get_typed_func::<(), (i8,)>(&mut store, &self.r2)?
650
.func();
651
let r3 = *_instance
652
.get_typed_func::<(), (u16,)>(&mut store, &self.r3)?
653
.func();
654
let r4 = *_instance
655
.get_typed_func::<(), (i16,)>(&mut store, &self.r4)?
656
.func();
657
let r5 = *_instance
658
.get_typed_func::<(), (u32,)>(&mut store, &self.r5)?
659
.func();
660
let r6 = *_instance
661
.get_typed_func::<(), (i32,)>(&mut store, &self.r6)?
662
.func();
663
let r7 = *_instance
664
.get_typed_func::<(), (u64,)>(&mut store, &self.r7)?
665
.func();
666
let r8 = *_instance
667
.get_typed_func::<(), (i64,)>(&mut store, &self.r8)?
668
.func();
669
let pair_ret = *_instance
670
.get_typed_func::<
671
(),
672
((i64, u8),),
673
>(&mut store, &self.pair_ret)?
674
.func();
675
Ok(Guest {
676
a1,
677
a2,
678
a3,
679
a4,
680
a5,
681
a6,
682
a7,
683
a8,
684
a9,
685
r1,
686
r2,
687
r3,
688
r4,
689
r5,
690
r6,
691
r7,
692
r8,
693
pair_ret,
694
})
695
}
696
}
697
impl Guest {
698
pub async fn call_a1<_T, _D>(
699
&self,
700
accessor: &wasmtime::component::Accessor<_T, _D>,
701
arg0: u8,
702
) -> wasmtime::Result<()>
703
where
704
_T: Send,
705
_D: wasmtime::component::HasData,
706
{
707
let callee = unsafe {
708
wasmtime::component::TypedFunc::<
709
(u8,),
710
(),
711
>::new_unchecked(self.a1)
712
};
713
let () = callee.call_concurrent(accessor, (arg0,)).await?;
714
Ok(())
715
}
716
pub async fn call_a2<_T, _D>(
717
&self,
718
accessor: &wasmtime::component::Accessor<_T, _D>,
719
arg0: i8,
720
) -> wasmtime::Result<()>
721
where
722
_T: Send,
723
_D: wasmtime::component::HasData,
724
{
725
let callee = unsafe {
726
wasmtime::component::TypedFunc::<
727
(i8,),
728
(),
729
>::new_unchecked(self.a2)
730
};
731
let () = callee.call_concurrent(accessor, (arg0,)).await?;
732
Ok(())
733
}
734
pub async fn call_a3<_T, _D>(
735
&self,
736
accessor: &wasmtime::component::Accessor<_T, _D>,
737
arg0: u16,
738
) -> wasmtime::Result<()>
739
where
740
_T: Send,
741
_D: wasmtime::component::HasData,
742
{
743
let callee = unsafe {
744
wasmtime::component::TypedFunc::<
745
(u16,),
746
(),
747
>::new_unchecked(self.a3)
748
};
749
let () = callee.call_concurrent(accessor, (arg0,)).await?;
750
Ok(())
751
}
752
pub async fn call_a4<_T, _D>(
753
&self,
754
accessor: &wasmtime::component::Accessor<_T, _D>,
755
arg0: i16,
756
) -> wasmtime::Result<()>
757
where
758
_T: Send,
759
_D: wasmtime::component::HasData,
760
{
761
let callee = unsafe {
762
wasmtime::component::TypedFunc::<
763
(i16,),
764
(),
765
>::new_unchecked(self.a4)
766
};
767
let () = callee.call_concurrent(accessor, (arg0,)).await?;
768
Ok(())
769
}
770
pub async fn call_a5<_T, _D>(
771
&self,
772
accessor: &wasmtime::component::Accessor<_T, _D>,
773
arg0: u32,
774
) -> wasmtime::Result<()>
775
where
776
_T: Send,
777
_D: wasmtime::component::HasData,
778
{
779
let callee = unsafe {
780
wasmtime::component::TypedFunc::<
781
(u32,),
782
(),
783
>::new_unchecked(self.a5)
784
};
785
let () = callee.call_concurrent(accessor, (arg0,)).await?;
786
Ok(())
787
}
788
pub async fn call_a6<_T, _D>(
789
&self,
790
accessor: &wasmtime::component::Accessor<_T, _D>,
791
arg0: i32,
792
) -> wasmtime::Result<()>
793
where
794
_T: Send,
795
_D: wasmtime::component::HasData,
796
{
797
let callee = unsafe {
798
wasmtime::component::TypedFunc::<
799
(i32,),
800
(),
801
>::new_unchecked(self.a6)
802
};
803
let () = callee.call_concurrent(accessor, (arg0,)).await?;
804
Ok(())
805
}
806
pub async fn call_a7<_T, _D>(
807
&self,
808
accessor: &wasmtime::component::Accessor<_T, _D>,
809
arg0: u64,
810
) -> wasmtime::Result<()>
811
where
812
_T: Send,
813
_D: wasmtime::component::HasData,
814
{
815
let callee = unsafe {
816
wasmtime::component::TypedFunc::<
817
(u64,),
818
(),
819
>::new_unchecked(self.a7)
820
};
821
let () = callee.call_concurrent(accessor, (arg0,)).await?;
822
Ok(())
823
}
824
pub async fn call_a8<_T, _D>(
825
&self,
826
accessor: &wasmtime::component::Accessor<_T, _D>,
827
arg0: i64,
828
) -> wasmtime::Result<()>
829
where
830
_T: Send,
831
_D: wasmtime::component::HasData,
832
{
833
let callee = unsafe {
834
wasmtime::component::TypedFunc::<
835
(i64,),
836
(),
837
>::new_unchecked(self.a8)
838
};
839
let () = callee.call_concurrent(accessor, (arg0,)).await?;
840
Ok(())
841
}
842
pub async fn call_a9<_T, _D>(
843
&self,
844
accessor: &wasmtime::component::Accessor<_T, _D>,
845
arg0: u8,
846
arg1: i8,
847
arg2: u16,
848
arg3: i16,
849
arg4: u32,
850
arg5: i32,
851
arg6: u64,
852
arg7: i64,
853
) -> wasmtime::Result<()>
854
where
855
_T: Send,
856
_D: wasmtime::component::HasData,
857
{
858
let callee = unsafe {
859
wasmtime::component::TypedFunc::<
860
(u8, i8, u16, i16, u32, i32, u64, i64),
861
(),
862
>::new_unchecked(self.a9)
863
};
864
let () = callee
865
.call_concurrent(
866
accessor,
867
(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7),
868
)
869
.await?;
870
Ok(())
871
}
872
pub async fn call_r1<_T, _D>(
873
&self,
874
accessor: &wasmtime::component::Accessor<_T, _D>,
875
) -> wasmtime::Result<u8>
876
where
877
_T: Send,
878
_D: wasmtime::component::HasData,
879
{
880
let callee = unsafe {
881
wasmtime::component::TypedFunc::<
882
(),
883
(u8,),
884
>::new_unchecked(self.r1)
885
};
886
let (ret0,) = callee.call_concurrent(accessor, ()).await?;
887
Ok(ret0)
888
}
889
pub async fn call_r2<_T, _D>(
890
&self,
891
accessor: &wasmtime::component::Accessor<_T, _D>,
892
) -> wasmtime::Result<i8>
893
where
894
_T: Send,
895
_D: wasmtime::component::HasData,
896
{
897
let callee = unsafe {
898
wasmtime::component::TypedFunc::<
899
(),
900
(i8,),
901
>::new_unchecked(self.r2)
902
};
903
let (ret0,) = callee.call_concurrent(accessor, ()).await?;
904
Ok(ret0)
905
}
906
pub async fn call_r3<_T, _D>(
907
&self,
908
accessor: &wasmtime::component::Accessor<_T, _D>,
909
) -> wasmtime::Result<u16>
910
where
911
_T: Send,
912
_D: wasmtime::component::HasData,
913
{
914
let callee = unsafe {
915
wasmtime::component::TypedFunc::<
916
(),
917
(u16,),
918
>::new_unchecked(self.r3)
919
};
920
let (ret0,) = callee.call_concurrent(accessor, ()).await?;
921
Ok(ret0)
922
}
923
pub async fn call_r4<_T, _D>(
924
&self,
925
accessor: &wasmtime::component::Accessor<_T, _D>,
926
) -> wasmtime::Result<i16>
927
where
928
_T: Send,
929
_D: wasmtime::component::HasData,
930
{
931
let callee = unsafe {
932
wasmtime::component::TypedFunc::<
933
(),
934
(i16,),
935
>::new_unchecked(self.r4)
936
};
937
let (ret0,) = callee.call_concurrent(accessor, ()).await?;
938
Ok(ret0)
939
}
940
pub async fn call_r5<_T, _D>(
941
&self,
942
accessor: &wasmtime::component::Accessor<_T, _D>,
943
) -> wasmtime::Result<u32>
944
where
945
_T: Send,
946
_D: wasmtime::component::HasData,
947
{
948
let callee = unsafe {
949
wasmtime::component::TypedFunc::<
950
(),
951
(u32,),
952
>::new_unchecked(self.r5)
953
};
954
let (ret0,) = callee.call_concurrent(accessor, ()).await?;
955
Ok(ret0)
956
}
957
pub async fn call_r6<_T, _D>(
958
&self,
959
accessor: &wasmtime::component::Accessor<_T, _D>,
960
) -> wasmtime::Result<i32>
961
where
962
_T: Send,
963
_D: wasmtime::component::HasData,
964
{
965
let callee = unsafe {
966
wasmtime::component::TypedFunc::<
967
(),
968
(i32,),
969
>::new_unchecked(self.r6)
970
};
971
let (ret0,) = callee.call_concurrent(accessor, ()).await?;
972
Ok(ret0)
973
}
974
pub async fn call_r7<_T, _D>(
975
&self,
976
accessor: &wasmtime::component::Accessor<_T, _D>,
977
) -> wasmtime::Result<u64>
978
where
979
_T: Send,
980
_D: wasmtime::component::HasData,
981
{
982
let callee = unsafe {
983
wasmtime::component::TypedFunc::<
984
(),
985
(u64,),
986
>::new_unchecked(self.r7)
987
};
988
let (ret0,) = callee.call_concurrent(accessor, ()).await?;
989
Ok(ret0)
990
}
991
pub async fn call_r8<_T, _D>(
992
&self,
993
accessor: &wasmtime::component::Accessor<_T, _D>,
994
) -> wasmtime::Result<i64>
995
where
996
_T: Send,
997
_D: wasmtime::component::HasData,
998
{
999
let callee = unsafe {
1000
wasmtime::component::TypedFunc::<
1001
(),
1002
(i64,),
1003
>::new_unchecked(self.r8)
1004
};
1005
let (ret0,) = callee.call_concurrent(accessor, ()).await?;
1006
Ok(ret0)
1007
}
1008
pub async fn call_pair_ret<_T, _D>(
1009
&self,
1010
accessor: &wasmtime::component::Accessor<_T, _D>,
1011
) -> wasmtime::Result<(i64, u8)>
1012
where
1013
_T: Send,
1014
_D: wasmtime::component::HasData,
1015
{
1016
let callee = unsafe {
1017
wasmtime::component::TypedFunc::<
1018
(),
1019
((i64, u8),),
1020
>::new_unchecked(self.pair_ret)
1021
};
1022
let (ret0,) = callee.call_concurrent(accessor, ()).await?;
1023
Ok(ret0)
1024
}
1025
}
1026
}
1027
}
1028
}
1029
}
1030
1031