Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/component-macro/tests/expanded/conventions.rs
3070 views
1
/// Auto-generated bindings for a pre-instantiated version of a
2
/// component which implements the world `the-world`.
3
///
4
/// This structure is created through [`TheWorldPre::new`] which
5
/// takes a [`InstancePre`](wasmtime::component::InstancePre) that
6
/// has been created through a [`Linker`](wasmtime::component::Linker).
7
///
8
/// For more information see [`TheWorld`] as well.
9
pub struct TheWorldPre<T: 'static> {
10
instance_pre: wasmtime::component::InstancePre<T>,
11
indices: TheWorldIndices,
12
}
13
impl<T: 'static> Clone for TheWorldPre<T> {
14
fn clone(&self) -> Self {
15
Self {
16
instance_pre: self.instance_pre.clone(),
17
indices: self.indices.clone(),
18
}
19
}
20
}
21
impl<_T: 'static> TheWorldPre<_T> {
22
/// Creates a new copy of `TheWorldPre` bindings which can then
23
/// be used to instantiate into a particular store.
24
///
25
/// This method may fail if the component behind `instance_pre`
26
/// does not have the required exports.
27
pub fn new(
28
instance_pre: wasmtime::component::InstancePre<_T>,
29
) -> wasmtime::Result<Self> {
30
let indices = TheWorldIndices::new(&instance_pre)?;
31
Ok(Self { instance_pre, indices })
32
}
33
pub fn engine(&self) -> &wasmtime::Engine {
34
self.instance_pre.engine()
35
}
36
pub fn instance_pre(&self) -> &wasmtime::component::InstancePre<_T> {
37
&self.instance_pre
38
}
39
/// Instantiates a new instance of [`TheWorld`] within the
40
/// `store` provided.
41
///
42
/// This function will use `self` as the pre-instantiated
43
/// instance to perform instantiation. Afterwards the preloaded
44
/// indices in `self` are used to lookup all exports on the
45
/// resulting instance.
46
pub fn instantiate(
47
&self,
48
mut store: impl wasmtime::AsContextMut<Data = _T>,
49
) -> wasmtime::Result<TheWorld> {
50
let mut store = store.as_context_mut();
51
let instance = self.instance_pre.instantiate(&mut store)?;
52
self.indices.load(&mut store, &instance)
53
}
54
}
55
impl<_T: Send + 'static> TheWorldPre<_T> {
56
/// Same as [`Self::instantiate`], except with `async`.
57
pub async fn instantiate_async(
58
&self,
59
mut store: impl wasmtime::AsContextMut<Data = _T>,
60
) -> wasmtime::Result<TheWorld> {
61
let mut store = store.as_context_mut();
62
let instance = self.instance_pre.instantiate_async(&mut store).await?;
63
self.indices.load(&mut store, &instance)
64
}
65
}
66
/// Auto-generated bindings for index of the exports of
67
/// `the-world`.
68
///
69
/// This is an implementation detail of [`TheWorldPre`] and can
70
/// be constructed if needed as well.
71
///
72
/// For more information see [`TheWorld`] as well.
73
#[derive(Clone)]
74
pub struct TheWorldIndices {
75
interface0: exports::foo::foo::conventions::GuestIndices,
76
}
77
/// Auto-generated bindings for an instance a component which
78
/// implements the world `the-world`.
79
///
80
/// This structure can be created through a number of means
81
/// depending on your requirements and what you have on hand:
82
///
83
/// * The most convenient way is to use
84
/// [`TheWorld::instantiate`] which only needs a
85
/// [`Store`], [`Component`], and [`Linker`].
86
///
87
/// * Alternatively you can create a [`TheWorldPre`] ahead of
88
/// time with a [`Component`] to front-load string lookups
89
/// of exports once instead of per-instantiation. This
90
/// method then uses [`TheWorldPre::instantiate`] to
91
/// create a [`TheWorld`].
92
///
93
/// * If you've instantiated the instance yourself already
94
/// then you can use [`TheWorld::new`].
95
///
96
/// These methods are all equivalent to one another and move
97
/// around the tradeoff of what work is performed when.
98
///
99
/// [`Store`]: wasmtime::Store
100
/// [`Component`]: wasmtime::component::Component
101
/// [`Linker`]: wasmtime::component::Linker
102
pub struct TheWorld {
103
interface0: exports::foo::foo::conventions::Guest,
104
}
105
const _: () = {
106
impl TheWorldIndices {
107
/// Creates a new copy of `TheWorldIndices` 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::conventions::GuestIndices::new(
118
_instance_pre,
119
)?;
120
Ok(TheWorldIndices { interface0 })
121
}
122
/// Uses the indices stored in `self` to load an instance
123
/// of [`TheWorld`] 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<TheWorld> {
132
let _ = &mut store;
133
let _instance = instance;
134
let interface0 = self.interface0.load(&mut store, &_instance)?;
135
Ok(TheWorld { interface0 })
136
}
137
}
138
impl TheWorld {
139
/// Convenience wrapper around [`TheWorldPre::new`] and
140
/// [`TheWorldPre::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<TheWorld> {
146
let pre = linker.instantiate_pre(component)?;
147
TheWorldPre::new(pre)?.instantiate(store)
148
}
149
/// Convenience wrapper around [`TheWorldIndices::new`] and
150
/// [`TheWorldIndices::load`].
151
pub fn new(
152
mut store: impl wasmtime::AsContextMut,
153
instance: &wasmtime::component::Instance,
154
) -> wasmtime::Result<TheWorld> {
155
let indices = TheWorldIndices::new(&instance.instance_pre(&store))?;
156
indices.load(&mut store, instance)
157
}
158
/// Convenience wrapper around [`TheWorldPre::new`] and
159
/// [`TheWorldPre::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<TheWorld>
165
where
166
_T: Send,
167
{
168
let pre = linker.instantiate_pre(component)?;
169
TheWorldPre::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::conventions::HostWithStore,
177
for<'a> D::Data<'a>: foo::foo::conventions::Host,
178
T: 'static,
179
{
180
foo::foo::conventions::add_to_linker::<T, D>(linker, host_getter)?;
181
Ok(())
182
}
183
pub fn foo_foo_conventions(&self) -> &exports::foo::foo::conventions::Guest {
184
&self.interface0
185
}
186
}
187
};
188
pub mod foo {
189
pub mod foo {
190
#[allow(clippy::all)]
191
pub mod conventions {
192
#[allow(unused_imports)]
193
use wasmtime::component::__internal::Box;
194
#[derive(wasmtime::component::ComponentType)]
195
#[derive(wasmtime::component::Lift)]
196
#[derive(wasmtime::component::Lower)]
197
#[component(record)]
198
#[derive(Clone, Copy)]
199
pub struct LudicrousSpeed {
200
#[component(name = "how-fast-are-you-going")]
201
pub how_fast_are_you_going: u32,
202
#[component(name = "i-am-going-extremely-slow")]
203
pub i_am_going_extremely_slow: u64,
204
}
205
impl core::fmt::Debug for LudicrousSpeed {
206
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
207
f.debug_struct("LudicrousSpeed")
208
.field("how-fast-are-you-going", &self.how_fast_are_you_going)
209
.field(
210
"i-am-going-extremely-slow",
211
&self.i_am_going_extremely_slow,
212
)
213
.finish()
214
}
215
}
216
const _: () = {
217
assert!(
218
16 == < LudicrousSpeed as wasmtime::component::ComponentType
219
>::SIZE32
220
);
221
assert!(
222
8 == < LudicrousSpeed as wasmtime::component::ComponentType
223
>::ALIGN32
224
);
225
};
226
pub trait HostWithStore: wasmtime::component::HasData {}
227
impl<_T: ?Sized> HostWithStore for _T
228
where
229
_T: wasmtime::component::HasData,
230
{}
231
pub trait Host {
232
fn kebab_case(&mut self) -> ();
233
fn foo(&mut self, x: LudicrousSpeed) -> ();
234
fn function_with_dashes(&mut self) -> ();
235
fn function_with_no_weird_characters(&mut self) -> ();
236
fn apple(&mut self) -> ();
237
fn apple_pear(&mut self) -> ();
238
fn apple_pear_grape(&mut self) -> ();
239
fn a0(&mut self) -> ();
240
/// Comment out identifiers that collide when mapped to snake_case, for now; see
241
/// https://github.com/WebAssembly/component-model/issues/118
242
/// APPLE: func()
243
/// APPLE-pear-GRAPE: func()
244
/// apple-PEAR-grape: func()
245
fn is_xml(&mut self) -> ();
246
fn explicit(&mut self) -> ();
247
fn explicit_kebab(&mut self) -> ();
248
/// Identifiers with the same name as keywords are quoted.
249
fn bool(&mut self) -> ();
250
}
251
impl<_T: Host + ?Sized> Host for &mut _T {
252
fn kebab_case(&mut self) -> () {
253
Host::kebab_case(*self)
254
}
255
fn foo(&mut self, x: LudicrousSpeed) -> () {
256
Host::foo(*self, x)
257
}
258
fn function_with_dashes(&mut self) -> () {
259
Host::function_with_dashes(*self)
260
}
261
fn function_with_no_weird_characters(&mut self) -> () {
262
Host::function_with_no_weird_characters(*self)
263
}
264
fn apple(&mut self) -> () {
265
Host::apple(*self)
266
}
267
fn apple_pear(&mut self) -> () {
268
Host::apple_pear(*self)
269
}
270
fn apple_pear_grape(&mut self) -> () {
271
Host::apple_pear_grape(*self)
272
}
273
fn a0(&mut self) -> () {
274
Host::a0(*self)
275
}
276
/// Comment out identifiers that collide when mapped to snake_case, for now; see
277
/// https://github.com/WebAssembly/component-model/issues/118
278
/// APPLE: func()
279
/// APPLE-pear-GRAPE: func()
280
/// apple-PEAR-grape: func()
281
fn is_xml(&mut self) -> () {
282
Host::is_xml(*self)
283
}
284
fn explicit(&mut self) -> () {
285
Host::explicit(*self)
286
}
287
fn explicit_kebab(&mut self) -> () {
288
Host::explicit_kebab(*self)
289
}
290
/// Identifiers with the same name as keywords are quoted.
291
fn bool(&mut self) -> () {
292
Host::bool(*self)
293
}
294
}
295
pub fn add_to_linker<T, D>(
296
linker: &mut wasmtime::component::Linker<T>,
297
host_getter: fn(&mut T) -> D::Data<'_>,
298
) -> wasmtime::Result<()>
299
where
300
D: HostWithStore,
301
for<'a> D::Data<'a>: Host,
302
T: 'static,
303
{
304
let mut inst = linker.instance("foo:foo/conventions")?;
305
inst.func_wrap(
306
"kebab-case",
307
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
308
let host = &mut host_getter(caller.data_mut());
309
let r = Host::kebab_case(host);
310
Ok(r)
311
},
312
)?;
313
inst.func_wrap(
314
"foo",
315
move |
316
mut caller: wasmtime::StoreContextMut<'_, T>,
317
(arg0,): (LudicrousSpeed,)|
318
{
319
let host = &mut host_getter(caller.data_mut());
320
let r = Host::foo(host, arg0);
321
Ok(r)
322
},
323
)?;
324
inst.func_wrap(
325
"function-with-dashes",
326
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
327
let host = &mut host_getter(caller.data_mut());
328
let r = Host::function_with_dashes(host);
329
Ok(r)
330
},
331
)?;
332
inst.func_wrap(
333
"function-with-no-weird-characters",
334
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
335
let host = &mut host_getter(caller.data_mut());
336
let r = Host::function_with_no_weird_characters(host);
337
Ok(r)
338
},
339
)?;
340
inst.func_wrap(
341
"apple",
342
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
343
let host = &mut host_getter(caller.data_mut());
344
let r = Host::apple(host);
345
Ok(r)
346
},
347
)?;
348
inst.func_wrap(
349
"apple-pear",
350
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
351
let host = &mut host_getter(caller.data_mut());
352
let r = Host::apple_pear(host);
353
Ok(r)
354
},
355
)?;
356
inst.func_wrap(
357
"apple-pear-grape",
358
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
359
let host = &mut host_getter(caller.data_mut());
360
let r = Host::apple_pear_grape(host);
361
Ok(r)
362
},
363
)?;
364
inst.func_wrap(
365
"a0",
366
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
367
let host = &mut host_getter(caller.data_mut());
368
let r = Host::a0(host);
369
Ok(r)
370
},
371
)?;
372
inst.func_wrap(
373
"is-XML",
374
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
375
let host = &mut host_getter(caller.data_mut());
376
let r = Host::is_xml(host);
377
Ok(r)
378
},
379
)?;
380
inst.func_wrap(
381
"explicit",
382
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
383
let host = &mut host_getter(caller.data_mut());
384
let r = Host::explicit(host);
385
Ok(r)
386
},
387
)?;
388
inst.func_wrap(
389
"explicit-kebab",
390
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
391
let host = &mut host_getter(caller.data_mut());
392
let r = Host::explicit_kebab(host);
393
Ok(r)
394
},
395
)?;
396
inst.func_wrap(
397
"bool",
398
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
399
let host = &mut host_getter(caller.data_mut());
400
let r = Host::bool(host);
401
Ok(r)
402
},
403
)?;
404
Ok(())
405
}
406
}
407
}
408
}
409
pub mod exports {
410
pub mod foo {
411
pub mod foo {
412
#[allow(clippy::all)]
413
pub mod conventions {
414
#[allow(unused_imports)]
415
use wasmtime::component::__internal::Box;
416
#[derive(wasmtime::component::ComponentType)]
417
#[derive(wasmtime::component::Lift)]
418
#[derive(wasmtime::component::Lower)]
419
#[component(record)]
420
#[derive(Clone, Copy)]
421
pub struct LudicrousSpeed {
422
#[component(name = "how-fast-are-you-going")]
423
pub how_fast_are_you_going: u32,
424
#[component(name = "i-am-going-extremely-slow")]
425
pub i_am_going_extremely_slow: u64,
426
}
427
impl core::fmt::Debug for LudicrousSpeed {
428
fn fmt(
429
&self,
430
f: &mut core::fmt::Formatter<'_>,
431
) -> core::fmt::Result {
432
f.debug_struct("LudicrousSpeed")
433
.field(
434
"how-fast-are-you-going",
435
&self.how_fast_are_you_going,
436
)
437
.field(
438
"i-am-going-extremely-slow",
439
&self.i_am_going_extremely_slow,
440
)
441
.finish()
442
}
443
}
444
const _: () = {
445
assert!(
446
16 == < LudicrousSpeed as wasmtime::component::ComponentType
447
>::SIZE32
448
);
449
assert!(
450
8 == < LudicrousSpeed as wasmtime::component::ComponentType
451
>::ALIGN32
452
);
453
};
454
#[derive(Clone)]
455
pub struct Guest {
456
kebab_case: wasmtime::component::Func,
457
foo: wasmtime::component::Func,
458
function_with_dashes: wasmtime::component::Func,
459
function_with_no_weird_characters: wasmtime::component::Func,
460
apple: wasmtime::component::Func,
461
apple_pear: wasmtime::component::Func,
462
apple_pear_grape: wasmtime::component::Func,
463
a0: wasmtime::component::Func,
464
is_xml: wasmtime::component::Func,
465
explicit: wasmtime::component::Func,
466
explicit_kebab: wasmtime::component::Func,
467
bool: wasmtime::component::Func,
468
}
469
#[derive(Clone)]
470
pub struct GuestIndices {
471
kebab_case: wasmtime::component::ComponentExportIndex,
472
foo: wasmtime::component::ComponentExportIndex,
473
function_with_dashes: wasmtime::component::ComponentExportIndex,
474
function_with_no_weird_characters: wasmtime::component::ComponentExportIndex,
475
apple: wasmtime::component::ComponentExportIndex,
476
apple_pear: wasmtime::component::ComponentExportIndex,
477
apple_pear_grape: wasmtime::component::ComponentExportIndex,
478
a0: wasmtime::component::ComponentExportIndex,
479
is_xml: wasmtime::component::ComponentExportIndex,
480
explicit: wasmtime::component::ComponentExportIndex,
481
explicit_kebab: wasmtime::component::ComponentExportIndex,
482
bool: wasmtime::component::ComponentExportIndex,
483
}
484
impl GuestIndices {
485
/// Constructor for [`GuestIndices`] which takes a
486
/// [`Component`](wasmtime::component::Component) as input and can be executed
487
/// before instantiation.
488
///
489
/// This constructor can be used to front-load string lookups to find exports
490
/// within a component.
491
pub fn new<_T>(
492
_instance_pre: &wasmtime::component::InstancePre<_T>,
493
) -> wasmtime::Result<GuestIndices> {
494
let instance = _instance_pre
495
.component()
496
.get_export_index(None, "foo:foo/conventions")
497
.ok_or_else(|| {
498
wasmtime::format_err!(
499
"no exported instance named `foo:foo/conventions`"
500
)
501
})?;
502
let mut lookup = move |name| {
503
_instance_pre
504
.component()
505
.get_export_index(Some(&instance), name)
506
.ok_or_else(|| {
507
wasmtime::format_err!(
508
"instance export `foo:foo/conventions` does \
509
not have export `{name}`"
510
)
511
})
512
};
513
let _ = &mut lookup;
514
let kebab_case = lookup("kebab-case")?;
515
let foo = lookup("foo")?;
516
let function_with_dashes = lookup("function-with-dashes")?;
517
let function_with_no_weird_characters = lookup(
518
"function-with-no-weird-characters",
519
)?;
520
let apple = lookup("apple")?;
521
let apple_pear = lookup("apple-pear")?;
522
let apple_pear_grape = lookup("apple-pear-grape")?;
523
let a0 = lookup("a0")?;
524
let is_xml = lookup("is-XML")?;
525
let explicit = lookup("explicit")?;
526
let explicit_kebab = lookup("explicit-kebab")?;
527
let bool = lookup("bool")?;
528
Ok(GuestIndices {
529
kebab_case,
530
foo,
531
function_with_dashes,
532
function_with_no_weird_characters,
533
apple,
534
apple_pear,
535
apple_pear_grape,
536
a0,
537
is_xml,
538
explicit,
539
explicit_kebab,
540
bool,
541
})
542
}
543
pub fn load(
544
&self,
545
mut store: impl wasmtime::AsContextMut,
546
instance: &wasmtime::component::Instance,
547
) -> wasmtime::Result<Guest> {
548
let _instance = instance;
549
let _instance_pre = _instance.instance_pre(&store);
550
let _instance_type = _instance_pre.instance_type();
551
let mut store = store.as_context_mut();
552
let _ = &mut store;
553
let kebab_case = *_instance
554
.get_typed_func::<(), ()>(&mut store, &self.kebab_case)?
555
.func();
556
let foo = *_instance
557
.get_typed_func::<
558
(LudicrousSpeed,),
559
(),
560
>(&mut store, &self.foo)?
561
.func();
562
let function_with_dashes = *_instance
563
.get_typed_func::<
564
(),
565
(),
566
>(&mut store, &self.function_with_dashes)?
567
.func();
568
let function_with_no_weird_characters = *_instance
569
.get_typed_func::<
570
(),
571
(),
572
>(&mut store, &self.function_with_no_weird_characters)?
573
.func();
574
let apple = *_instance
575
.get_typed_func::<(), ()>(&mut store, &self.apple)?
576
.func();
577
let apple_pear = *_instance
578
.get_typed_func::<(), ()>(&mut store, &self.apple_pear)?
579
.func();
580
let apple_pear_grape = *_instance
581
.get_typed_func::<
582
(),
583
(),
584
>(&mut store, &self.apple_pear_grape)?
585
.func();
586
let a0 = *_instance
587
.get_typed_func::<(), ()>(&mut store, &self.a0)?
588
.func();
589
let is_xml = *_instance
590
.get_typed_func::<(), ()>(&mut store, &self.is_xml)?
591
.func();
592
let explicit = *_instance
593
.get_typed_func::<(), ()>(&mut store, &self.explicit)?
594
.func();
595
let explicit_kebab = *_instance
596
.get_typed_func::<(), ()>(&mut store, &self.explicit_kebab)?
597
.func();
598
let bool = *_instance
599
.get_typed_func::<(), ()>(&mut store, &self.bool)?
600
.func();
601
Ok(Guest {
602
kebab_case,
603
foo,
604
function_with_dashes,
605
function_with_no_weird_characters,
606
apple,
607
apple_pear,
608
apple_pear_grape,
609
a0,
610
is_xml,
611
explicit,
612
explicit_kebab,
613
bool,
614
})
615
}
616
}
617
impl Guest {
618
pub fn call_kebab_case<S: wasmtime::AsContextMut>(
619
&self,
620
mut store: S,
621
) -> wasmtime::Result<()> {
622
let callee = unsafe {
623
wasmtime::component::TypedFunc::<
624
(),
625
(),
626
>::new_unchecked(self.kebab_case)
627
};
628
let () = callee.call(store.as_context_mut(), ())?;
629
Ok(())
630
}
631
pub fn call_foo<S: wasmtime::AsContextMut>(
632
&self,
633
mut store: S,
634
arg0: LudicrousSpeed,
635
) -> wasmtime::Result<()> {
636
let callee = unsafe {
637
wasmtime::component::TypedFunc::<
638
(LudicrousSpeed,),
639
(),
640
>::new_unchecked(self.foo)
641
};
642
let () = callee.call(store.as_context_mut(), (arg0,))?;
643
Ok(())
644
}
645
pub fn call_function_with_dashes<S: wasmtime::AsContextMut>(
646
&self,
647
mut store: S,
648
) -> wasmtime::Result<()> {
649
let callee = unsafe {
650
wasmtime::component::TypedFunc::<
651
(),
652
(),
653
>::new_unchecked(self.function_with_dashes)
654
};
655
let () = callee.call(store.as_context_mut(), ())?;
656
Ok(())
657
}
658
pub fn call_function_with_no_weird_characters<
659
S: wasmtime::AsContextMut,
660
>(&self, mut store: S) -> wasmtime::Result<()> {
661
let callee = unsafe {
662
wasmtime::component::TypedFunc::<
663
(),
664
(),
665
>::new_unchecked(self.function_with_no_weird_characters)
666
};
667
let () = callee.call(store.as_context_mut(), ())?;
668
Ok(())
669
}
670
pub fn call_apple<S: wasmtime::AsContextMut>(
671
&self,
672
mut store: S,
673
) -> wasmtime::Result<()> {
674
let callee = unsafe {
675
wasmtime::component::TypedFunc::<
676
(),
677
(),
678
>::new_unchecked(self.apple)
679
};
680
let () = callee.call(store.as_context_mut(), ())?;
681
Ok(())
682
}
683
pub fn call_apple_pear<S: wasmtime::AsContextMut>(
684
&self,
685
mut store: S,
686
) -> wasmtime::Result<()> {
687
let callee = unsafe {
688
wasmtime::component::TypedFunc::<
689
(),
690
(),
691
>::new_unchecked(self.apple_pear)
692
};
693
let () = callee.call(store.as_context_mut(), ())?;
694
Ok(())
695
}
696
pub fn call_apple_pear_grape<S: wasmtime::AsContextMut>(
697
&self,
698
mut store: S,
699
) -> wasmtime::Result<()> {
700
let callee = unsafe {
701
wasmtime::component::TypedFunc::<
702
(),
703
(),
704
>::new_unchecked(self.apple_pear_grape)
705
};
706
let () = callee.call(store.as_context_mut(), ())?;
707
Ok(())
708
}
709
pub fn call_a0<S: wasmtime::AsContextMut>(
710
&self,
711
mut store: S,
712
) -> wasmtime::Result<()> {
713
let callee = unsafe {
714
wasmtime::component::TypedFunc::<
715
(),
716
(),
717
>::new_unchecked(self.a0)
718
};
719
let () = callee.call(store.as_context_mut(), ())?;
720
Ok(())
721
}
722
/// Comment out identifiers that collide when mapped to snake_case, for now; see
723
/// https://github.com/WebAssembly/component-model/issues/118
724
/// APPLE: func()
725
/// APPLE-pear-GRAPE: func()
726
/// apple-PEAR-grape: func()
727
pub fn call_is_xml<S: wasmtime::AsContextMut>(
728
&self,
729
mut store: S,
730
) -> wasmtime::Result<()> {
731
let callee = unsafe {
732
wasmtime::component::TypedFunc::<
733
(),
734
(),
735
>::new_unchecked(self.is_xml)
736
};
737
let () = callee.call(store.as_context_mut(), ())?;
738
Ok(())
739
}
740
pub fn call_explicit<S: wasmtime::AsContextMut>(
741
&self,
742
mut store: S,
743
) -> wasmtime::Result<()> {
744
let callee = unsafe {
745
wasmtime::component::TypedFunc::<
746
(),
747
(),
748
>::new_unchecked(self.explicit)
749
};
750
let () = callee.call(store.as_context_mut(), ())?;
751
Ok(())
752
}
753
pub fn call_explicit_kebab<S: wasmtime::AsContextMut>(
754
&self,
755
mut store: S,
756
) -> wasmtime::Result<()> {
757
let callee = unsafe {
758
wasmtime::component::TypedFunc::<
759
(),
760
(),
761
>::new_unchecked(self.explicit_kebab)
762
};
763
let () = callee.call(store.as_context_mut(), ())?;
764
Ok(())
765
}
766
/// Identifiers with the same name as keywords are quoted.
767
pub fn call_bool<S: wasmtime::AsContextMut>(
768
&self,
769
mut store: S,
770
) -> wasmtime::Result<()> {
771
let callee = unsafe {
772
wasmtime::component::TypedFunc::<
773
(),
774
(),
775
>::new_unchecked(self.bool)
776
};
777
let () = callee.call(store.as_context_mut(), ())?;
778
Ok(())
779
}
780
}
781
}
782
}
783
}
784
}
785
786