Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/component-macro/tests/expanded/lists_async.rs
1692 views
1
/// Auto-generated bindings for a pre-instantiated version of a
2
/// component which implements the world `the-lists`.
3
///
4
/// This structure is created through [`TheListsPre::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 [`TheLists`] as well.
9
pub struct TheListsPre<T: 'static> {
10
instance_pre: wasmtime::component::InstancePre<T>,
11
indices: TheListsIndices,
12
}
13
impl<T: 'static> Clone for TheListsPre<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> TheListsPre<_T> {
22
/// Creates a new copy of `TheListsPre` 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 = TheListsIndices::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 [`TheLists`] 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<TheLists> {
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> TheListsPre<_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<TheLists> {
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-lists`.
68
///
69
/// This is an implementation detail of [`TheListsPre`] and can
70
/// be constructed if needed as well.
71
///
72
/// For more information see [`TheLists`] as well.
73
#[derive(Clone)]
74
pub struct TheListsIndices {
75
interface0: exports::foo::foo::lists::GuestIndices,
76
}
77
/// Auto-generated bindings for an instance a component which
78
/// implements the world `the-lists`.
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
/// [`TheLists::instantiate`] which only needs a
85
/// [`Store`], [`Component`], and [`Linker`].
86
///
87
/// * Alternatively you can create a [`TheListsPre`] 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 [`TheListsPre::instantiate`] to
91
/// create a [`TheLists`].
92
///
93
/// * If you've instantiated the instance yourself already
94
/// then you can use [`TheLists::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 TheLists {
103
interface0: exports::foo::foo::lists::Guest,
104
}
105
const _: () = {
106
#[allow(unused_imports)]
107
use wasmtime::component::__internal::anyhow;
108
impl TheListsIndices {
109
/// Creates a new copy of `TheListsIndices` 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::lists::GuestIndices::new(_instance_pre)?;
120
Ok(TheListsIndices { interface0 })
121
}
122
/// Uses the indices stored in `self` to load an instance
123
/// of [`TheLists`] from the instance provided.
124
///
125
/// Note that at this time this method will additionally
126
/// perform type-checks of all exports.
127
pub fn load(
128
&self,
129
mut store: impl wasmtime::AsContextMut,
130
instance: &wasmtime::component::Instance,
131
) -> wasmtime::Result<TheLists> {
132
let _ = &mut store;
133
let _instance = instance;
134
let interface0 = self.interface0.load(&mut store, &_instance)?;
135
Ok(TheLists { interface0 })
136
}
137
}
138
impl TheLists {
139
/// Convenience wrapper around [`TheListsPre::new`] and
140
/// [`TheListsPre::instantiate`].
141
pub fn instantiate<_T>(
142
store: impl wasmtime::AsContextMut<Data = _T>,
143
component: &wasmtime::component::Component,
144
linker: &wasmtime::component::Linker<_T>,
145
) -> wasmtime::Result<TheLists> {
146
let pre = linker.instantiate_pre(component)?;
147
TheListsPre::new(pre)?.instantiate(store)
148
}
149
/// Convenience wrapper around [`TheListsIndices::new`] and
150
/// [`TheListsIndices::load`].
151
pub fn new(
152
mut store: impl wasmtime::AsContextMut,
153
instance: &wasmtime::component::Instance,
154
) -> wasmtime::Result<TheLists> {
155
let indices = TheListsIndices::new(&instance.instance_pre(&store))?;
156
indices.load(&mut store, instance)
157
}
158
/// Convenience wrapper around [`TheListsPre::new`] and
159
/// [`TheListsPre::instantiate_async`].
160
pub async fn instantiate_async<_T>(
161
store: impl wasmtime::AsContextMut<Data = _T>,
162
component: &wasmtime::component::Component,
163
linker: &wasmtime::component::Linker<_T>,
164
) -> wasmtime::Result<TheLists>
165
where
166
_T: Send,
167
{
168
let pre = linker.instantiate_pre(component)?;
169
TheListsPre::new(pre)?.instantiate_async(store).await
170
}
171
pub fn add_to_linker<T, D>(
172
linker: &mut wasmtime::component::Linker<T>,
173
host_getter: fn(&mut T) -> D::Data<'_>,
174
) -> wasmtime::Result<()>
175
where
176
D: foo::foo::lists::HostWithStore + Send,
177
for<'a> D::Data<'a>: foo::foo::lists::Host + Send,
178
T: 'static + Send,
179
{
180
foo::foo::lists::add_to_linker::<T, D>(linker, host_getter)?;
181
Ok(())
182
}
183
pub fn foo_foo_lists(&self) -> &exports::foo::foo::lists::Guest {
184
&self.interface0
185
}
186
}
187
};
188
pub mod foo {
189
pub mod foo {
190
#[allow(clippy::all)]
191
pub mod lists {
192
#[allow(unused_imports)]
193
use wasmtime::component::__internal::{anyhow, Box};
194
#[derive(wasmtime::component::ComponentType)]
195
#[derive(wasmtime::component::Lift)]
196
#[derive(wasmtime::component::Lower)]
197
#[component(record)]
198
#[derive(Clone)]
199
pub struct OtherRecord {
200
#[component(name = "a1")]
201
pub a1: u32,
202
#[component(name = "a2")]
203
pub a2: u64,
204
#[component(name = "a3")]
205
pub a3: i32,
206
#[component(name = "a4")]
207
pub a4: i64,
208
#[component(name = "b")]
209
pub b: wasmtime::component::__internal::String,
210
#[component(name = "c")]
211
pub c: wasmtime::component::__internal::Vec<u8>,
212
}
213
impl core::fmt::Debug for OtherRecord {
214
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
215
f.debug_struct("OtherRecord")
216
.field("a1", &self.a1)
217
.field("a2", &self.a2)
218
.field("a3", &self.a3)
219
.field("a4", &self.a4)
220
.field("b", &self.b)
221
.field("c", &self.c)
222
.finish()
223
}
224
}
225
const _: () = {
226
assert!(
227
48 == < OtherRecord as wasmtime::component::ComponentType >::SIZE32
228
);
229
assert!(
230
8 == < OtherRecord as wasmtime::component::ComponentType >::ALIGN32
231
);
232
};
233
#[derive(wasmtime::component::ComponentType)]
234
#[derive(wasmtime::component::Lift)]
235
#[derive(wasmtime::component::Lower)]
236
#[component(record)]
237
#[derive(Clone)]
238
pub struct SomeRecord {
239
#[component(name = "x")]
240
pub x: wasmtime::component::__internal::String,
241
#[component(name = "y")]
242
pub y: OtherRecord,
243
#[component(name = "z")]
244
pub z: wasmtime::component::__internal::Vec<OtherRecord>,
245
#[component(name = "c1")]
246
pub c1: u32,
247
#[component(name = "c2")]
248
pub c2: u64,
249
#[component(name = "c3")]
250
pub c3: i32,
251
#[component(name = "c4")]
252
pub c4: i64,
253
}
254
impl core::fmt::Debug for SomeRecord {
255
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
256
f.debug_struct("SomeRecord")
257
.field("x", &self.x)
258
.field("y", &self.y)
259
.field("z", &self.z)
260
.field("c1", &self.c1)
261
.field("c2", &self.c2)
262
.field("c3", &self.c3)
263
.field("c4", &self.c4)
264
.finish()
265
}
266
}
267
const _: () = {
268
assert!(
269
96 == < SomeRecord as wasmtime::component::ComponentType >::SIZE32
270
);
271
assert!(
272
8 == < SomeRecord as wasmtime::component::ComponentType >::ALIGN32
273
);
274
};
275
#[derive(wasmtime::component::ComponentType)]
276
#[derive(wasmtime::component::Lift)]
277
#[derive(wasmtime::component::Lower)]
278
#[component(variant)]
279
#[derive(Clone)]
280
pub enum OtherVariant {
281
#[component(name = "a")]
282
A,
283
#[component(name = "b")]
284
B(u32),
285
#[component(name = "c")]
286
C(wasmtime::component::__internal::String),
287
}
288
impl core::fmt::Debug for OtherVariant {
289
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
290
match self {
291
OtherVariant::A => f.debug_tuple("OtherVariant::A").finish(),
292
OtherVariant::B(e) => {
293
f.debug_tuple("OtherVariant::B").field(e).finish()
294
}
295
OtherVariant::C(e) => {
296
f.debug_tuple("OtherVariant::C").field(e).finish()
297
}
298
}
299
}
300
}
301
const _: () = {
302
assert!(
303
12 == < OtherVariant as wasmtime::component::ComponentType >::SIZE32
304
);
305
assert!(
306
4 == < OtherVariant as wasmtime::component::ComponentType >::ALIGN32
307
);
308
};
309
#[derive(wasmtime::component::ComponentType)]
310
#[derive(wasmtime::component::Lift)]
311
#[derive(wasmtime::component::Lower)]
312
#[component(variant)]
313
#[derive(Clone)]
314
pub enum SomeVariant {
315
#[component(name = "a")]
316
A(wasmtime::component::__internal::String),
317
#[component(name = "b")]
318
B,
319
#[component(name = "c")]
320
C(u32),
321
#[component(name = "d")]
322
D(wasmtime::component::__internal::Vec<OtherVariant>),
323
}
324
impl core::fmt::Debug for SomeVariant {
325
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
326
match self {
327
SomeVariant::A(e) => {
328
f.debug_tuple("SomeVariant::A").field(e).finish()
329
}
330
SomeVariant::B => f.debug_tuple("SomeVariant::B").finish(),
331
SomeVariant::C(e) => {
332
f.debug_tuple("SomeVariant::C").field(e).finish()
333
}
334
SomeVariant::D(e) => {
335
f.debug_tuple("SomeVariant::D").field(e).finish()
336
}
337
}
338
}
339
}
340
const _: () = {
341
assert!(
342
12 == < SomeVariant as wasmtime::component::ComponentType >::SIZE32
343
);
344
assert!(
345
4 == < SomeVariant as wasmtime::component::ComponentType >::ALIGN32
346
);
347
};
348
pub type LoadStoreAllSizes = wasmtime::component::__internal::Vec<
349
(
350
wasmtime::component::__internal::String,
351
u8,
352
i8,
353
u16,
354
i16,
355
u32,
356
i32,
357
u64,
358
i64,
359
f32,
360
f64,
361
char,
362
),
363
>;
364
const _: () = {
365
assert!(
366
8 == < LoadStoreAllSizes as wasmtime::component::ComponentType
367
>::SIZE32
368
);
369
assert!(
370
4 == < LoadStoreAllSizes as wasmtime::component::ComponentType
371
>::ALIGN32
372
);
373
};
374
pub trait HostWithStore: wasmtime::component::HasData + Send {}
375
impl<_T: ?Sized> HostWithStore for _T
376
where
377
_T: wasmtime::component::HasData + Send,
378
{}
379
pub trait Host: Send {
380
fn list_u8_param(
381
&mut self,
382
x: wasmtime::component::__internal::Vec<u8>,
383
) -> impl ::core::future::Future<Output = ()> + Send;
384
fn list_u16_param(
385
&mut self,
386
x: wasmtime::component::__internal::Vec<u16>,
387
) -> impl ::core::future::Future<Output = ()> + Send;
388
fn list_u32_param(
389
&mut self,
390
x: wasmtime::component::__internal::Vec<u32>,
391
) -> impl ::core::future::Future<Output = ()> + Send;
392
fn list_u64_param(
393
&mut self,
394
x: wasmtime::component::__internal::Vec<u64>,
395
) -> impl ::core::future::Future<Output = ()> + Send;
396
fn list_s8_param(
397
&mut self,
398
x: wasmtime::component::__internal::Vec<i8>,
399
) -> impl ::core::future::Future<Output = ()> + Send;
400
fn list_s16_param(
401
&mut self,
402
x: wasmtime::component::__internal::Vec<i16>,
403
) -> impl ::core::future::Future<Output = ()> + Send;
404
fn list_s32_param(
405
&mut self,
406
x: wasmtime::component::__internal::Vec<i32>,
407
) -> impl ::core::future::Future<Output = ()> + Send;
408
fn list_s64_param(
409
&mut self,
410
x: wasmtime::component::__internal::Vec<i64>,
411
) -> impl ::core::future::Future<Output = ()> + Send;
412
fn list_f32_param(
413
&mut self,
414
x: wasmtime::component::__internal::Vec<f32>,
415
) -> impl ::core::future::Future<Output = ()> + Send;
416
fn list_f64_param(
417
&mut self,
418
x: wasmtime::component::__internal::Vec<f64>,
419
) -> impl ::core::future::Future<Output = ()> + Send;
420
fn list_u8_ret(
421
&mut self,
422
) -> impl ::core::future::Future<
423
Output = wasmtime::component::__internal::Vec<u8>,
424
> + Send;
425
fn list_u16_ret(
426
&mut self,
427
) -> impl ::core::future::Future<
428
Output = wasmtime::component::__internal::Vec<u16>,
429
> + Send;
430
fn list_u32_ret(
431
&mut self,
432
) -> impl ::core::future::Future<
433
Output = wasmtime::component::__internal::Vec<u32>,
434
> + Send;
435
fn list_u64_ret(
436
&mut self,
437
) -> impl ::core::future::Future<
438
Output = wasmtime::component::__internal::Vec<u64>,
439
> + Send;
440
fn list_s8_ret(
441
&mut self,
442
) -> impl ::core::future::Future<
443
Output = wasmtime::component::__internal::Vec<i8>,
444
> + Send;
445
fn list_s16_ret(
446
&mut self,
447
) -> impl ::core::future::Future<
448
Output = wasmtime::component::__internal::Vec<i16>,
449
> + Send;
450
fn list_s32_ret(
451
&mut self,
452
) -> impl ::core::future::Future<
453
Output = wasmtime::component::__internal::Vec<i32>,
454
> + Send;
455
fn list_s64_ret(
456
&mut self,
457
) -> impl ::core::future::Future<
458
Output = wasmtime::component::__internal::Vec<i64>,
459
> + Send;
460
fn list_f32_ret(
461
&mut self,
462
) -> impl ::core::future::Future<
463
Output = wasmtime::component::__internal::Vec<f32>,
464
> + Send;
465
fn list_f64_ret(
466
&mut self,
467
) -> impl ::core::future::Future<
468
Output = wasmtime::component::__internal::Vec<f64>,
469
> + Send;
470
fn tuple_list(
471
&mut self,
472
x: wasmtime::component::__internal::Vec<(u8, i8)>,
473
) -> impl ::core::future::Future<
474
Output = wasmtime::component::__internal::Vec<(i64, u32)>,
475
> + Send;
476
fn string_list_arg(
477
&mut self,
478
a: wasmtime::component::__internal::Vec<
479
wasmtime::component::__internal::String,
480
>,
481
) -> impl ::core::future::Future<Output = ()> + Send;
482
fn string_list_ret(
483
&mut self,
484
) -> impl ::core::future::Future<
485
Output = wasmtime::component::__internal::Vec<
486
wasmtime::component::__internal::String,
487
>,
488
> + Send;
489
fn tuple_string_list(
490
&mut self,
491
x: wasmtime::component::__internal::Vec<
492
(u8, wasmtime::component::__internal::String),
493
>,
494
) -> impl ::core::future::Future<
495
Output = wasmtime::component::__internal::Vec<
496
(wasmtime::component::__internal::String, u8),
497
>,
498
> + Send;
499
fn string_list(
500
&mut self,
501
x: wasmtime::component::__internal::Vec<
502
wasmtime::component::__internal::String,
503
>,
504
) -> impl ::core::future::Future<
505
Output = wasmtime::component::__internal::Vec<
506
wasmtime::component::__internal::String,
507
>,
508
> + Send;
509
fn record_list(
510
&mut self,
511
x: wasmtime::component::__internal::Vec<SomeRecord>,
512
) -> impl ::core::future::Future<
513
Output = wasmtime::component::__internal::Vec<OtherRecord>,
514
> + Send;
515
fn record_list_reverse(
516
&mut self,
517
x: wasmtime::component::__internal::Vec<OtherRecord>,
518
) -> impl ::core::future::Future<
519
Output = wasmtime::component::__internal::Vec<SomeRecord>,
520
> + Send;
521
fn variant_list(
522
&mut self,
523
x: wasmtime::component::__internal::Vec<SomeVariant>,
524
) -> impl ::core::future::Future<
525
Output = wasmtime::component::__internal::Vec<OtherVariant>,
526
> + Send;
527
fn load_store_everything(
528
&mut self,
529
a: LoadStoreAllSizes,
530
) -> impl ::core::future::Future<Output = LoadStoreAllSizes> + Send;
531
}
532
impl<_T: Host + ?Sized + Send> Host for &mut _T {
533
fn list_u8_param(
534
&mut self,
535
x: wasmtime::component::__internal::Vec<u8>,
536
) -> impl ::core::future::Future<Output = ()> + Send {
537
async move { Host::list_u8_param(*self, x).await }
538
}
539
fn list_u16_param(
540
&mut self,
541
x: wasmtime::component::__internal::Vec<u16>,
542
) -> impl ::core::future::Future<Output = ()> + Send {
543
async move { Host::list_u16_param(*self, x).await }
544
}
545
fn list_u32_param(
546
&mut self,
547
x: wasmtime::component::__internal::Vec<u32>,
548
) -> impl ::core::future::Future<Output = ()> + Send {
549
async move { Host::list_u32_param(*self, x).await }
550
}
551
fn list_u64_param(
552
&mut self,
553
x: wasmtime::component::__internal::Vec<u64>,
554
) -> impl ::core::future::Future<Output = ()> + Send {
555
async move { Host::list_u64_param(*self, x).await }
556
}
557
fn list_s8_param(
558
&mut self,
559
x: wasmtime::component::__internal::Vec<i8>,
560
) -> impl ::core::future::Future<Output = ()> + Send {
561
async move { Host::list_s8_param(*self, x).await }
562
}
563
fn list_s16_param(
564
&mut self,
565
x: wasmtime::component::__internal::Vec<i16>,
566
) -> impl ::core::future::Future<Output = ()> + Send {
567
async move { Host::list_s16_param(*self, x).await }
568
}
569
fn list_s32_param(
570
&mut self,
571
x: wasmtime::component::__internal::Vec<i32>,
572
) -> impl ::core::future::Future<Output = ()> + Send {
573
async move { Host::list_s32_param(*self, x).await }
574
}
575
fn list_s64_param(
576
&mut self,
577
x: wasmtime::component::__internal::Vec<i64>,
578
) -> impl ::core::future::Future<Output = ()> + Send {
579
async move { Host::list_s64_param(*self, x).await }
580
}
581
fn list_f32_param(
582
&mut self,
583
x: wasmtime::component::__internal::Vec<f32>,
584
) -> impl ::core::future::Future<Output = ()> + Send {
585
async move { Host::list_f32_param(*self, x).await }
586
}
587
fn list_f64_param(
588
&mut self,
589
x: wasmtime::component::__internal::Vec<f64>,
590
) -> impl ::core::future::Future<Output = ()> + Send {
591
async move { Host::list_f64_param(*self, x).await }
592
}
593
fn list_u8_ret(
594
&mut self,
595
) -> impl ::core::future::Future<
596
Output = wasmtime::component::__internal::Vec<u8>,
597
> + Send {
598
async move { Host::list_u8_ret(*self).await }
599
}
600
fn list_u16_ret(
601
&mut self,
602
) -> impl ::core::future::Future<
603
Output = wasmtime::component::__internal::Vec<u16>,
604
> + Send {
605
async move { Host::list_u16_ret(*self).await }
606
}
607
fn list_u32_ret(
608
&mut self,
609
) -> impl ::core::future::Future<
610
Output = wasmtime::component::__internal::Vec<u32>,
611
> + Send {
612
async move { Host::list_u32_ret(*self).await }
613
}
614
fn list_u64_ret(
615
&mut self,
616
) -> impl ::core::future::Future<
617
Output = wasmtime::component::__internal::Vec<u64>,
618
> + Send {
619
async move { Host::list_u64_ret(*self).await }
620
}
621
fn list_s8_ret(
622
&mut self,
623
) -> impl ::core::future::Future<
624
Output = wasmtime::component::__internal::Vec<i8>,
625
> + Send {
626
async move { Host::list_s8_ret(*self).await }
627
}
628
fn list_s16_ret(
629
&mut self,
630
) -> impl ::core::future::Future<
631
Output = wasmtime::component::__internal::Vec<i16>,
632
> + Send {
633
async move { Host::list_s16_ret(*self).await }
634
}
635
fn list_s32_ret(
636
&mut self,
637
) -> impl ::core::future::Future<
638
Output = wasmtime::component::__internal::Vec<i32>,
639
> + Send {
640
async move { Host::list_s32_ret(*self).await }
641
}
642
fn list_s64_ret(
643
&mut self,
644
) -> impl ::core::future::Future<
645
Output = wasmtime::component::__internal::Vec<i64>,
646
> + Send {
647
async move { Host::list_s64_ret(*self).await }
648
}
649
fn list_f32_ret(
650
&mut self,
651
) -> impl ::core::future::Future<
652
Output = wasmtime::component::__internal::Vec<f32>,
653
> + Send {
654
async move { Host::list_f32_ret(*self).await }
655
}
656
fn list_f64_ret(
657
&mut self,
658
) -> impl ::core::future::Future<
659
Output = wasmtime::component::__internal::Vec<f64>,
660
> + Send {
661
async move { Host::list_f64_ret(*self).await }
662
}
663
fn tuple_list(
664
&mut self,
665
x: wasmtime::component::__internal::Vec<(u8, i8)>,
666
) -> impl ::core::future::Future<
667
Output = wasmtime::component::__internal::Vec<(i64, u32)>,
668
> + Send {
669
async move { Host::tuple_list(*self, x).await }
670
}
671
fn string_list_arg(
672
&mut self,
673
a: wasmtime::component::__internal::Vec<
674
wasmtime::component::__internal::String,
675
>,
676
) -> impl ::core::future::Future<Output = ()> + Send {
677
async move { Host::string_list_arg(*self, a).await }
678
}
679
fn string_list_ret(
680
&mut self,
681
) -> impl ::core::future::Future<
682
Output = wasmtime::component::__internal::Vec<
683
wasmtime::component::__internal::String,
684
>,
685
> + Send {
686
async move { Host::string_list_ret(*self).await }
687
}
688
fn tuple_string_list(
689
&mut self,
690
x: wasmtime::component::__internal::Vec<
691
(u8, wasmtime::component::__internal::String),
692
>,
693
) -> impl ::core::future::Future<
694
Output = wasmtime::component::__internal::Vec<
695
(wasmtime::component::__internal::String, u8),
696
>,
697
> + Send {
698
async move { Host::tuple_string_list(*self, x).await }
699
}
700
fn string_list(
701
&mut self,
702
x: wasmtime::component::__internal::Vec<
703
wasmtime::component::__internal::String,
704
>,
705
) -> impl ::core::future::Future<
706
Output = wasmtime::component::__internal::Vec<
707
wasmtime::component::__internal::String,
708
>,
709
> + Send {
710
async move { Host::string_list(*self, x).await }
711
}
712
fn record_list(
713
&mut self,
714
x: wasmtime::component::__internal::Vec<SomeRecord>,
715
) -> impl ::core::future::Future<
716
Output = wasmtime::component::__internal::Vec<OtherRecord>,
717
> + Send {
718
async move { Host::record_list(*self, x).await }
719
}
720
fn record_list_reverse(
721
&mut self,
722
x: wasmtime::component::__internal::Vec<OtherRecord>,
723
) -> impl ::core::future::Future<
724
Output = wasmtime::component::__internal::Vec<SomeRecord>,
725
> + Send {
726
async move { Host::record_list_reverse(*self, x).await }
727
}
728
fn variant_list(
729
&mut self,
730
x: wasmtime::component::__internal::Vec<SomeVariant>,
731
) -> impl ::core::future::Future<
732
Output = wasmtime::component::__internal::Vec<OtherVariant>,
733
> + Send {
734
async move { Host::variant_list(*self, x).await }
735
}
736
fn load_store_everything(
737
&mut self,
738
a: LoadStoreAllSizes,
739
) -> impl ::core::future::Future<Output = LoadStoreAllSizes> + Send {
740
async move { Host::load_store_everything(*self, a).await }
741
}
742
}
743
pub fn add_to_linker<T, D>(
744
linker: &mut wasmtime::component::Linker<T>,
745
host_getter: fn(&mut T) -> D::Data<'_>,
746
) -> wasmtime::Result<()>
747
where
748
D: HostWithStore,
749
for<'a> D::Data<'a>: Host,
750
T: 'static + Send,
751
{
752
let mut inst = linker.instance("foo:foo/lists")?;
753
inst.func_wrap_async(
754
"list-u8-param",
755
move |
756
mut caller: wasmtime::StoreContextMut<'_, T>,
757
(arg0,): (wasmtime::component::__internal::Vec<u8>,)|
758
{
759
wasmtime::component::__internal::Box::new(async move {
760
let host = &mut host_getter(caller.data_mut());
761
let r = Host::list_u8_param(host, arg0).await;
762
Ok(r)
763
})
764
},
765
)?;
766
inst.func_wrap_async(
767
"list-u16-param",
768
move |
769
mut caller: wasmtime::StoreContextMut<'_, T>,
770
(arg0,): (wasmtime::component::__internal::Vec<u16>,)|
771
{
772
wasmtime::component::__internal::Box::new(async move {
773
let host = &mut host_getter(caller.data_mut());
774
let r = Host::list_u16_param(host, arg0).await;
775
Ok(r)
776
})
777
},
778
)?;
779
inst.func_wrap_async(
780
"list-u32-param",
781
move |
782
mut caller: wasmtime::StoreContextMut<'_, T>,
783
(arg0,): (wasmtime::component::__internal::Vec<u32>,)|
784
{
785
wasmtime::component::__internal::Box::new(async move {
786
let host = &mut host_getter(caller.data_mut());
787
let r = Host::list_u32_param(host, arg0).await;
788
Ok(r)
789
})
790
},
791
)?;
792
inst.func_wrap_async(
793
"list-u64-param",
794
move |
795
mut caller: wasmtime::StoreContextMut<'_, T>,
796
(arg0,): (wasmtime::component::__internal::Vec<u64>,)|
797
{
798
wasmtime::component::__internal::Box::new(async move {
799
let host = &mut host_getter(caller.data_mut());
800
let r = Host::list_u64_param(host, arg0).await;
801
Ok(r)
802
})
803
},
804
)?;
805
inst.func_wrap_async(
806
"list-s8-param",
807
move |
808
mut caller: wasmtime::StoreContextMut<'_, T>,
809
(arg0,): (wasmtime::component::__internal::Vec<i8>,)|
810
{
811
wasmtime::component::__internal::Box::new(async move {
812
let host = &mut host_getter(caller.data_mut());
813
let r = Host::list_s8_param(host, arg0).await;
814
Ok(r)
815
})
816
},
817
)?;
818
inst.func_wrap_async(
819
"list-s16-param",
820
move |
821
mut caller: wasmtime::StoreContextMut<'_, T>,
822
(arg0,): (wasmtime::component::__internal::Vec<i16>,)|
823
{
824
wasmtime::component::__internal::Box::new(async move {
825
let host = &mut host_getter(caller.data_mut());
826
let r = Host::list_s16_param(host, arg0).await;
827
Ok(r)
828
})
829
},
830
)?;
831
inst.func_wrap_async(
832
"list-s32-param",
833
move |
834
mut caller: wasmtime::StoreContextMut<'_, T>,
835
(arg0,): (wasmtime::component::__internal::Vec<i32>,)|
836
{
837
wasmtime::component::__internal::Box::new(async move {
838
let host = &mut host_getter(caller.data_mut());
839
let r = Host::list_s32_param(host, arg0).await;
840
Ok(r)
841
})
842
},
843
)?;
844
inst.func_wrap_async(
845
"list-s64-param",
846
move |
847
mut caller: wasmtime::StoreContextMut<'_, T>,
848
(arg0,): (wasmtime::component::__internal::Vec<i64>,)|
849
{
850
wasmtime::component::__internal::Box::new(async move {
851
let host = &mut host_getter(caller.data_mut());
852
let r = Host::list_s64_param(host, arg0).await;
853
Ok(r)
854
})
855
},
856
)?;
857
inst.func_wrap_async(
858
"list-f32-param",
859
move |
860
mut caller: wasmtime::StoreContextMut<'_, T>,
861
(arg0,): (wasmtime::component::__internal::Vec<f32>,)|
862
{
863
wasmtime::component::__internal::Box::new(async move {
864
let host = &mut host_getter(caller.data_mut());
865
let r = Host::list_f32_param(host, arg0).await;
866
Ok(r)
867
})
868
},
869
)?;
870
inst.func_wrap_async(
871
"list-f64-param",
872
move |
873
mut caller: wasmtime::StoreContextMut<'_, T>,
874
(arg0,): (wasmtime::component::__internal::Vec<f64>,)|
875
{
876
wasmtime::component::__internal::Box::new(async move {
877
let host = &mut host_getter(caller.data_mut());
878
let r = Host::list_f64_param(host, arg0).await;
879
Ok(r)
880
})
881
},
882
)?;
883
inst.func_wrap_async(
884
"list-u8-ret",
885
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
886
wasmtime::component::__internal::Box::new(async move {
887
let host = &mut host_getter(caller.data_mut());
888
let r = Host::list_u8_ret(host).await;
889
Ok((r,))
890
})
891
},
892
)?;
893
inst.func_wrap_async(
894
"list-u16-ret",
895
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
896
wasmtime::component::__internal::Box::new(async move {
897
let host = &mut host_getter(caller.data_mut());
898
let r = Host::list_u16_ret(host).await;
899
Ok((r,))
900
})
901
},
902
)?;
903
inst.func_wrap_async(
904
"list-u32-ret",
905
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
906
wasmtime::component::__internal::Box::new(async move {
907
let host = &mut host_getter(caller.data_mut());
908
let r = Host::list_u32_ret(host).await;
909
Ok((r,))
910
})
911
},
912
)?;
913
inst.func_wrap_async(
914
"list-u64-ret",
915
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
916
wasmtime::component::__internal::Box::new(async move {
917
let host = &mut host_getter(caller.data_mut());
918
let r = Host::list_u64_ret(host).await;
919
Ok((r,))
920
})
921
},
922
)?;
923
inst.func_wrap_async(
924
"list-s8-ret",
925
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
926
wasmtime::component::__internal::Box::new(async move {
927
let host = &mut host_getter(caller.data_mut());
928
let r = Host::list_s8_ret(host).await;
929
Ok((r,))
930
})
931
},
932
)?;
933
inst.func_wrap_async(
934
"list-s16-ret",
935
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
936
wasmtime::component::__internal::Box::new(async move {
937
let host = &mut host_getter(caller.data_mut());
938
let r = Host::list_s16_ret(host).await;
939
Ok((r,))
940
})
941
},
942
)?;
943
inst.func_wrap_async(
944
"list-s32-ret",
945
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
946
wasmtime::component::__internal::Box::new(async move {
947
let host = &mut host_getter(caller.data_mut());
948
let r = Host::list_s32_ret(host).await;
949
Ok((r,))
950
})
951
},
952
)?;
953
inst.func_wrap_async(
954
"list-s64-ret",
955
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
956
wasmtime::component::__internal::Box::new(async move {
957
let host = &mut host_getter(caller.data_mut());
958
let r = Host::list_s64_ret(host).await;
959
Ok((r,))
960
})
961
},
962
)?;
963
inst.func_wrap_async(
964
"list-f32-ret",
965
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
966
wasmtime::component::__internal::Box::new(async move {
967
let host = &mut host_getter(caller.data_mut());
968
let r = Host::list_f32_ret(host).await;
969
Ok((r,))
970
})
971
},
972
)?;
973
inst.func_wrap_async(
974
"list-f64-ret",
975
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
976
wasmtime::component::__internal::Box::new(async move {
977
let host = &mut host_getter(caller.data_mut());
978
let r = Host::list_f64_ret(host).await;
979
Ok((r,))
980
})
981
},
982
)?;
983
inst.func_wrap_async(
984
"tuple-list",
985
move |
986
mut caller: wasmtime::StoreContextMut<'_, T>,
987
(arg0,): (wasmtime::component::__internal::Vec<(u8, i8)>,)|
988
{
989
wasmtime::component::__internal::Box::new(async move {
990
let host = &mut host_getter(caller.data_mut());
991
let r = Host::tuple_list(host, arg0).await;
992
Ok((r,))
993
})
994
},
995
)?;
996
inst.func_wrap_async(
997
"string-list-arg",
998
move |
999
mut caller: wasmtime::StoreContextMut<'_, T>,
1000
(
1001
arg0,
1002
): (
1003
wasmtime::component::__internal::Vec<
1004
wasmtime::component::__internal::String,
1005
>,
1006
)|
1007
{
1008
wasmtime::component::__internal::Box::new(async move {
1009
let host = &mut host_getter(caller.data_mut());
1010
let r = Host::string_list_arg(host, arg0).await;
1011
Ok(r)
1012
})
1013
},
1014
)?;
1015
inst.func_wrap_async(
1016
"string-list-ret",
1017
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
1018
wasmtime::component::__internal::Box::new(async move {
1019
let host = &mut host_getter(caller.data_mut());
1020
let r = Host::string_list_ret(host).await;
1021
Ok((r,))
1022
})
1023
},
1024
)?;
1025
inst.func_wrap_async(
1026
"tuple-string-list",
1027
move |
1028
mut caller: wasmtime::StoreContextMut<'_, T>,
1029
(
1030
arg0,
1031
): (
1032
wasmtime::component::__internal::Vec<
1033
(u8, wasmtime::component::__internal::String),
1034
>,
1035
)|
1036
{
1037
wasmtime::component::__internal::Box::new(async move {
1038
let host = &mut host_getter(caller.data_mut());
1039
let r = Host::tuple_string_list(host, arg0).await;
1040
Ok((r,))
1041
})
1042
},
1043
)?;
1044
inst.func_wrap_async(
1045
"string-list",
1046
move |
1047
mut caller: wasmtime::StoreContextMut<'_, T>,
1048
(
1049
arg0,
1050
): (
1051
wasmtime::component::__internal::Vec<
1052
wasmtime::component::__internal::String,
1053
>,
1054
)|
1055
{
1056
wasmtime::component::__internal::Box::new(async move {
1057
let host = &mut host_getter(caller.data_mut());
1058
let r = Host::string_list(host, arg0).await;
1059
Ok((r,))
1060
})
1061
},
1062
)?;
1063
inst.func_wrap_async(
1064
"record-list",
1065
move |
1066
mut caller: wasmtime::StoreContextMut<'_, T>,
1067
(arg0,): (wasmtime::component::__internal::Vec<SomeRecord>,)|
1068
{
1069
wasmtime::component::__internal::Box::new(async move {
1070
let host = &mut host_getter(caller.data_mut());
1071
let r = Host::record_list(host, arg0).await;
1072
Ok((r,))
1073
})
1074
},
1075
)?;
1076
inst.func_wrap_async(
1077
"record-list-reverse",
1078
move |
1079
mut caller: wasmtime::StoreContextMut<'_, T>,
1080
(arg0,): (wasmtime::component::__internal::Vec<OtherRecord>,)|
1081
{
1082
wasmtime::component::__internal::Box::new(async move {
1083
let host = &mut host_getter(caller.data_mut());
1084
let r = Host::record_list_reverse(host, arg0).await;
1085
Ok((r,))
1086
})
1087
},
1088
)?;
1089
inst.func_wrap_async(
1090
"variant-list",
1091
move |
1092
mut caller: wasmtime::StoreContextMut<'_, T>,
1093
(arg0,): (wasmtime::component::__internal::Vec<SomeVariant>,)|
1094
{
1095
wasmtime::component::__internal::Box::new(async move {
1096
let host = &mut host_getter(caller.data_mut());
1097
let r = Host::variant_list(host, arg0).await;
1098
Ok((r,))
1099
})
1100
},
1101
)?;
1102
inst.func_wrap_async(
1103
"load-store-everything",
1104
move |
1105
mut caller: wasmtime::StoreContextMut<'_, T>,
1106
(arg0,): (LoadStoreAllSizes,)|
1107
{
1108
wasmtime::component::__internal::Box::new(async move {
1109
let host = &mut host_getter(caller.data_mut());
1110
let r = Host::load_store_everything(host, arg0).await;
1111
Ok((r,))
1112
})
1113
},
1114
)?;
1115
Ok(())
1116
}
1117
}
1118
}
1119
}
1120
pub mod exports {
1121
pub mod foo {
1122
pub mod foo {
1123
#[allow(clippy::all)]
1124
pub mod lists {
1125
#[allow(unused_imports)]
1126
use wasmtime::component::__internal::{anyhow, Box};
1127
#[derive(wasmtime::component::ComponentType)]
1128
#[derive(wasmtime::component::Lift)]
1129
#[derive(wasmtime::component::Lower)]
1130
#[component(record)]
1131
#[derive(Clone)]
1132
pub struct OtherRecord {
1133
#[component(name = "a1")]
1134
pub a1: u32,
1135
#[component(name = "a2")]
1136
pub a2: u64,
1137
#[component(name = "a3")]
1138
pub a3: i32,
1139
#[component(name = "a4")]
1140
pub a4: i64,
1141
#[component(name = "b")]
1142
pub b: wasmtime::component::__internal::String,
1143
#[component(name = "c")]
1144
pub c: wasmtime::component::__internal::Vec<u8>,
1145
}
1146
impl core::fmt::Debug for OtherRecord {
1147
fn fmt(
1148
&self,
1149
f: &mut core::fmt::Formatter<'_>,
1150
) -> core::fmt::Result {
1151
f.debug_struct("OtherRecord")
1152
.field("a1", &self.a1)
1153
.field("a2", &self.a2)
1154
.field("a3", &self.a3)
1155
.field("a4", &self.a4)
1156
.field("b", &self.b)
1157
.field("c", &self.c)
1158
.finish()
1159
}
1160
}
1161
const _: () = {
1162
assert!(
1163
48 == < OtherRecord as wasmtime::component::ComponentType
1164
>::SIZE32
1165
);
1166
assert!(
1167
8 == < OtherRecord as wasmtime::component::ComponentType
1168
>::ALIGN32
1169
);
1170
};
1171
#[derive(wasmtime::component::ComponentType)]
1172
#[derive(wasmtime::component::Lift)]
1173
#[derive(wasmtime::component::Lower)]
1174
#[component(record)]
1175
#[derive(Clone)]
1176
pub struct SomeRecord {
1177
#[component(name = "x")]
1178
pub x: wasmtime::component::__internal::String,
1179
#[component(name = "y")]
1180
pub y: OtherRecord,
1181
#[component(name = "z")]
1182
pub z: wasmtime::component::__internal::Vec<OtherRecord>,
1183
#[component(name = "c1")]
1184
pub c1: u32,
1185
#[component(name = "c2")]
1186
pub c2: u64,
1187
#[component(name = "c3")]
1188
pub c3: i32,
1189
#[component(name = "c4")]
1190
pub c4: i64,
1191
}
1192
impl core::fmt::Debug for SomeRecord {
1193
fn fmt(
1194
&self,
1195
f: &mut core::fmt::Formatter<'_>,
1196
) -> core::fmt::Result {
1197
f.debug_struct("SomeRecord")
1198
.field("x", &self.x)
1199
.field("y", &self.y)
1200
.field("z", &self.z)
1201
.field("c1", &self.c1)
1202
.field("c2", &self.c2)
1203
.field("c3", &self.c3)
1204
.field("c4", &self.c4)
1205
.finish()
1206
}
1207
}
1208
const _: () = {
1209
assert!(
1210
96 == < SomeRecord as wasmtime::component::ComponentType
1211
>::SIZE32
1212
);
1213
assert!(
1214
8 == < SomeRecord as wasmtime::component::ComponentType
1215
>::ALIGN32
1216
);
1217
};
1218
#[derive(wasmtime::component::ComponentType)]
1219
#[derive(wasmtime::component::Lift)]
1220
#[derive(wasmtime::component::Lower)]
1221
#[component(variant)]
1222
#[derive(Clone)]
1223
pub enum OtherVariant {
1224
#[component(name = "a")]
1225
A,
1226
#[component(name = "b")]
1227
B(u32),
1228
#[component(name = "c")]
1229
C(wasmtime::component::__internal::String),
1230
}
1231
impl core::fmt::Debug for OtherVariant {
1232
fn fmt(
1233
&self,
1234
f: &mut core::fmt::Formatter<'_>,
1235
) -> core::fmt::Result {
1236
match self {
1237
OtherVariant::A => f.debug_tuple("OtherVariant::A").finish(),
1238
OtherVariant::B(e) => {
1239
f.debug_tuple("OtherVariant::B").field(e).finish()
1240
}
1241
OtherVariant::C(e) => {
1242
f.debug_tuple("OtherVariant::C").field(e).finish()
1243
}
1244
}
1245
}
1246
}
1247
const _: () = {
1248
assert!(
1249
12 == < OtherVariant as wasmtime::component::ComponentType
1250
>::SIZE32
1251
);
1252
assert!(
1253
4 == < OtherVariant as wasmtime::component::ComponentType
1254
>::ALIGN32
1255
);
1256
};
1257
#[derive(wasmtime::component::ComponentType)]
1258
#[derive(wasmtime::component::Lift)]
1259
#[derive(wasmtime::component::Lower)]
1260
#[component(variant)]
1261
#[derive(Clone)]
1262
pub enum SomeVariant {
1263
#[component(name = "a")]
1264
A(wasmtime::component::__internal::String),
1265
#[component(name = "b")]
1266
B,
1267
#[component(name = "c")]
1268
C(u32),
1269
#[component(name = "d")]
1270
D(wasmtime::component::__internal::Vec<OtherVariant>),
1271
}
1272
impl core::fmt::Debug for SomeVariant {
1273
fn fmt(
1274
&self,
1275
f: &mut core::fmt::Formatter<'_>,
1276
) -> core::fmt::Result {
1277
match self {
1278
SomeVariant::A(e) => {
1279
f.debug_tuple("SomeVariant::A").field(e).finish()
1280
}
1281
SomeVariant::B => f.debug_tuple("SomeVariant::B").finish(),
1282
SomeVariant::C(e) => {
1283
f.debug_tuple("SomeVariant::C").field(e).finish()
1284
}
1285
SomeVariant::D(e) => {
1286
f.debug_tuple("SomeVariant::D").field(e).finish()
1287
}
1288
}
1289
}
1290
}
1291
const _: () = {
1292
assert!(
1293
12 == < SomeVariant as wasmtime::component::ComponentType
1294
>::SIZE32
1295
);
1296
assert!(
1297
4 == < SomeVariant as wasmtime::component::ComponentType
1298
>::ALIGN32
1299
);
1300
};
1301
pub type LoadStoreAllSizes = wasmtime::component::__internal::Vec<
1302
(
1303
wasmtime::component::__internal::String,
1304
u8,
1305
i8,
1306
u16,
1307
i16,
1308
u32,
1309
i32,
1310
u64,
1311
i64,
1312
f32,
1313
f64,
1314
char,
1315
),
1316
>;
1317
const _: () = {
1318
assert!(
1319
8 == < LoadStoreAllSizes as wasmtime::component::ComponentType
1320
>::SIZE32
1321
);
1322
assert!(
1323
4 == < LoadStoreAllSizes as wasmtime::component::ComponentType
1324
>::ALIGN32
1325
);
1326
};
1327
pub struct Guest {
1328
list_u8_param: wasmtime::component::Func,
1329
list_u16_param: wasmtime::component::Func,
1330
list_u32_param: wasmtime::component::Func,
1331
list_u64_param: wasmtime::component::Func,
1332
list_s8_param: wasmtime::component::Func,
1333
list_s16_param: wasmtime::component::Func,
1334
list_s32_param: wasmtime::component::Func,
1335
list_s64_param: wasmtime::component::Func,
1336
list_f32_param: wasmtime::component::Func,
1337
list_f64_param: wasmtime::component::Func,
1338
list_u8_ret: wasmtime::component::Func,
1339
list_u16_ret: wasmtime::component::Func,
1340
list_u32_ret: wasmtime::component::Func,
1341
list_u64_ret: wasmtime::component::Func,
1342
list_s8_ret: wasmtime::component::Func,
1343
list_s16_ret: wasmtime::component::Func,
1344
list_s32_ret: wasmtime::component::Func,
1345
list_s64_ret: wasmtime::component::Func,
1346
list_f32_ret: wasmtime::component::Func,
1347
list_f64_ret: wasmtime::component::Func,
1348
tuple_list: wasmtime::component::Func,
1349
string_list_arg: wasmtime::component::Func,
1350
string_list_ret: wasmtime::component::Func,
1351
tuple_string_list: wasmtime::component::Func,
1352
string_list: wasmtime::component::Func,
1353
record_list: wasmtime::component::Func,
1354
record_list_reverse: wasmtime::component::Func,
1355
variant_list: wasmtime::component::Func,
1356
load_store_everything: wasmtime::component::Func,
1357
}
1358
#[derive(Clone)]
1359
pub struct GuestIndices {
1360
list_u8_param: wasmtime::component::ComponentExportIndex,
1361
list_u16_param: wasmtime::component::ComponentExportIndex,
1362
list_u32_param: wasmtime::component::ComponentExportIndex,
1363
list_u64_param: wasmtime::component::ComponentExportIndex,
1364
list_s8_param: wasmtime::component::ComponentExportIndex,
1365
list_s16_param: wasmtime::component::ComponentExportIndex,
1366
list_s32_param: wasmtime::component::ComponentExportIndex,
1367
list_s64_param: wasmtime::component::ComponentExportIndex,
1368
list_f32_param: wasmtime::component::ComponentExportIndex,
1369
list_f64_param: wasmtime::component::ComponentExportIndex,
1370
list_u8_ret: wasmtime::component::ComponentExportIndex,
1371
list_u16_ret: wasmtime::component::ComponentExportIndex,
1372
list_u32_ret: wasmtime::component::ComponentExportIndex,
1373
list_u64_ret: wasmtime::component::ComponentExportIndex,
1374
list_s8_ret: wasmtime::component::ComponentExportIndex,
1375
list_s16_ret: wasmtime::component::ComponentExportIndex,
1376
list_s32_ret: wasmtime::component::ComponentExportIndex,
1377
list_s64_ret: wasmtime::component::ComponentExportIndex,
1378
list_f32_ret: wasmtime::component::ComponentExportIndex,
1379
list_f64_ret: wasmtime::component::ComponentExportIndex,
1380
tuple_list: wasmtime::component::ComponentExportIndex,
1381
string_list_arg: wasmtime::component::ComponentExportIndex,
1382
string_list_ret: wasmtime::component::ComponentExportIndex,
1383
tuple_string_list: wasmtime::component::ComponentExportIndex,
1384
string_list: wasmtime::component::ComponentExportIndex,
1385
record_list: wasmtime::component::ComponentExportIndex,
1386
record_list_reverse: wasmtime::component::ComponentExportIndex,
1387
variant_list: wasmtime::component::ComponentExportIndex,
1388
load_store_everything: wasmtime::component::ComponentExportIndex,
1389
}
1390
impl GuestIndices {
1391
/// Constructor for [`GuestIndices`] which takes a
1392
/// [`Component`](wasmtime::component::Component) as input and can be executed
1393
/// before instantiation.
1394
///
1395
/// This constructor can be used to front-load string lookups to find exports
1396
/// within a component.
1397
pub fn new<_T>(
1398
_instance_pre: &wasmtime::component::InstancePre<_T>,
1399
) -> wasmtime::Result<GuestIndices> {
1400
let instance = _instance_pre
1401
.component()
1402
.get_export_index(None, "foo:foo/lists")
1403
.ok_or_else(|| {
1404
anyhow::anyhow!(
1405
"no exported instance named `foo:foo/lists`"
1406
)
1407
})?;
1408
let mut lookup = move |name| {
1409
_instance_pre
1410
.component()
1411
.get_export_index(Some(&instance), name)
1412
.ok_or_else(|| {
1413
anyhow::anyhow!(
1414
"instance export `foo:foo/lists` does \
1415
not have export `{name}`"
1416
)
1417
})
1418
};
1419
let _ = &mut lookup;
1420
let list_u8_param = lookup("list-u8-param")?;
1421
let list_u16_param = lookup("list-u16-param")?;
1422
let list_u32_param = lookup("list-u32-param")?;
1423
let list_u64_param = lookup("list-u64-param")?;
1424
let list_s8_param = lookup("list-s8-param")?;
1425
let list_s16_param = lookup("list-s16-param")?;
1426
let list_s32_param = lookup("list-s32-param")?;
1427
let list_s64_param = lookup("list-s64-param")?;
1428
let list_f32_param = lookup("list-f32-param")?;
1429
let list_f64_param = lookup("list-f64-param")?;
1430
let list_u8_ret = lookup("list-u8-ret")?;
1431
let list_u16_ret = lookup("list-u16-ret")?;
1432
let list_u32_ret = lookup("list-u32-ret")?;
1433
let list_u64_ret = lookup("list-u64-ret")?;
1434
let list_s8_ret = lookup("list-s8-ret")?;
1435
let list_s16_ret = lookup("list-s16-ret")?;
1436
let list_s32_ret = lookup("list-s32-ret")?;
1437
let list_s64_ret = lookup("list-s64-ret")?;
1438
let list_f32_ret = lookup("list-f32-ret")?;
1439
let list_f64_ret = lookup("list-f64-ret")?;
1440
let tuple_list = lookup("tuple-list")?;
1441
let string_list_arg = lookup("string-list-arg")?;
1442
let string_list_ret = lookup("string-list-ret")?;
1443
let tuple_string_list = lookup("tuple-string-list")?;
1444
let string_list = lookup("string-list")?;
1445
let record_list = lookup("record-list")?;
1446
let record_list_reverse = lookup("record-list-reverse")?;
1447
let variant_list = lookup("variant-list")?;
1448
let load_store_everything = lookup("load-store-everything")?;
1449
Ok(GuestIndices {
1450
list_u8_param,
1451
list_u16_param,
1452
list_u32_param,
1453
list_u64_param,
1454
list_s8_param,
1455
list_s16_param,
1456
list_s32_param,
1457
list_s64_param,
1458
list_f32_param,
1459
list_f64_param,
1460
list_u8_ret,
1461
list_u16_ret,
1462
list_u32_ret,
1463
list_u64_ret,
1464
list_s8_ret,
1465
list_s16_ret,
1466
list_s32_ret,
1467
list_s64_ret,
1468
list_f32_ret,
1469
list_f64_ret,
1470
tuple_list,
1471
string_list_arg,
1472
string_list_ret,
1473
tuple_string_list,
1474
string_list,
1475
record_list,
1476
record_list_reverse,
1477
variant_list,
1478
load_store_everything,
1479
})
1480
}
1481
pub fn load(
1482
&self,
1483
mut store: impl wasmtime::AsContextMut,
1484
instance: &wasmtime::component::Instance,
1485
) -> wasmtime::Result<Guest> {
1486
let _instance = instance;
1487
let _instance_pre = _instance.instance_pre(&store);
1488
let _instance_type = _instance_pre.instance_type();
1489
let mut store = store.as_context_mut();
1490
let _ = &mut store;
1491
let list_u8_param = *_instance
1492
.get_typed_func::<
1493
(&[u8],),
1494
(),
1495
>(&mut store, &self.list_u8_param)?
1496
.func();
1497
let list_u16_param = *_instance
1498
.get_typed_func::<
1499
(&[u16],),
1500
(),
1501
>(&mut store, &self.list_u16_param)?
1502
.func();
1503
let list_u32_param = *_instance
1504
.get_typed_func::<
1505
(&[u32],),
1506
(),
1507
>(&mut store, &self.list_u32_param)?
1508
.func();
1509
let list_u64_param = *_instance
1510
.get_typed_func::<
1511
(&[u64],),
1512
(),
1513
>(&mut store, &self.list_u64_param)?
1514
.func();
1515
let list_s8_param = *_instance
1516
.get_typed_func::<
1517
(&[i8],),
1518
(),
1519
>(&mut store, &self.list_s8_param)?
1520
.func();
1521
let list_s16_param = *_instance
1522
.get_typed_func::<
1523
(&[i16],),
1524
(),
1525
>(&mut store, &self.list_s16_param)?
1526
.func();
1527
let list_s32_param = *_instance
1528
.get_typed_func::<
1529
(&[i32],),
1530
(),
1531
>(&mut store, &self.list_s32_param)?
1532
.func();
1533
let list_s64_param = *_instance
1534
.get_typed_func::<
1535
(&[i64],),
1536
(),
1537
>(&mut store, &self.list_s64_param)?
1538
.func();
1539
let list_f32_param = *_instance
1540
.get_typed_func::<
1541
(&[f32],),
1542
(),
1543
>(&mut store, &self.list_f32_param)?
1544
.func();
1545
let list_f64_param = *_instance
1546
.get_typed_func::<
1547
(&[f64],),
1548
(),
1549
>(&mut store, &self.list_f64_param)?
1550
.func();
1551
let list_u8_ret = *_instance
1552
.get_typed_func::<
1553
(),
1554
(wasmtime::component::__internal::Vec<u8>,),
1555
>(&mut store, &self.list_u8_ret)?
1556
.func();
1557
let list_u16_ret = *_instance
1558
.get_typed_func::<
1559
(),
1560
(wasmtime::component::__internal::Vec<u16>,),
1561
>(&mut store, &self.list_u16_ret)?
1562
.func();
1563
let list_u32_ret = *_instance
1564
.get_typed_func::<
1565
(),
1566
(wasmtime::component::__internal::Vec<u32>,),
1567
>(&mut store, &self.list_u32_ret)?
1568
.func();
1569
let list_u64_ret = *_instance
1570
.get_typed_func::<
1571
(),
1572
(wasmtime::component::__internal::Vec<u64>,),
1573
>(&mut store, &self.list_u64_ret)?
1574
.func();
1575
let list_s8_ret = *_instance
1576
.get_typed_func::<
1577
(),
1578
(wasmtime::component::__internal::Vec<i8>,),
1579
>(&mut store, &self.list_s8_ret)?
1580
.func();
1581
let list_s16_ret = *_instance
1582
.get_typed_func::<
1583
(),
1584
(wasmtime::component::__internal::Vec<i16>,),
1585
>(&mut store, &self.list_s16_ret)?
1586
.func();
1587
let list_s32_ret = *_instance
1588
.get_typed_func::<
1589
(),
1590
(wasmtime::component::__internal::Vec<i32>,),
1591
>(&mut store, &self.list_s32_ret)?
1592
.func();
1593
let list_s64_ret = *_instance
1594
.get_typed_func::<
1595
(),
1596
(wasmtime::component::__internal::Vec<i64>,),
1597
>(&mut store, &self.list_s64_ret)?
1598
.func();
1599
let list_f32_ret = *_instance
1600
.get_typed_func::<
1601
(),
1602
(wasmtime::component::__internal::Vec<f32>,),
1603
>(&mut store, &self.list_f32_ret)?
1604
.func();
1605
let list_f64_ret = *_instance
1606
.get_typed_func::<
1607
(),
1608
(wasmtime::component::__internal::Vec<f64>,),
1609
>(&mut store, &self.list_f64_ret)?
1610
.func();
1611
let tuple_list = *_instance
1612
.get_typed_func::<
1613
(&[(u8, i8)],),
1614
(wasmtime::component::__internal::Vec<(i64, u32)>,),
1615
>(&mut store, &self.tuple_list)?
1616
.func();
1617
let string_list_arg = *_instance
1618
.get_typed_func::<
1619
(&[wasmtime::component::__internal::String],),
1620
(),
1621
>(&mut store, &self.string_list_arg)?
1622
.func();
1623
let string_list_ret = *_instance
1624
.get_typed_func::<
1625
(),
1626
(
1627
wasmtime::component::__internal::Vec<
1628
wasmtime::component::__internal::String,
1629
>,
1630
),
1631
>(&mut store, &self.string_list_ret)?
1632
.func();
1633
let tuple_string_list = *_instance
1634
.get_typed_func::<
1635
(&[(u8, wasmtime::component::__internal::String)],),
1636
(
1637
wasmtime::component::__internal::Vec<
1638
(wasmtime::component::__internal::String, u8),
1639
>,
1640
),
1641
>(&mut store, &self.tuple_string_list)?
1642
.func();
1643
let string_list = *_instance
1644
.get_typed_func::<
1645
(&[wasmtime::component::__internal::String],),
1646
(
1647
wasmtime::component::__internal::Vec<
1648
wasmtime::component::__internal::String,
1649
>,
1650
),
1651
>(&mut store, &self.string_list)?
1652
.func();
1653
let record_list = *_instance
1654
.get_typed_func::<
1655
(&[SomeRecord],),
1656
(wasmtime::component::__internal::Vec<OtherRecord>,),
1657
>(&mut store, &self.record_list)?
1658
.func();
1659
let record_list_reverse = *_instance
1660
.get_typed_func::<
1661
(&[OtherRecord],),
1662
(wasmtime::component::__internal::Vec<SomeRecord>,),
1663
>(&mut store, &self.record_list_reverse)?
1664
.func();
1665
let variant_list = *_instance
1666
.get_typed_func::<
1667
(&[SomeVariant],),
1668
(wasmtime::component::__internal::Vec<OtherVariant>,),
1669
>(&mut store, &self.variant_list)?
1670
.func();
1671
let load_store_everything = *_instance
1672
.get_typed_func::<
1673
(&LoadStoreAllSizes,),
1674
(LoadStoreAllSizes,),
1675
>(&mut store, &self.load_store_everything)?
1676
.func();
1677
Ok(Guest {
1678
list_u8_param,
1679
list_u16_param,
1680
list_u32_param,
1681
list_u64_param,
1682
list_s8_param,
1683
list_s16_param,
1684
list_s32_param,
1685
list_s64_param,
1686
list_f32_param,
1687
list_f64_param,
1688
list_u8_ret,
1689
list_u16_ret,
1690
list_u32_ret,
1691
list_u64_ret,
1692
list_s8_ret,
1693
list_s16_ret,
1694
list_s32_ret,
1695
list_s64_ret,
1696
list_f32_ret,
1697
list_f64_ret,
1698
tuple_list,
1699
string_list_arg,
1700
string_list_ret,
1701
tuple_string_list,
1702
string_list,
1703
record_list,
1704
record_list_reverse,
1705
variant_list,
1706
load_store_everything,
1707
})
1708
}
1709
}
1710
impl Guest {
1711
pub async fn call_list_u8_param<S: wasmtime::AsContextMut>(
1712
&self,
1713
mut store: S,
1714
arg0: &[u8],
1715
) -> wasmtime::Result<()>
1716
where
1717
<S as wasmtime::AsContext>::Data: Send,
1718
{
1719
let callee = unsafe {
1720
wasmtime::component::TypedFunc::<
1721
(&[u8],),
1722
(),
1723
>::new_unchecked(self.list_u8_param)
1724
};
1725
let () = callee
1726
.call_async(store.as_context_mut(), (arg0,))
1727
.await?;
1728
callee.post_return_async(store.as_context_mut()).await?;
1729
Ok(())
1730
}
1731
pub async fn call_list_u16_param<S: wasmtime::AsContextMut>(
1732
&self,
1733
mut store: S,
1734
arg0: &[u16],
1735
) -> wasmtime::Result<()>
1736
where
1737
<S as wasmtime::AsContext>::Data: Send,
1738
{
1739
let callee = unsafe {
1740
wasmtime::component::TypedFunc::<
1741
(&[u16],),
1742
(),
1743
>::new_unchecked(self.list_u16_param)
1744
};
1745
let () = callee
1746
.call_async(store.as_context_mut(), (arg0,))
1747
.await?;
1748
callee.post_return_async(store.as_context_mut()).await?;
1749
Ok(())
1750
}
1751
pub async fn call_list_u32_param<S: wasmtime::AsContextMut>(
1752
&self,
1753
mut store: S,
1754
arg0: &[u32],
1755
) -> wasmtime::Result<()>
1756
where
1757
<S as wasmtime::AsContext>::Data: Send,
1758
{
1759
let callee = unsafe {
1760
wasmtime::component::TypedFunc::<
1761
(&[u32],),
1762
(),
1763
>::new_unchecked(self.list_u32_param)
1764
};
1765
let () = callee
1766
.call_async(store.as_context_mut(), (arg0,))
1767
.await?;
1768
callee.post_return_async(store.as_context_mut()).await?;
1769
Ok(())
1770
}
1771
pub async fn call_list_u64_param<S: wasmtime::AsContextMut>(
1772
&self,
1773
mut store: S,
1774
arg0: &[u64],
1775
) -> wasmtime::Result<()>
1776
where
1777
<S as wasmtime::AsContext>::Data: Send,
1778
{
1779
let callee = unsafe {
1780
wasmtime::component::TypedFunc::<
1781
(&[u64],),
1782
(),
1783
>::new_unchecked(self.list_u64_param)
1784
};
1785
let () = callee
1786
.call_async(store.as_context_mut(), (arg0,))
1787
.await?;
1788
callee.post_return_async(store.as_context_mut()).await?;
1789
Ok(())
1790
}
1791
pub async fn call_list_s8_param<S: wasmtime::AsContextMut>(
1792
&self,
1793
mut store: S,
1794
arg0: &[i8],
1795
) -> wasmtime::Result<()>
1796
where
1797
<S as wasmtime::AsContext>::Data: Send,
1798
{
1799
let callee = unsafe {
1800
wasmtime::component::TypedFunc::<
1801
(&[i8],),
1802
(),
1803
>::new_unchecked(self.list_s8_param)
1804
};
1805
let () = callee
1806
.call_async(store.as_context_mut(), (arg0,))
1807
.await?;
1808
callee.post_return_async(store.as_context_mut()).await?;
1809
Ok(())
1810
}
1811
pub async fn call_list_s16_param<S: wasmtime::AsContextMut>(
1812
&self,
1813
mut store: S,
1814
arg0: &[i16],
1815
) -> wasmtime::Result<()>
1816
where
1817
<S as wasmtime::AsContext>::Data: Send,
1818
{
1819
let callee = unsafe {
1820
wasmtime::component::TypedFunc::<
1821
(&[i16],),
1822
(),
1823
>::new_unchecked(self.list_s16_param)
1824
};
1825
let () = callee
1826
.call_async(store.as_context_mut(), (arg0,))
1827
.await?;
1828
callee.post_return_async(store.as_context_mut()).await?;
1829
Ok(())
1830
}
1831
pub async fn call_list_s32_param<S: wasmtime::AsContextMut>(
1832
&self,
1833
mut store: S,
1834
arg0: &[i32],
1835
) -> wasmtime::Result<()>
1836
where
1837
<S as wasmtime::AsContext>::Data: Send,
1838
{
1839
let callee = unsafe {
1840
wasmtime::component::TypedFunc::<
1841
(&[i32],),
1842
(),
1843
>::new_unchecked(self.list_s32_param)
1844
};
1845
let () = callee
1846
.call_async(store.as_context_mut(), (arg0,))
1847
.await?;
1848
callee.post_return_async(store.as_context_mut()).await?;
1849
Ok(())
1850
}
1851
pub async fn call_list_s64_param<S: wasmtime::AsContextMut>(
1852
&self,
1853
mut store: S,
1854
arg0: &[i64],
1855
) -> wasmtime::Result<()>
1856
where
1857
<S as wasmtime::AsContext>::Data: Send,
1858
{
1859
let callee = unsafe {
1860
wasmtime::component::TypedFunc::<
1861
(&[i64],),
1862
(),
1863
>::new_unchecked(self.list_s64_param)
1864
};
1865
let () = callee
1866
.call_async(store.as_context_mut(), (arg0,))
1867
.await?;
1868
callee.post_return_async(store.as_context_mut()).await?;
1869
Ok(())
1870
}
1871
pub async fn call_list_f32_param<S: wasmtime::AsContextMut>(
1872
&self,
1873
mut store: S,
1874
arg0: &[f32],
1875
) -> wasmtime::Result<()>
1876
where
1877
<S as wasmtime::AsContext>::Data: Send,
1878
{
1879
let callee = unsafe {
1880
wasmtime::component::TypedFunc::<
1881
(&[f32],),
1882
(),
1883
>::new_unchecked(self.list_f32_param)
1884
};
1885
let () = callee
1886
.call_async(store.as_context_mut(), (arg0,))
1887
.await?;
1888
callee.post_return_async(store.as_context_mut()).await?;
1889
Ok(())
1890
}
1891
pub async fn call_list_f64_param<S: wasmtime::AsContextMut>(
1892
&self,
1893
mut store: S,
1894
arg0: &[f64],
1895
) -> wasmtime::Result<()>
1896
where
1897
<S as wasmtime::AsContext>::Data: Send,
1898
{
1899
let callee = unsafe {
1900
wasmtime::component::TypedFunc::<
1901
(&[f64],),
1902
(),
1903
>::new_unchecked(self.list_f64_param)
1904
};
1905
let () = callee
1906
.call_async(store.as_context_mut(), (arg0,))
1907
.await?;
1908
callee.post_return_async(store.as_context_mut()).await?;
1909
Ok(())
1910
}
1911
pub async fn call_list_u8_ret<S: wasmtime::AsContextMut>(
1912
&self,
1913
mut store: S,
1914
) -> wasmtime::Result<wasmtime::component::__internal::Vec<u8>>
1915
where
1916
<S as wasmtime::AsContext>::Data: Send,
1917
{
1918
let callee = unsafe {
1919
wasmtime::component::TypedFunc::<
1920
(),
1921
(wasmtime::component::__internal::Vec<u8>,),
1922
>::new_unchecked(self.list_u8_ret)
1923
};
1924
let (ret0,) = callee
1925
.call_async(store.as_context_mut(), ())
1926
.await?;
1927
callee.post_return_async(store.as_context_mut()).await?;
1928
Ok(ret0)
1929
}
1930
pub async fn call_list_u16_ret<S: wasmtime::AsContextMut>(
1931
&self,
1932
mut store: S,
1933
) -> wasmtime::Result<wasmtime::component::__internal::Vec<u16>>
1934
where
1935
<S as wasmtime::AsContext>::Data: Send,
1936
{
1937
let callee = unsafe {
1938
wasmtime::component::TypedFunc::<
1939
(),
1940
(wasmtime::component::__internal::Vec<u16>,),
1941
>::new_unchecked(self.list_u16_ret)
1942
};
1943
let (ret0,) = callee
1944
.call_async(store.as_context_mut(), ())
1945
.await?;
1946
callee.post_return_async(store.as_context_mut()).await?;
1947
Ok(ret0)
1948
}
1949
pub async fn call_list_u32_ret<S: wasmtime::AsContextMut>(
1950
&self,
1951
mut store: S,
1952
) -> wasmtime::Result<wasmtime::component::__internal::Vec<u32>>
1953
where
1954
<S as wasmtime::AsContext>::Data: Send,
1955
{
1956
let callee = unsafe {
1957
wasmtime::component::TypedFunc::<
1958
(),
1959
(wasmtime::component::__internal::Vec<u32>,),
1960
>::new_unchecked(self.list_u32_ret)
1961
};
1962
let (ret0,) = callee
1963
.call_async(store.as_context_mut(), ())
1964
.await?;
1965
callee.post_return_async(store.as_context_mut()).await?;
1966
Ok(ret0)
1967
}
1968
pub async fn call_list_u64_ret<S: wasmtime::AsContextMut>(
1969
&self,
1970
mut store: S,
1971
) -> wasmtime::Result<wasmtime::component::__internal::Vec<u64>>
1972
where
1973
<S as wasmtime::AsContext>::Data: Send,
1974
{
1975
let callee = unsafe {
1976
wasmtime::component::TypedFunc::<
1977
(),
1978
(wasmtime::component::__internal::Vec<u64>,),
1979
>::new_unchecked(self.list_u64_ret)
1980
};
1981
let (ret0,) = callee
1982
.call_async(store.as_context_mut(), ())
1983
.await?;
1984
callee.post_return_async(store.as_context_mut()).await?;
1985
Ok(ret0)
1986
}
1987
pub async fn call_list_s8_ret<S: wasmtime::AsContextMut>(
1988
&self,
1989
mut store: S,
1990
) -> wasmtime::Result<wasmtime::component::__internal::Vec<i8>>
1991
where
1992
<S as wasmtime::AsContext>::Data: Send,
1993
{
1994
let callee = unsafe {
1995
wasmtime::component::TypedFunc::<
1996
(),
1997
(wasmtime::component::__internal::Vec<i8>,),
1998
>::new_unchecked(self.list_s8_ret)
1999
};
2000
let (ret0,) = callee
2001
.call_async(store.as_context_mut(), ())
2002
.await?;
2003
callee.post_return_async(store.as_context_mut()).await?;
2004
Ok(ret0)
2005
}
2006
pub async fn call_list_s16_ret<S: wasmtime::AsContextMut>(
2007
&self,
2008
mut store: S,
2009
) -> wasmtime::Result<wasmtime::component::__internal::Vec<i16>>
2010
where
2011
<S as wasmtime::AsContext>::Data: Send,
2012
{
2013
let callee = unsafe {
2014
wasmtime::component::TypedFunc::<
2015
(),
2016
(wasmtime::component::__internal::Vec<i16>,),
2017
>::new_unchecked(self.list_s16_ret)
2018
};
2019
let (ret0,) = callee
2020
.call_async(store.as_context_mut(), ())
2021
.await?;
2022
callee.post_return_async(store.as_context_mut()).await?;
2023
Ok(ret0)
2024
}
2025
pub async fn call_list_s32_ret<S: wasmtime::AsContextMut>(
2026
&self,
2027
mut store: S,
2028
) -> wasmtime::Result<wasmtime::component::__internal::Vec<i32>>
2029
where
2030
<S as wasmtime::AsContext>::Data: Send,
2031
{
2032
let callee = unsafe {
2033
wasmtime::component::TypedFunc::<
2034
(),
2035
(wasmtime::component::__internal::Vec<i32>,),
2036
>::new_unchecked(self.list_s32_ret)
2037
};
2038
let (ret0,) = callee
2039
.call_async(store.as_context_mut(), ())
2040
.await?;
2041
callee.post_return_async(store.as_context_mut()).await?;
2042
Ok(ret0)
2043
}
2044
pub async fn call_list_s64_ret<S: wasmtime::AsContextMut>(
2045
&self,
2046
mut store: S,
2047
) -> wasmtime::Result<wasmtime::component::__internal::Vec<i64>>
2048
where
2049
<S as wasmtime::AsContext>::Data: Send,
2050
{
2051
let callee = unsafe {
2052
wasmtime::component::TypedFunc::<
2053
(),
2054
(wasmtime::component::__internal::Vec<i64>,),
2055
>::new_unchecked(self.list_s64_ret)
2056
};
2057
let (ret0,) = callee
2058
.call_async(store.as_context_mut(), ())
2059
.await?;
2060
callee.post_return_async(store.as_context_mut()).await?;
2061
Ok(ret0)
2062
}
2063
pub async fn call_list_f32_ret<S: wasmtime::AsContextMut>(
2064
&self,
2065
mut store: S,
2066
) -> wasmtime::Result<wasmtime::component::__internal::Vec<f32>>
2067
where
2068
<S as wasmtime::AsContext>::Data: Send,
2069
{
2070
let callee = unsafe {
2071
wasmtime::component::TypedFunc::<
2072
(),
2073
(wasmtime::component::__internal::Vec<f32>,),
2074
>::new_unchecked(self.list_f32_ret)
2075
};
2076
let (ret0,) = callee
2077
.call_async(store.as_context_mut(), ())
2078
.await?;
2079
callee.post_return_async(store.as_context_mut()).await?;
2080
Ok(ret0)
2081
}
2082
pub async fn call_list_f64_ret<S: wasmtime::AsContextMut>(
2083
&self,
2084
mut store: S,
2085
) -> wasmtime::Result<wasmtime::component::__internal::Vec<f64>>
2086
where
2087
<S as wasmtime::AsContext>::Data: Send,
2088
{
2089
let callee = unsafe {
2090
wasmtime::component::TypedFunc::<
2091
(),
2092
(wasmtime::component::__internal::Vec<f64>,),
2093
>::new_unchecked(self.list_f64_ret)
2094
};
2095
let (ret0,) = callee
2096
.call_async(store.as_context_mut(), ())
2097
.await?;
2098
callee.post_return_async(store.as_context_mut()).await?;
2099
Ok(ret0)
2100
}
2101
pub async fn call_tuple_list<S: wasmtime::AsContextMut>(
2102
&self,
2103
mut store: S,
2104
arg0: &[(u8, i8)],
2105
) -> wasmtime::Result<
2106
wasmtime::component::__internal::Vec<(i64, u32)>,
2107
>
2108
where
2109
<S as wasmtime::AsContext>::Data: Send,
2110
{
2111
let callee = unsafe {
2112
wasmtime::component::TypedFunc::<
2113
(&[(u8, i8)],),
2114
(wasmtime::component::__internal::Vec<(i64, u32)>,),
2115
>::new_unchecked(self.tuple_list)
2116
};
2117
let (ret0,) = callee
2118
.call_async(store.as_context_mut(), (arg0,))
2119
.await?;
2120
callee.post_return_async(store.as_context_mut()).await?;
2121
Ok(ret0)
2122
}
2123
pub async fn call_string_list_arg<S: wasmtime::AsContextMut>(
2124
&self,
2125
mut store: S,
2126
arg0: &[wasmtime::component::__internal::String],
2127
) -> wasmtime::Result<()>
2128
where
2129
<S as wasmtime::AsContext>::Data: Send,
2130
{
2131
let callee = unsafe {
2132
wasmtime::component::TypedFunc::<
2133
(&[wasmtime::component::__internal::String],),
2134
(),
2135
>::new_unchecked(self.string_list_arg)
2136
};
2137
let () = callee
2138
.call_async(store.as_context_mut(), (arg0,))
2139
.await?;
2140
callee.post_return_async(store.as_context_mut()).await?;
2141
Ok(())
2142
}
2143
pub async fn call_string_list_ret<S: wasmtime::AsContextMut>(
2144
&self,
2145
mut store: S,
2146
) -> wasmtime::Result<
2147
wasmtime::component::__internal::Vec<
2148
wasmtime::component::__internal::String,
2149
>,
2150
>
2151
where
2152
<S as wasmtime::AsContext>::Data: Send,
2153
{
2154
let callee = unsafe {
2155
wasmtime::component::TypedFunc::<
2156
(),
2157
(
2158
wasmtime::component::__internal::Vec<
2159
wasmtime::component::__internal::String,
2160
>,
2161
),
2162
>::new_unchecked(self.string_list_ret)
2163
};
2164
let (ret0,) = callee
2165
.call_async(store.as_context_mut(), ())
2166
.await?;
2167
callee.post_return_async(store.as_context_mut()).await?;
2168
Ok(ret0)
2169
}
2170
pub async fn call_tuple_string_list<S: wasmtime::AsContextMut>(
2171
&self,
2172
mut store: S,
2173
arg0: &[(u8, wasmtime::component::__internal::String)],
2174
) -> wasmtime::Result<
2175
wasmtime::component::__internal::Vec<
2176
(wasmtime::component::__internal::String, u8),
2177
>,
2178
>
2179
where
2180
<S as wasmtime::AsContext>::Data: Send,
2181
{
2182
let callee = unsafe {
2183
wasmtime::component::TypedFunc::<
2184
(&[(u8, wasmtime::component::__internal::String)],),
2185
(
2186
wasmtime::component::__internal::Vec<
2187
(wasmtime::component::__internal::String, u8),
2188
>,
2189
),
2190
>::new_unchecked(self.tuple_string_list)
2191
};
2192
let (ret0,) = callee
2193
.call_async(store.as_context_mut(), (arg0,))
2194
.await?;
2195
callee.post_return_async(store.as_context_mut()).await?;
2196
Ok(ret0)
2197
}
2198
pub async fn call_string_list<S: wasmtime::AsContextMut>(
2199
&self,
2200
mut store: S,
2201
arg0: &[wasmtime::component::__internal::String],
2202
) -> wasmtime::Result<
2203
wasmtime::component::__internal::Vec<
2204
wasmtime::component::__internal::String,
2205
>,
2206
>
2207
where
2208
<S as wasmtime::AsContext>::Data: Send,
2209
{
2210
let callee = unsafe {
2211
wasmtime::component::TypedFunc::<
2212
(&[wasmtime::component::__internal::String],),
2213
(
2214
wasmtime::component::__internal::Vec<
2215
wasmtime::component::__internal::String,
2216
>,
2217
),
2218
>::new_unchecked(self.string_list)
2219
};
2220
let (ret0,) = callee
2221
.call_async(store.as_context_mut(), (arg0,))
2222
.await?;
2223
callee.post_return_async(store.as_context_mut()).await?;
2224
Ok(ret0)
2225
}
2226
pub async fn call_record_list<S: wasmtime::AsContextMut>(
2227
&self,
2228
mut store: S,
2229
arg0: &[SomeRecord],
2230
) -> wasmtime::Result<
2231
wasmtime::component::__internal::Vec<OtherRecord>,
2232
>
2233
where
2234
<S as wasmtime::AsContext>::Data: Send,
2235
{
2236
let callee = unsafe {
2237
wasmtime::component::TypedFunc::<
2238
(&[SomeRecord],),
2239
(wasmtime::component::__internal::Vec<OtherRecord>,),
2240
>::new_unchecked(self.record_list)
2241
};
2242
let (ret0,) = callee
2243
.call_async(store.as_context_mut(), (arg0,))
2244
.await?;
2245
callee.post_return_async(store.as_context_mut()).await?;
2246
Ok(ret0)
2247
}
2248
pub async fn call_record_list_reverse<S: wasmtime::AsContextMut>(
2249
&self,
2250
mut store: S,
2251
arg0: &[OtherRecord],
2252
) -> wasmtime::Result<
2253
wasmtime::component::__internal::Vec<SomeRecord>,
2254
>
2255
where
2256
<S as wasmtime::AsContext>::Data: Send,
2257
{
2258
let callee = unsafe {
2259
wasmtime::component::TypedFunc::<
2260
(&[OtherRecord],),
2261
(wasmtime::component::__internal::Vec<SomeRecord>,),
2262
>::new_unchecked(self.record_list_reverse)
2263
};
2264
let (ret0,) = callee
2265
.call_async(store.as_context_mut(), (arg0,))
2266
.await?;
2267
callee.post_return_async(store.as_context_mut()).await?;
2268
Ok(ret0)
2269
}
2270
pub async fn call_variant_list<S: wasmtime::AsContextMut>(
2271
&self,
2272
mut store: S,
2273
arg0: &[SomeVariant],
2274
) -> wasmtime::Result<
2275
wasmtime::component::__internal::Vec<OtherVariant>,
2276
>
2277
where
2278
<S as wasmtime::AsContext>::Data: Send,
2279
{
2280
let callee = unsafe {
2281
wasmtime::component::TypedFunc::<
2282
(&[SomeVariant],),
2283
(wasmtime::component::__internal::Vec<OtherVariant>,),
2284
>::new_unchecked(self.variant_list)
2285
};
2286
let (ret0,) = callee
2287
.call_async(store.as_context_mut(), (arg0,))
2288
.await?;
2289
callee.post_return_async(store.as_context_mut()).await?;
2290
Ok(ret0)
2291
}
2292
pub async fn call_load_store_everything<S: wasmtime::AsContextMut>(
2293
&self,
2294
mut store: S,
2295
arg0: &LoadStoreAllSizes,
2296
) -> wasmtime::Result<LoadStoreAllSizes>
2297
where
2298
<S as wasmtime::AsContext>::Data: Send,
2299
{
2300
let callee = unsafe {
2301
wasmtime::component::TypedFunc::<
2302
(&LoadStoreAllSizes,),
2303
(LoadStoreAllSizes,),
2304
>::new_unchecked(self.load_store_everything)
2305
};
2306
let (ret0,) = callee
2307
.call_async(store.as_context_mut(), (arg0,))
2308
.await?;
2309
callee.post_return_async(store.as_context_mut()).await?;
2310
Ok(ret0)
2311
}
2312
}
2313
}
2314
}
2315
}
2316
}
2317
2318