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