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
3071 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 + Send,
177
for<'a> D::Data<'a>: foo::foo::conventions::Host + Send,
178
T: 'static + Send,
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 + Send {
227
fn kebab_case<T: Send>(
228
accessor: &wasmtime::component::Accessor<T, Self>,
229
) -> impl ::core::future::Future<Output = ()> + Send;
230
fn foo<T: Send>(
231
accessor: &wasmtime::component::Accessor<T, Self>,
232
x: LudicrousSpeed,
233
) -> impl ::core::future::Future<Output = ()> + Send;
234
fn function_with_dashes<T: Send>(
235
accessor: &wasmtime::component::Accessor<T, Self>,
236
) -> impl ::core::future::Future<Output = ()> + Send;
237
fn function_with_no_weird_characters<T: Send>(
238
accessor: &wasmtime::component::Accessor<T, Self>,
239
) -> impl ::core::future::Future<Output = ()> + Send;
240
fn apple<T: Send>(
241
accessor: &wasmtime::component::Accessor<T, Self>,
242
) -> impl ::core::future::Future<Output = ()> + Send;
243
fn apple_pear<T: Send>(
244
accessor: &wasmtime::component::Accessor<T, Self>,
245
) -> impl ::core::future::Future<Output = ()> + Send;
246
fn apple_pear_grape<T: Send>(
247
accessor: &wasmtime::component::Accessor<T, Self>,
248
) -> impl ::core::future::Future<Output = ()> + Send;
249
fn a0<T: Send>(
250
accessor: &wasmtime::component::Accessor<T, Self>,
251
) -> impl ::core::future::Future<Output = ()> + Send;
252
/// Comment out identifiers that collide when mapped to snake_case, for now; see
253
/// https://github.com/WebAssembly/component-model/issues/118
254
/// APPLE: func()
255
/// APPLE-pear-GRAPE: func()
256
/// apple-PEAR-grape: func()
257
fn is_xml<T: Send>(
258
accessor: &wasmtime::component::Accessor<T, Self>,
259
) -> impl ::core::future::Future<Output = ()> + Send;
260
fn explicit<T: Send>(
261
accessor: &wasmtime::component::Accessor<T, Self>,
262
) -> impl ::core::future::Future<Output = ()> + Send;
263
fn explicit_kebab<T: Send>(
264
accessor: &wasmtime::component::Accessor<T, Self>,
265
) -> impl ::core::future::Future<Output = ()> + Send;
266
/// Identifiers with the same name as keywords are quoted.
267
fn bool<T: Send>(
268
accessor: &wasmtime::component::Accessor<T, Self>,
269
) -> impl ::core::future::Future<Output = ()> + Send;
270
}
271
pub trait Host: Send {}
272
impl<_T: Host + ?Sized + Send> Host for &mut _T {}
273
pub fn add_to_linker<T, D>(
274
linker: &mut wasmtime::component::Linker<T>,
275
host_getter: fn(&mut T) -> D::Data<'_>,
276
) -> wasmtime::Result<()>
277
where
278
D: HostWithStore,
279
for<'a> D::Data<'a>: Host,
280
T: 'static + Send,
281
{
282
let mut inst = linker.instance("foo:foo/conventions")?;
283
inst.func_wrap_concurrent(
284
"kebab-case",
285
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
286
wasmtime::component::__internal::Box::pin(async move {
287
let host = &caller.with_getter(host_getter);
288
let r = <D as HostWithStore>::kebab_case(host).await;
289
Ok(r)
290
})
291
},
292
)?;
293
inst.func_wrap_concurrent(
294
"foo",
295
move |
296
caller: &wasmtime::component::Accessor<T>,
297
(arg0,): (LudicrousSpeed,)|
298
{
299
wasmtime::component::__internal::Box::pin(async move {
300
let host = &caller.with_getter(host_getter);
301
let r = <D as HostWithStore>::foo(host, arg0).await;
302
Ok(r)
303
})
304
},
305
)?;
306
inst.func_wrap_concurrent(
307
"function-with-dashes",
308
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
309
wasmtime::component::__internal::Box::pin(async move {
310
let host = &caller.with_getter(host_getter);
311
let r = <D as HostWithStore>::function_with_dashes(host)
312
.await;
313
Ok(r)
314
})
315
},
316
)?;
317
inst.func_wrap_concurrent(
318
"function-with-no-weird-characters",
319
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
320
wasmtime::component::__internal::Box::pin(async move {
321
let host = &caller.with_getter(host_getter);
322
let r = <D as HostWithStore>::function_with_no_weird_characters(
323
host,
324
)
325
.await;
326
Ok(r)
327
})
328
},
329
)?;
330
inst.func_wrap_concurrent(
331
"apple",
332
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
333
wasmtime::component::__internal::Box::pin(async move {
334
let host = &caller.with_getter(host_getter);
335
let r = <D as HostWithStore>::apple(host).await;
336
Ok(r)
337
})
338
},
339
)?;
340
inst.func_wrap_concurrent(
341
"apple-pear",
342
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
343
wasmtime::component::__internal::Box::pin(async move {
344
let host = &caller.with_getter(host_getter);
345
let r = <D as HostWithStore>::apple_pear(host).await;
346
Ok(r)
347
})
348
},
349
)?;
350
inst.func_wrap_concurrent(
351
"apple-pear-grape",
352
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
353
wasmtime::component::__internal::Box::pin(async move {
354
let host = &caller.with_getter(host_getter);
355
let r = <D as HostWithStore>::apple_pear_grape(host).await;
356
Ok(r)
357
})
358
},
359
)?;
360
inst.func_wrap_concurrent(
361
"a0",
362
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
363
wasmtime::component::__internal::Box::pin(async move {
364
let host = &caller.with_getter(host_getter);
365
let r = <D as HostWithStore>::a0(host).await;
366
Ok(r)
367
})
368
},
369
)?;
370
inst.func_wrap_concurrent(
371
"is-XML",
372
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
373
wasmtime::component::__internal::Box::pin(async move {
374
let host = &caller.with_getter(host_getter);
375
let r = <D as HostWithStore>::is_xml(host).await;
376
Ok(r)
377
})
378
},
379
)?;
380
inst.func_wrap_concurrent(
381
"explicit",
382
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
383
wasmtime::component::__internal::Box::pin(async move {
384
let host = &caller.with_getter(host_getter);
385
let r = <D as HostWithStore>::explicit(host).await;
386
Ok(r)
387
})
388
},
389
)?;
390
inst.func_wrap_concurrent(
391
"explicit-kebab",
392
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
393
wasmtime::component::__internal::Box::pin(async move {
394
let host = &caller.with_getter(host_getter);
395
let r = <D as HostWithStore>::explicit_kebab(host).await;
396
Ok(r)
397
})
398
},
399
)?;
400
inst.func_wrap_concurrent(
401
"bool",
402
move |caller: &wasmtime::component::Accessor<T>, (): ()| {
403
wasmtime::component::__internal::Box::pin(async move {
404
let host = &caller.with_getter(host_getter);
405
let r = <D as HostWithStore>::bool(host).await;
406
Ok(r)
407
})
408
},
409
)?;
410
Ok(())
411
}
412
}
413
}
414
}
415
pub mod exports {
416
pub mod foo {
417
pub mod foo {
418
#[allow(clippy::all)]
419
pub mod conventions {
420
#[allow(unused_imports)]
421
use wasmtime::component::__internal::Box;
422
#[derive(wasmtime::component::ComponentType)]
423
#[derive(wasmtime::component::Lift)]
424
#[derive(wasmtime::component::Lower)]
425
#[component(record)]
426
#[derive(Clone, Copy)]
427
pub struct LudicrousSpeed {
428
#[component(name = "how-fast-are-you-going")]
429
pub how_fast_are_you_going: u32,
430
#[component(name = "i-am-going-extremely-slow")]
431
pub i_am_going_extremely_slow: u64,
432
}
433
impl core::fmt::Debug for LudicrousSpeed {
434
fn fmt(
435
&self,
436
f: &mut core::fmt::Formatter<'_>,
437
) -> core::fmt::Result {
438
f.debug_struct("LudicrousSpeed")
439
.field(
440
"how-fast-are-you-going",
441
&self.how_fast_are_you_going,
442
)
443
.field(
444
"i-am-going-extremely-slow",
445
&self.i_am_going_extremely_slow,
446
)
447
.finish()
448
}
449
}
450
const _: () = {
451
assert!(
452
16 == < LudicrousSpeed as wasmtime::component::ComponentType
453
>::SIZE32
454
);
455
assert!(
456
8 == < LudicrousSpeed as wasmtime::component::ComponentType
457
>::ALIGN32
458
);
459
};
460
#[derive(Clone)]
461
pub struct Guest {
462
kebab_case: wasmtime::component::Func,
463
foo: wasmtime::component::Func,
464
function_with_dashes: wasmtime::component::Func,
465
function_with_no_weird_characters: wasmtime::component::Func,
466
apple: wasmtime::component::Func,
467
apple_pear: wasmtime::component::Func,
468
apple_pear_grape: wasmtime::component::Func,
469
a0: wasmtime::component::Func,
470
is_xml: wasmtime::component::Func,
471
explicit: wasmtime::component::Func,
472
explicit_kebab: wasmtime::component::Func,
473
bool: wasmtime::component::Func,
474
}
475
#[derive(Clone)]
476
pub struct GuestIndices {
477
kebab_case: wasmtime::component::ComponentExportIndex,
478
foo: wasmtime::component::ComponentExportIndex,
479
function_with_dashes: wasmtime::component::ComponentExportIndex,
480
function_with_no_weird_characters: wasmtime::component::ComponentExportIndex,
481
apple: wasmtime::component::ComponentExportIndex,
482
apple_pear: wasmtime::component::ComponentExportIndex,
483
apple_pear_grape: wasmtime::component::ComponentExportIndex,
484
a0: wasmtime::component::ComponentExportIndex,
485
is_xml: wasmtime::component::ComponentExportIndex,
486
explicit: wasmtime::component::ComponentExportIndex,
487
explicit_kebab: wasmtime::component::ComponentExportIndex,
488
bool: wasmtime::component::ComponentExportIndex,
489
}
490
impl GuestIndices {
491
/// Constructor for [`GuestIndices`] which takes a
492
/// [`Component`](wasmtime::component::Component) as input and can be executed
493
/// before instantiation.
494
///
495
/// This constructor can be used to front-load string lookups to find exports
496
/// within a component.
497
pub fn new<_T>(
498
_instance_pre: &wasmtime::component::InstancePre<_T>,
499
) -> wasmtime::Result<GuestIndices> {
500
let instance = _instance_pre
501
.component()
502
.get_export_index(None, "foo:foo/conventions")
503
.ok_or_else(|| {
504
wasmtime::format_err!(
505
"no exported instance named `foo:foo/conventions`"
506
)
507
})?;
508
let mut lookup = move |name| {
509
_instance_pre
510
.component()
511
.get_export_index(Some(&instance), name)
512
.ok_or_else(|| {
513
wasmtime::format_err!(
514
"instance export `foo:foo/conventions` does \
515
not have export `{name}`"
516
)
517
})
518
};
519
let _ = &mut lookup;
520
let kebab_case = lookup("kebab-case")?;
521
let foo = lookup("foo")?;
522
let function_with_dashes = lookup("function-with-dashes")?;
523
let function_with_no_weird_characters = lookup(
524
"function-with-no-weird-characters",
525
)?;
526
let apple = lookup("apple")?;
527
let apple_pear = lookup("apple-pear")?;
528
let apple_pear_grape = lookup("apple-pear-grape")?;
529
let a0 = lookup("a0")?;
530
let is_xml = lookup("is-XML")?;
531
let explicit = lookup("explicit")?;
532
let explicit_kebab = lookup("explicit-kebab")?;
533
let bool = lookup("bool")?;
534
Ok(GuestIndices {
535
kebab_case,
536
foo,
537
function_with_dashes,
538
function_with_no_weird_characters,
539
apple,
540
apple_pear,
541
apple_pear_grape,
542
a0,
543
is_xml,
544
explicit,
545
explicit_kebab,
546
bool,
547
})
548
}
549
pub fn load(
550
&self,
551
mut store: impl wasmtime::AsContextMut,
552
instance: &wasmtime::component::Instance,
553
) -> wasmtime::Result<Guest> {
554
let _instance = instance;
555
let _instance_pre = _instance.instance_pre(&store);
556
let _instance_type = _instance_pre.instance_type();
557
let mut store = store.as_context_mut();
558
let _ = &mut store;
559
let kebab_case = *_instance
560
.get_typed_func::<(), ()>(&mut store, &self.kebab_case)?
561
.func();
562
let foo = *_instance
563
.get_typed_func::<
564
(LudicrousSpeed,),
565
(),
566
>(&mut store, &self.foo)?
567
.func();
568
let function_with_dashes = *_instance
569
.get_typed_func::<
570
(),
571
(),
572
>(&mut store, &self.function_with_dashes)?
573
.func();
574
let function_with_no_weird_characters = *_instance
575
.get_typed_func::<
576
(),
577
(),
578
>(&mut store, &self.function_with_no_weird_characters)?
579
.func();
580
let apple = *_instance
581
.get_typed_func::<(), ()>(&mut store, &self.apple)?
582
.func();
583
let apple_pear = *_instance
584
.get_typed_func::<(), ()>(&mut store, &self.apple_pear)?
585
.func();
586
let apple_pear_grape = *_instance
587
.get_typed_func::<
588
(),
589
(),
590
>(&mut store, &self.apple_pear_grape)?
591
.func();
592
let a0 = *_instance
593
.get_typed_func::<(), ()>(&mut store, &self.a0)?
594
.func();
595
let is_xml = *_instance
596
.get_typed_func::<(), ()>(&mut store, &self.is_xml)?
597
.func();
598
let explicit = *_instance
599
.get_typed_func::<(), ()>(&mut store, &self.explicit)?
600
.func();
601
let explicit_kebab = *_instance
602
.get_typed_func::<(), ()>(&mut store, &self.explicit_kebab)?
603
.func();
604
let bool = *_instance
605
.get_typed_func::<(), ()>(&mut store, &self.bool)?
606
.func();
607
Ok(Guest {
608
kebab_case,
609
foo,
610
function_with_dashes,
611
function_with_no_weird_characters,
612
apple,
613
apple_pear,
614
apple_pear_grape,
615
a0,
616
is_xml,
617
explicit,
618
explicit_kebab,
619
bool,
620
})
621
}
622
}
623
impl Guest {
624
pub async fn call_kebab_case<_T, _D>(
625
&self,
626
accessor: &wasmtime::component::Accessor<_T, _D>,
627
) -> wasmtime::Result<()>
628
where
629
_T: Send,
630
_D: wasmtime::component::HasData,
631
{
632
let callee = unsafe {
633
wasmtime::component::TypedFunc::<
634
(),
635
(),
636
>::new_unchecked(self.kebab_case)
637
};
638
let ((), _) = callee.call_concurrent(accessor, ()).await?;
639
Ok(())
640
}
641
pub async fn call_foo<_T, _D>(
642
&self,
643
accessor: &wasmtime::component::Accessor<_T, _D>,
644
arg0: LudicrousSpeed,
645
) -> wasmtime::Result<()>
646
where
647
_T: Send,
648
_D: wasmtime::component::HasData,
649
{
650
let callee = unsafe {
651
wasmtime::component::TypedFunc::<
652
(LudicrousSpeed,),
653
(),
654
>::new_unchecked(self.foo)
655
};
656
let ((), _) = callee.call_concurrent(accessor, (arg0,)).await?;
657
Ok(())
658
}
659
pub async fn call_function_with_dashes<_T, _D>(
660
&self,
661
accessor: &wasmtime::component::Accessor<_T, _D>,
662
) -> wasmtime::Result<()>
663
where
664
_T: Send,
665
_D: wasmtime::component::HasData,
666
{
667
let callee = unsafe {
668
wasmtime::component::TypedFunc::<
669
(),
670
(),
671
>::new_unchecked(self.function_with_dashes)
672
};
673
let ((), _) = callee.call_concurrent(accessor, ()).await?;
674
Ok(())
675
}
676
pub async fn call_function_with_no_weird_characters<_T, _D>(
677
&self,
678
accessor: &wasmtime::component::Accessor<_T, _D>,
679
) -> wasmtime::Result<()>
680
where
681
_T: Send,
682
_D: wasmtime::component::HasData,
683
{
684
let callee = unsafe {
685
wasmtime::component::TypedFunc::<
686
(),
687
(),
688
>::new_unchecked(self.function_with_no_weird_characters)
689
};
690
let ((), _) = callee.call_concurrent(accessor, ()).await?;
691
Ok(())
692
}
693
pub async fn call_apple<_T, _D>(
694
&self,
695
accessor: &wasmtime::component::Accessor<_T, _D>,
696
) -> wasmtime::Result<()>
697
where
698
_T: Send,
699
_D: wasmtime::component::HasData,
700
{
701
let callee = unsafe {
702
wasmtime::component::TypedFunc::<
703
(),
704
(),
705
>::new_unchecked(self.apple)
706
};
707
let ((), _) = callee.call_concurrent(accessor, ()).await?;
708
Ok(())
709
}
710
pub async fn call_apple_pear<_T, _D>(
711
&self,
712
accessor: &wasmtime::component::Accessor<_T, _D>,
713
) -> wasmtime::Result<()>
714
where
715
_T: Send,
716
_D: wasmtime::component::HasData,
717
{
718
let callee = unsafe {
719
wasmtime::component::TypedFunc::<
720
(),
721
(),
722
>::new_unchecked(self.apple_pear)
723
};
724
let ((), _) = callee.call_concurrent(accessor, ()).await?;
725
Ok(())
726
}
727
pub async fn call_apple_pear_grape<_T, _D>(
728
&self,
729
accessor: &wasmtime::component::Accessor<_T, _D>,
730
) -> wasmtime::Result<()>
731
where
732
_T: Send,
733
_D: wasmtime::component::HasData,
734
{
735
let callee = unsafe {
736
wasmtime::component::TypedFunc::<
737
(),
738
(),
739
>::new_unchecked(self.apple_pear_grape)
740
};
741
let ((), _) = callee.call_concurrent(accessor, ()).await?;
742
Ok(())
743
}
744
pub async fn call_a0<_T, _D>(
745
&self,
746
accessor: &wasmtime::component::Accessor<_T, _D>,
747
) -> wasmtime::Result<()>
748
where
749
_T: Send,
750
_D: wasmtime::component::HasData,
751
{
752
let callee = unsafe {
753
wasmtime::component::TypedFunc::<
754
(),
755
(),
756
>::new_unchecked(self.a0)
757
};
758
let ((), _) = callee.call_concurrent(accessor, ()).await?;
759
Ok(())
760
}
761
/// Comment out identifiers that collide when mapped to snake_case, for now; see
762
/// https://github.com/WebAssembly/component-model/issues/118
763
/// APPLE: func()
764
/// APPLE-pear-GRAPE: func()
765
/// apple-PEAR-grape: func()
766
pub async fn call_is_xml<_T, _D>(
767
&self,
768
accessor: &wasmtime::component::Accessor<_T, _D>,
769
) -> wasmtime::Result<()>
770
where
771
_T: Send,
772
_D: wasmtime::component::HasData,
773
{
774
let callee = unsafe {
775
wasmtime::component::TypedFunc::<
776
(),
777
(),
778
>::new_unchecked(self.is_xml)
779
};
780
let ((), _) = callee.call_concurrent(accessor, ()).await?;
781
Ok(())
782
}
783
pub async fn call_explicit<_T, _D>(
784
&self,
785
accessor: &wasmtime::component::Accessor<_T, _D>,
786
) -> wasmtime::Result<()>
787
where
788
_T: Send,
789
_D: wasmtime::component::HasData,
790
{
791
let callee = unsafe {
792
wasmtime::component::TypedFunc::<
793
(),
794
(),
795
>::new_unchecked(self.explicit)
796
};
797
let ((), _) = callee.call_concurrent(accessor, ()).await?;
798
Ok(())
799
}
800
pub async fn call_explicit_kebab<_T, _D>(
801
&self,
802
accessor: &wasmtime::component::Accessor<_T, _D>,
803
) -> wasmtime::Result<()>
804
where
805
_T: Send,
806
_D: wasmtime::component::HasData,
807
{
808
let callee = unsafe {
809
wasmtime::component::TypedFunc::<
810
(),
811
(),
812
>::new_unchecked(self.explicit_kebab)
813
};
814
let ((), _) = callee.call_concurrent(accessor, ()).await?;
815
Ok(())
816
}
817
/// Identifiers with the same name as keywords are quoted.
818
pub async fn call_bool<_T, _D>(
819
&self,
820
accessor: &wasmtime::component::Accessor<_T, _D>,
821
) -> wasmtime::Result<()>
822
where
823
_T: Send,
824
_D: wasmtime::component::HasData,
825
{
826
let callee = unsafe {
827
wasmtime::component::TypedFunc::<
828
(),
829
(),
830
>::new_unchecked(self.bool)
831
};
832
let ((), _) = callee.call_concurrent(accessor, ()).await?;
833
Ok(())
834
}
835
}
836
}
837
}
838
}
839
}
840
841