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