1 /// Auto-generated bindings for a pre-instantiated version of a 2 /// component which implements the world `my-world`. 3 /// 4 /// This structure is created through [`MyWorldPre::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 [`MyWorld`] as well. 9 pub struct MyWorldPre<T: 'static> { 10 instance_pre: wasmtime::component::InstancePre<T>, 11 indices: MyWorldIndices, 12 } 13 impl<T: 'static> Clone for MyWorldPre<T> { clone(&self) -> Self14 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> MyWorldPre<_T> { 22 /// Creates a new copy of `MyWorldPre` 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. new( instance_pre: wasmtime::component::InstancePre<_T>, ) -> wasmtime::Result<Self>27 pub fn new( 28 instance_pre: wasmtime::component::InstancePre<_T>, 29 ) -> wasmtime::Result<Self> { 30 let indices = MyWorldIndices::new(&instance_pre)?; 31 Ok(Self { instance_pre, indices }) 32 } engine(&self) -> &wasmtime::Engine33 pub fn engine(&self) -> &wasmtime::Engine { 34 self.instance_pre.engine() 35 } instance_pre(&self) -> &wasmtime::component::InstancePre<_T>36 pub fn instance_pre(&self) -> &wasmtime::component::InstancePre<_T> { 37 &self.instance_pre 38 } 39 /// Instantiates a new instance of [`MyWorld`] 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. instantiate( &self, mut store: impl wasmtime::AsContextMut<Data = _T>, ) -> wasmtime::Result<MyWorld>46 pub fn instantiate( 47 &self, 48 mut store: impl wasmtime::AsContextMut<Data = _T>, 49 ) -> wasmtime::Result<MyWorld> { 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> MyWorldPre<_T> { 56 /// Same as [`Self::instantiate`], except with `async`. instantiate_async( &self, mut store: impl wasmtime::AsContextMut<Data = _T>, ) -> wasmtime::Result<MyWorld>57 pub async fn instantiate_async( 58 &self, 59 mut store: impl wasmtime::AsContextMut<Data = _T>, 60 ) -> wasmtime::Result<MyWorld> { 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 /// `my-world`. 68 /// 69 /// This is an implementation detail of [`MyWorldPre`] and can 70 /// be constructed if needed as well. 71 /// 72 /// For more information see [`MyWorld`] as well. 73 #[derive(Clone)] 74 pub struct MyWorldIndices { 75 interface0: exports::foo::foo::variants::GuestIndices, 76 } 77 /// Auto-generated bindings for an instance a component which 78 /// implements the world `my-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 /// [`MyWorld::instantiate`] which only needs a 85 /// [`Store`], [`Component`], and [`Linker`]. 86 /// 87 /// * Alternatively you can create a [`MyWorldPre`] 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 [`MyWorldPre::instantiate`] to 91 /// create a [`MyWorld`]. 92 /// 93 /// * If you've instantiated the instance yourself already 94 /// then you can use [`MyWorld::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 MyWorld { 103 interface0: exports::foo::foo::variants::Guest, 104 } 105 const _: () = { 106 impl MyWorldIndices { 107 /// Creates a new copy of `MyWorldIndices` 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. new<_T>( _instance_pre: &wasmtime::component::InstancePre<_T>, ) -> wasmtime::Result<Self>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::variants::GuestIndices::new( 118 _instance_pre, 119 )?; 120 Ok(MyWorldIndices { interface0 }) 121 } 122 /// Uses the indices stored in `self` to load an instance 123 /// of [`MyWorld`] from the instance provided. 124 /// 125 /// Note that at this time this method will additionally 126 /// perform type-checks of all exports. load( &self, mut store: impl wasmtime::AsContextMut, instance: &wasmtime::component::Instance, ) -> wasmtime::Result<MyWorld>127 pub fn load( 128 &self, 129 mut store: impl wasmtime::AsContextMut, 130 instance: &wasmtime::component::Instance, 131 ) -> wasmtime::Result<MyWorld> { 132 let _ = &mut store; 133 let _instance = instance; 134 let interface0 = self.interface0.load(&mut store, &_instance)?; 135 Ok(MyWorld { interface0 }) 136 } 137 } 138 impl MyWorld { 139 /// Convenience wrapper around [`MyWorldPre::new`] and 140 /// [`MyWorldPre::instantiate`]. instantiate<_T>( store: impl wasmtime::AsContextMut<Data = _T>, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, ) -> wasmtime::Result<MyWorld>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<MyWorld> { 146 let pre = linker.instantiate_pre(component)?; 147 MyWorldPre::new(pre)?.instantiate(store) 148 } 149 /// Convenience wrapper around [`MyWorldIndices::new`] and 150 /// [`MyWorldIndices::load`]. new( mut store: impl wasmtime::AsContextMut, instance: &wasmtime::component::Instance, ) -> wasmtime::Result<MyWorld>151 pub fn new( 152 mut store: impl wasmtime::AsContextMut, 153 instance: &wasmtime::component::Instance, 154 ) -> wasmtime::Result<MyWorld> { 155 let indices = MyWorldIndices::new(&instance.instance_pre(&store))?; 156 indices.load(&mut store, instance) 157 } 158 /// Convenience wrapper around [`MyWorldPre::new`] and 159 /// [`MyWorldPre::instantiate_async`]. instantiate_async<_T>( store: impl wasmtime::AsContextMut<Data = _T>, component: &wasmtime::component::Component, linker: &wasmtime::component::Linker<_T>, ) -> wasmtime::Result<MyWorld> where _T: Send,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<MyWorld> 165 where 166 _T: Send, 167 { 168 let pre = linker.instantiate_pre(component)?; 169 MyWorldPre::new(pre)?.instantiate_async(store).await 170 } add_to_linker<T, D>( linker: &mut wasmtime::component::Linker<T>, host_getter: fn(&mut T) -> D::Data<'_>, ) -> wasmtime::Result<()> where D: foo::foo::variants::HostWithStore, for<'a> D::Data<'a>: foo::foo::variants::Host, T: 'static,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::variants::HostWithStore, 177 for<'a> D::Data<'a>: foo::foo::variants::Host, 178 T: 'static, 179 { 180 foo::foo::variants::add_to_linker::<T, D>(linker, host_getter)?; 181 Ok(()) 182 } foo_foo_variants(&self) -> &exports::foo::foo::variants::Guest183 pub fn foo_foo_variants(&self) -> &exports::foo::foo::variants::Guest { 184 &self.interface0 185 } 186 } 187 }; 188 pub mod foo { 189 pub mod foo { 190 #[allow(clippy::all)] 191 pub mod variants { 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(enum)] 198 #[derive(Clone, Copy, Eq, PartialEq)] 199 #[repr(u8)] 200 pub enum E1 { 201 #[component(name = "a")] 202 A, 203 } 204 impl core::fmt::Debug for E1 { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result205 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 206 match self { 207 E1::A => f.debug_tuple("E1::A").finish(), 208 } 209 } 210 } 211 const _: () = { 212 assert!(1 == < E1 as wasmtime::component::ComponentType >::SIZE32); 213 assert!(1 == < E1 as wasmtime::component::ComponentType >::ALIGN32); 214 }; 215 #[derive(wasmtime::component::ComponentType)] 216 #[derive(wasmtime::component::Lift)] 217 #[derive(wasmtime::component::Lower)] 218 #[component(record)] 219 #[derive(Clone, Copy)] 220 pub struct Empty {} 221 impl core::fmt::Debug for Empty { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result222 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 223 f.debug_struct("Empty").finish() 224 } 225 } 226 const _: () = { 227 assert!(0 == < Empty as wasmtime::component::ComponentType >::SIZE32); 228 assert!(1 == < Empty as wasmtime::component::ComponentType >::ALIGN32); 229 }; 230 #[derive(wasmtime::component::ComponentType)] 231 #[derive(wasmtime::component::Lift)] 232 #[derive(wasmtime::component::Lower)] 233 #[component(variant)] 234 #[derive(Clone)] 235 pub enum V1 { 236 #[component(name = "a")] 237 A, 238 #[component(name = "c")] 239 C(E1), 240 #[component(name = "d")] 241 D(wasmtime::component::__internal::String), 242 #[component(name = "e")] 243 E(Empty), 244 #[component(name = "f")] 245 F, 246 #[component(name = "g")] 247 G(u32), 248 } 249 impl core::fmt::Debug for V1 { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result250 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 251 match self { 252 V1::A => f.debug_tuple("V1::A").finish(), 253 V1::C(e) => f.debug_tuple("V1::C").field(e).finish(), 254 V1::D(e) => f.debug_tuple("V1::D").field(e).finish(), 255 V1::E(e) => f.debug_tuple("V1::E").field(e).finish(), 256 V1::F => f.debug_tuple("V1::F").finish(), 257 V1::G(e) => f.debug_tuple("V1::G").field(e).finish(), 258 } 259 } 260 } 261 const _: () = { 262 assert!(12 == < V1 as wasmtime::component::ComponentType >::SIZE32); 263 assert!(4 == < V1 as wasmtime::component::ComponentType >::ALIGN32); 264 }; 265 #[derive(wasmtime::component::ComponentType)] 266 #[derive(wasmtime::component::Lift)] 267 #[derive(wasmtime::component::Lower)] 268 #[component(variant)] 269 #[derive(Clone, Copy)] 270 pub enum Casts1 { 271 #[component(name = "a")] 272 A(i32), 273 #[component(name = "b")] 274 B(f32), 275 } 276 impl core::fmt::Debug for Casts1 { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result277 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 278 match self { 279 Casts1::A(e) => f.debug_tuple("Casts1::A").field(e).finish(), 280 Casts1::B(e) => f.debug_tuple("Casts1::B").field(e).finish(), 281 } 282 } 283 } 284 const _: () = { 285 assert!(8 == < Casts1 as wasmtime::component::ComponentType >::SIZE32); 286 assert!(4 == < Casts1 as wasmtime::component::ComponentType >::ALIGN32); 287 }; 288 #[derive(wasmtime::component::ComponentType)] 289 #[derive(wasmtime::component::Lift)] 290 #[derive(wasmtime::component::Lower)] 291 #[component(variant)] 292 #[derive(Clone, Copy)] 293 pub enum Casts2 { 294 #[component(name = "a")] 295 A(f64), 296 #[component(name = "b")] 297 B(f32), 298 } 299 impl core::fmt::Debug for Casts2 { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result300 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 301 match self { 302 Casts2::A(e) => f.debug_tuple("Casts2::A").field(e).finish(), 303 Casts2::B(e) => f.debug_tuple("Casts2::B").field(e).finish(), 304 } 305 } 306 } 307 const _: () = { 308 assert!(16 == < Casts2 as wasmtime::component::ComponentType >::SIZE32); 309 assert!(8 == < Casts2 as wasmtime::component::ComponentType >::ALIGN32); 310 }; 311 #[derive(wasmtime::component::ComponentType)] 312 #[derive(wasmtime::component::Lift)] 313 #[derive(wasmtime::component::Lower)] 314 #[component(variant)] 315 #[derive(Clone, Copy)] 316 pub enum Casts3 { 317 #[component(name = "a")] 318 A(f64), 319 #[component(name = "b")] 320 B(u64), 321 } 322 impl core::fmt::Debug for Casts3 { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result323 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 324 match self { 325 Casts3::A(e) => f.debug_tuple("Casts3::A").field(e).finish(), 326 Casts3::B(e) => f.debug_tuple("Casts3::B").field(e).finish(), 327 } 328 } 329 } 330 const _: () = { 331 assert!(16 == < Casts3 as wasmtime::component::ComponentType >::SIZE32); 332 assert!(8 == < Casts3 as wasmtime::component::ComponentType >::ALIGN32); 333 }; 334 #[derive(wasmtime::component::ComponentType)] 335 #[derive(wasmtime::component::Lift)] 336 #[derive(wasmtime::component::Lower)] 337 #[component(variant)] 338 #[derive(Clone, Copy)] 339 pub enum Casts4 { 340 #[component(name = "a")] 341 A(u32), 342 #[component(name = "b")] 343 B(i64), 344 } 345 impl core::fmt::Debug for Casts4 { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result346 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 347 match self { 348 Casts4::A(e) => f.debug_tuple("Casts4::A").field(e).finish(), 349 Casts4::B(e) => f.debug_tuple("Casts4::B").field(e).finish(), 350 } 351 } 352 } 353 const _: () = { 354 assert!(16 == < Casts4 as wasmtime::component::ComponentType >::SIZE32); 355 assert!(8 == < Casts4 as wasmtime::component::ComponentType >::ALIGN32); 356 }; 357 #[derive(wasmtime::component::ComponentType)] 358 #[derive(wasmtime::component::Lift)] 359 #[derive(wasmtime::component::Lower)] 360 #[component(variant)] 361 #[derive(Clone, Copy)] 362 pub enum Casts5 { 363 #[component(name = "a")] 364 A(f32), 365 #[component(name = "b")] 366 B(i64), 367 } 368 impl core::fmt::Debug for Casts5 { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result369 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 370 match self { 371 Casts5::A(e) => f.debug_tuple("Casts5::A").field(e).finish(), 372 Casts5::B(e) => f.debug_tuple("Casts5::B").field(e).finish(), 373 } 374 } 375 } 376 const _: () = { 377 assert!(16 == < Casts5 as wasmtime::component::ComponentType >::SIZE32); 378 assert!(8 == < Casts5 as wasmtime::component::ComponentType >::ALIGN32); 379 }; 380 #[derive(wasmtime::component::ComponentType)] 381 #[derive(wasmtime::component::Lift)] 382 #[derive(wasmtime::component::Lower)] 383 #[component(variant)] 384 #[derive(Clone, Copy)] 385 pub enum Casts6 { 386 #[component(name = "a")] 387 A((f32, u32)), 388 #[component(name = "b")] 389 B((u32, u32)), 390 } 391 impl core::fmt::Debug for Casts6 { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result392 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 393 match self { 394 Casts6::A(e) => f.debug_tuple("Casts6::A").field(e).finish(), 395 Casts6::B(e) => f.debug_tuple("Casts6::B").field(e).finish(), 396 } 397 } 398 } 399 const _: () = { 400 assert!(12 == < Casts6 as wasmtime::component::ComponentType >::SIZE32); 401 assert!(4 == < Casts6 as wasmtime::component::ComponentType >::ALIGN32); 402 }; 403 #[derive(wasmtime::component::ComponentType)] 404 #[derive(wasmtime::component::Lift)] 405 #[derive(wasmtime::component::Lower)] 406 #[component(enum)] 407 #[derive(Clone, Copy, Eq, PartialEq)] 408 #[repr(u8)] 409 pub enum MyErrno { 410 #[component(name = "bad1")] 411 Bad1, 412 #[component(name = "bad2")] 413 Bad2, 414 } 415 impl MyErrno { name(&self) -> &'static str416 pub fn name(&self) -> &'static str { 417 match self { 418 MyErrno::Bad1 => "bad1", 419 MyErrno::Bad2 => "bad2", 420 } 421 } message(&self) -> &'static str422 pub fn message(&self) -> &'static str { 423 match self { 424 MyErrno::Bad1 => "", 425 MyErrno::Bad2 => "", 426 } 427 } 428 } 429 impl core::fmt::Debug for MyErrno { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result430 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 431 f.debug_struct("MyErrno") 432 .field("code", &(*self as i32)) 433 .field("name", &self.name()) 434 .field("message", &self.message()) 435 .finish() 436 } 437 } 438 impl core::fmt::Display for MyErrno { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result439 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 440 write!(f, "{} (error {})", self.name(), * self as i32) 441 } 442 } 443 impl core::error::Error for MyErrno {} 444 const _: () = { 445 assert!(1 == < MyErrno as wasmtime::component::ComponentType >::SIZE32); 446 assert!(1 == < MyErrno as wasmtime::component::ComponentType >::ALIGN32); 447 }; 448 #[derive(wasmtime::component::ComponentType)] 449 #[derive(wasmtime::component::Lift)] 450 #[derive(wasmtime::component::Lower)] 451 #[component(record)] 452 #[derive(Clone)] 453 pub struct IsClone { 454 #[component(name = "v1")] 455 pub v1: V1, 456 } 457 impl core::fmt::Debug for IsClone { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result458 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 459 f.debug_struct("IsClone").field("v1", &self.v1).finish() 460 } 461 } 462 const _: () = { 463 assert!(12 == < IsClone as wasmtime::component::ComponentType >::SIZE32); 464 assert!(4 == < IsClone as wasmtime::component::ComponentType >::ALIGN32); 465 }; 466 pub trait HostWithStore: wasmtime::component::HasData {} 467 impl<_T: ?Sized> HostWithStore for _T 468 where 469 _T: wasmtime::component::HasData, 470 {} 471 pub trait Host { e1_arg(&mut self, x: E1) -> ()472 fn e1_arg(&mut self, x: E1) -> (); e1_result(&mut self) -> E1473 fn e1_result(&mut self) -> E1; v1_arg(&mut self, x: V1) -> ()474 fn v1_arg(&mut self, x: V1) -> (); v1_result(&mut self) -> V1475 fn v1_result(&mut self) -> V1; bool_arg(&mut self, x: bool) -> ()476 fn bool_arg(&mut self, x: bool) -> (); bool_result(&mut self) -> bool477 fn bool_result(&mut self) -> bool; option_arg( &mut self, a: Option<bool>, b: Option<()>, c: Option<u32>, d: Option<E1>, e: Option<f32>, g: Option<Option<bool>>, ) -> ()478 fn option_arg( 479 &mut self, 480 a: Option<bool>, 481 b: Option<()>, 482 c: Option<u32>, 483 d: Option<E1>, 484 e: Option<f32>, 485 g: Option<Option<bool>>, 486 ) -> (); option_result( &mut self, ) -> ( Option<bool>, Option<()>, Option<u32>, Option<E1>, Option<f32>, Option<Option<bool>>, )487 fn option_result( 488 &mut self, 489 ) -> ( 490 Option<bool>, 491 Option<()>, 492 Option<u32>, 493 Option<E1>, 494 Option<f32>, 495 Option<Option<bool>>, 496 ); casts( &mut self, a: Casts1, b: Casts2, c: Casts3, d: Casts4, e: Casts5, f: Casts6, ) -> (Casts1, Casts2, Casts3, Casts4, Casts5, Casts6)497 fn casts( 498 &mut self, 499 a: Casts1, 500 b: Casts2, 501 c: Casts3, 502 d: Casts4, 503 e: Casts5, 504 f: Casts6, 505 ) -> (Casts1, Casts2, Casts3, Casts4, Casts5, Casts6); result_arg( &mut self, a: Result<(), ()>, b: Result<(), E1>, c: Result<E1, ()>, d: Result<(), ()>, e: Result<u32, V1>, f: Result< wasmtime::component::__internal::String, wasmtime::component::__internal::Vec<u8>, >, ) -> ()506 fn result_arg( 507 &mut self, 508 a: Result<(), ()>, 509 b: Result<(), E1>, 510 c: Result<E1, ()>, 511 d: Result<(), ()>, 512 e: Result<u32, V1>, 513 f: Result< 514 wasmtime::component::__internal::String, 515 wasmtime::component::__internal::Vec<u8>, 516 >, 517 ) -> (); result_result( &mut self, ) -> ( Result<(), ()>, Result<(), E1>, Result<E1, ()>, Result<(), ()>, Result<u32, V1>, Result< wasmtime::component::__internal::String, wasmtime::component::__internal::Vec<u8>, >, )518 fn result_result( 519 &mut self, 520 ) -> ( 521 Result<(), ()>, 522 Result<(), E1>, 523 Result<E1, ()>, 524 Result<(), ()>, 525 Result<u32, V1>, 526 Result< 527 wasmtime::component::__internal::String, 528 wasmtime::component::__internal::Vec<u8>, 529 >, 530 ); return_result_sugar(&mut self) -> Result<i32, MyErrno>531 fn return_result_sugar(&mut self) -> Result<i32, MyErrno>; return_result_sugar2(&mut self) -> Result<(), MyErrno>532 fn return_result_sugar2(&mut self) -> Result<(), MyErrno>; return_result_sugar3(&mut self) -> Result<MyErrno, MyErrno>533 fn return_result_sugar3(&mut self) -> Result<MyErrno, MyErrno>; return_result_sugar4(&mut self) -> Result<(i32, u32), MyErrno>534 fn return_result_sugar4(&mut self) -> Result<(i32, u32), MyErrno>; return_option_sugar(&mut self) -> Option<i32>535 fn return_option_sugar(&mut self) -> Option<i32>; return_option_sugar2(&mut self) -> Option<MyErrno>536 fn return_option_sugar2(&mut self) -> Option<MyErrno>; result_simple(&mut self) -> Result<u32, i32>537 fn result_simple(&mut self) -> Result<u32, i32>; is_clone_arg(&mut self, a: IsClone) -> ()538 fn is_clone_arg(&mut self, a: IsClone) -> (); is_clone_return(&mut self) -> IsClone539 fn is_clone_return(&mut self) -> IsClone; 540 } 541 impl<_T: Host + ?Sized> Host for &mut _T { e1_arg(&mut self, x: E1) -> ()542 fn e1_arg(&mut self, x: E1) -> () { 543 Host::e1_arg(*self, x) 544 } e1_result(&mut self) -> E1545 fn e1_result(&mut self) -> E1 { 546 Host::e1_result(*self) 547 } v1_arg(&mut self, x: V1) -> ()548 fn v1_arg(&mut self, x: V1) -> () { 549 Host::v1_arg(*self, x) 550 } v1_result(&mut self) -> V1551 fn v1_result(&mut self) -> V1 { 552 Host::v1_result(*self) 553 } bool_arg(&mut self, x: bool) -> ()554 fn bool_arg(&mut self, x: bool) -> () { 555 Host::bool_arg(*self, x) 556 } bool_result(&mut self) -> bool557 fn bool_result(&mut self) -> bool { 558 Host::bool_result(*self) 559 } option_arg( &mut self, a: Option<bool>, b: Option<()>, c: Option<u32>, d: Option<E1>, e: Option<f32>, g: Option<Option<bool>>, ) -> ()560 fn option_arg( 561 &mut self, 562 a: Option<bool>, 563 b: Option<()>, 564 c: Option<u32>, 565 d: Option<E1>, 566 e: Option<f32>, 567 g: Option<Option<bool>>, 568 ) -> () { 569 Host::option_arg(*self, a, b, c, d, e, g) 570 } option_result( &mut self, ) -> ( Option<bool>, Option<()>, Option<u32>, Option<E1>, Option<f32>, Option<Option<bool>>, )571 fn option_result( 572 &mut self, 573 ) -> ( 574 Option<bool>, 575 Option<()>, 576 Option<u32>, 577 Option<E1>, 578 Option<f32>, 579 Option<Option<bool>>, 580 ) { 581 Host::option_result(*self) 582 } casts( &mut self, a: Casts1, b: Casts2, c: Casts3, d: Casts4, e: Casts5, f: Casts6, ) -> (Casts1, Casts2, Casts3, Casts4, Casts5, Casts6)583 fn casts( 584 &mut self, 585 a: Casts1, 586 b: Casts2, 587 c: Casts3, 588 d: Casts4, 589 e: Casts5, 590 f: Casts6, 591 ) -> (Casts1, Casts2, Casts3, Casts4, Casts5, Casts6) { 592 Host::casts(*self, a, b, c, d, e, f) 593 } result_arg( &mut self, a: Result<(), ()>, b: Result<(), E1>, c: Result<E1, ()>, d: Result<(), ()>, e: Result<u32, V1>, f: Result< wasmtime::component::__internal::String, wasmtime::component::__internal::Vec<u8>, >, ) -> ()594 fn result_arg( 595 &mut self, 596 a: Result<(), ()>, 597 b: Result<(), E1>, 598 c: Result<E1, ()>, 599 d: Result<(), ()>, 600 e: Result<u32, V1>, 601 f: Result< 602 wasmtime::component::__internal::String, 603 wasmtime::component::__internal::Vec<u8>, 604 >, 605 ) -> () { 606 Host::result_arg(*self, a, b, c, d, e, f) 607 } result_result( &mut self, ) -> ( Result<(), ()>, Result<(), E1>, Result<E1, ()>, Result<(), ()>, Result<u32, V1>, Result< wasmtime::component::__internal::String, wasmtime::component::__internal::Vec<u8>, >, )608 fn result_result( 609 &mut self, 610 ) -> ( 611 Result<(), ()>, 612 Result<(), E1>, 613 Result<E1, ()>, 614 Result<(), ()>, 615 Result<u32, V1>, 616 Result< 617 wasmtime::component::__internal::String, 618 wasmtime::component::__internal::Vec<u8>, 619 >, 620 ) { 621 Host::result_result(*self) 622 } return_result_sugar(&mut self) -> Result<i32, MyErrno>623 fn return_result_sugar(&mut self) -> Result<i32, MyErrno> { 624 Host::return_result_sugar(*self) 625 } return_result_sugar2(&mut self) -> Result<(), MyErrno>626 fn return_result_sugar2(&mut self) -> Result<(), MyErrno> { 627 Host::return_result_sugar2(*self) 628 } return_result_sugar3(&mut self) -> Result<MyErrno, MyErrno>629 fn return_result_sugar3(&mut self) -> Result<MyErrno, MyErrno> { 630 Host::return_result_sugar3(*self) 631 } return_result_sugar4(&mut self) -> Result<(i32, u32), MyErrno>632 fn return_result_sugar4(&mut self) -> Result<(i32, u32), MyErrno> { 633 Host::return_result_sugar4(*self) 634 } return_option_sugar(&mut self) -> Option<i32>635 fn return_option_sugar(&mut self) -> Option<i32> { 636 Host::return_option_sugar(*self) 637 } return_option_sugar2(&mut self) -> Option<MyErrno>638 fn return_option_sugar2(&mut self) -> Option<MyErrno> { 639 Host::return_option_sugar2(*self) 640 } result_simple(&mut self) -> Result<u32, i32>641 fn result_simple(&mut self) -> Result<u32, i32> { 642 Host::result_simple(*self) 643 } is_clone_arg(&mut self, a: IsClone) -> ()644 fn is_clone_arg(&mut self, a: IsClone) -> () { 645 Host::is_clone_arg(*self, a) 646 } is_clone_return(&mut self) -> IsClone647 fn is_clone_return(&mut self) -> IsClone { 648 Host::is_clone_return(*self) 649 } 650 } add_to_linker<T, D>( linker: &mut wasmtime::component::Linker<T>, host_getter: fn(&mut T) -> D::Data<'_>, ) -> wasmtime::Result<()> where D: HostWithStore, for<'a> D::Data<'a>: Host, T: 'static,651 pub fn add_to_linker<T, D>( 652 linker: &mut wasmtime::component::Linker<T>, 653 host_getter: fn(&mut T) -> D::Data<'_>, 654 ) -> wasmtime::Result<()> 655 where 656 D: HostWithStore, 657 for<'a> D::Data<'a>: Host, 658 T: 'static, 659 { 660 let mut inst = linker.instance("foo:foo/variants")?; 661 inst.func_wrap( 662 "e1-arg", 663 move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (E1,)| { 664 let host = &mut host_getter(caller.data_mut()); 665 let r = Host::e1_arg(host, arg0); 666 Ok(r) 667 }, 668 )?; 669 inst.func_wrap( 670 "e1-result", 671 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 672 let host = &mut host_getter(caller.data_mut()); 673 let r = Host::e1_result(host); 674 Ok((r,)) 675 }, 676 )?; 677 inst.func_wrap( 678 "v1-arg", 679 move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (V1,)| { 680 let host = &mut host_getter(caller.data_mut()); 681 let r = Host::v1_arg(host, arg0); 682 Ok(r) 683 }, 684 )?; 685 inst.func_wrap( 686 "v1-result", 687 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 688 let host = &mut host_getter(caller.data_mut()); 689 let r = Host::v1_result(host); 690 Ok((r,)) 691 }, 692 )?; 693 inst.func_wrap( 694 "bool-arg", 695 move | 696 mut caller: wasmtime::StoreContextMut<'_, T>, 697 (arg0,): (bool,)| 698 { 699 let host = &mut host_getter(caller.data_mut()); 700 let r = Host::bool_arg(host, arg0); 701 Ok(r) 702 }, 703 )?; 704 inst.func_wrap( 705 "bool-result", 706 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 707 let host = &mut host_getter(caller.data_mut()); 708 let r = Host::bool_result(host); 709 Ok((r,)) 710 }, 711 )?; 712 inst.func_wrap( 713 "option-arg", 714 move | 715 mut caller: wasmtime::StoreContextMut<'_, T>, 716 ( 717 arg0, 718 arg1, 719 arg2, 720 arg3, 721 arg4, 722 arg5, 723 ): ( 724 Option<bool>, 725 Option<()>, 726 Option<u32>, 727 Option<E1>, 728 Option<f32>, 729 Option<Option<bool>>, 730 )| 731 { 732 let host = &mut host_getter(caller.data_mut()); 733 let r = Host::option_arg( 734 host, 735 arg0, 736 arg1, 737 arg2, 738 arg3, 739 arg4, 740 arg5, 741 ); 742 Ok(r) 743 }, 744 )?; 745 inst.func_wrap( 746 "option-result", 747 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 748 let host = &mut host_getter(caller.data_mut()); 749 let r = Host::option_result(host); 750 Ok((r,)) 751 }, 752 )?; 753 inst.func_wrap( 754 "casts", 755 move | 756 mut caller: wasmtime::StoreContextMut<'_, T>, 757 ( 758 arg0, 759 arg1, 760 arg2, 761 arg3, 762 arg4, 763 arg5, 764 ): (Casts1, Casts2, Casts3, Casts4, Casts5, Casts6)| 765 { 766 let host = &mut host_getter(caller.data_mut()); 767 let r = Host::casts(host, arg0, arg1, arg2, arg3, arg4, arg5); 768 Ok((r,)) 769 }, 770 )?; 771 inst.func_wrap( 772 "result-arg", 773 move | 774 mut caller: wasmtime::StoreContextMut<'_, T>, 775 ( 776 arg0, 777 arg1, 778 arg2, 779 arg3, 780 arg4, 781 arg5, 782 ): ( 783 Result<(), ()>, 784 Result<(), E1>, 785 Result<E1, ()>, 786 Result<(), ()>, 787 Result<u32, V1>, 788 Result< 789 wasmtime::component::__internal::String, 790 wasmtime::component::__internal::Vec<u8>, 791 >, 792 )| 793 { 794 let host = &mut host_getter(caller.data_mut()); 795 let r = Host::result_arg( 796 host, 797 arg0, 798 arg1, 799 arg2, 800 arg3, 801 arg4, 802 arg5, 803 ); 804 Ok(r) 805 }, 806 )?; 807 inst.func_wrap( 808 "result-result", 809 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 810 let host = &mut host_getter(caller.data_mut()); 811 let r = Host::result_result(host); 812 Ok((r,)) 813 }, 814 )?; 815 inst.func_wrap( 816 "return-result-sugar", 817 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 818 let host = &mut host_getter(caller.data_mut()); 819 let r = Host::return_result_sugar(host); 820 Ok((r,)) 821 }, 822 )?; 823 inst.func_wrap( 824 "return-result-sugar2", 825 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 826 let host = &mut host_getter(caller.data_mut()); 827 let r = Host::return_result_sugar2(host); 828 Ok((r,)) 829 }, 830 )?; 831 inst.func_wrap( 832 "return-result-sugar3", 833 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 834 let host = &mut host_getter(caller.data_mut()); 835 let r = Host::return_result_sugar3(host); 836 Ok((r,)) 837 }, 838 )?; 839 inst.func_wrap( 840 "return-result-sugar4", 841 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 842 let host = &mut host_getter(caller.data_mut()); 843 let r = Host::return_result_sugar4(host); 844 Ok((r,)) 845 }, 846 )?; 847 inst.func_wrap( 848 "return-option-sugar", 849 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 850 let host = &mut host_getter(caller.data_mut()); 851 let r = Host::return_option_sugar(host); 852 Ok((r,)) 853 }, 854 )?; 855 inst.func_wrap( 856 "return-option-sugar2", 857 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 858 let host = &mut host_getter(caller.data_mut()); 859 let r = Host::return_option_sugar2(host); 860 Ok((r,)) 861 }, 862 )?; 863 inst.func_wrap( 864 "result-simple", 865 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 866 let host = &mut host_getter(caller.data_mut()); 867 let r = Host::result_simple(host); 868 Ok((r,)) 869 }, 870 )?; 871 inst.func_wrap( 872 "is-clone-arg", 873 move | 874 mut caller: wasmtime::StoreContextMut<'_, T>, 875 (arg0,): (IsClone,)| 876 { 877 let host = &mut host_getter(caller.data_mut()); 878 let r = Host::is_clone_arg(host, arg0); 879 Ok(r) 880 }, 881 )?; 882 inst.func_wrap( 883 "is-clone-return", 884 move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| { 885 let host = &mut host_getter(caller.data_mut()); 886 let r = Host::is_clone_return(host); 887 Ok((r,)) 888 }, 889 )?; 890 Ok(()) 891 } 892 } 893 } 894 } 895 pub mod exports { 896 pub mod foo { 897 pub mod foo { 898 #[allow(clippy::all)] 899 pub mod variants { 900 #[allow(unused_imports)] 901 use wasmtime::component::__internal::Box; 902 #[derive(wasmtime::component::ComponentType)] 903 #[derive(wasmtime::component::Lift)] 904 #[derive(wasmtime::component::Lower)] 905 #[component(enum)] 906 #[derive(Clone, Copy, Eq, PartialEq)] 907 #[repr(u8)] 908 pub enum E1 { 909 #[component(name = "a")] 910 A, 911 } 912 impl core::fmt::Debug for E1 { fmt( &self, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result913 fn fmt( 914 &self, 915 f: &mut core::fmt::Formatter<'_>, 916 ) -> core::fmt::Result { 917 match self { 918 E1::A => f.debug_tuple("E1::A").finish(), 919 } 920 } 921 } 922 const _: () = { 923 assert!(1 == < E1 as wasmtime::component::ComponentType >::SIZE32); 924 assert!(1 == < E1 as wasmtime::component::ComponentType >::ALIGN32); 925 }; 926 #[derive(wasmtime::component::ComponentType)] 927 #[derive(wasmtime::component::Lift)] 928 #[derive(wasmtime::component::Lower)] 929 #[component(record)] 930 #[derive(Clone, Copy)] 931 pub struct Empty {} 932 impl core::fmt::Debug for Empty { fmt( &self, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result933 fn fmt( 934 &self, 935 f: &mut core::fmt::Formatter<'_>, 936 ) -> core::fmt::Result { 937 f.debug_struct("Empty").finish() 938 } 939 } 940 const _: () = { 941 assert!( 942 0 == < Empty as wasmtime::component::ComponentType >::SIZE32 943 ); 944 assert!( 945 1 == < Empty as wasmtime::component::ComponentType >::ALIGN32 946 ); 947 }; 948 #[derive(wasmtime::component::ComponentType)] 949 #[derive(wasmtime::component::Lift)] 950 #[derive(wasmtime::component::Lower)] 951 #[component(variant)] 952 #[derive(Clone)] 953 pub enum V1 { 954 #[component(name = "a")] 955 A, 956 #[component(name = "c")] 957 C(E1), 958 #[component(name = "d")] 959 D(wasmtime::component::__internal::String), 960 #[component(name = "e")] 961 E(Empty), 962 #[component(name = "f")] 963 F, 964 #[component(name = "g")] 965 G(u32), 966 } 967 impl core::fmt::Debug for V1 { fmt( &self, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result968 fn fmt( 969 &self, 970 f: &mut core::fmt::Formatter<'_>, 971 ) -> core::fmt::Result { 972 match self { 973 V1::A => f.debug_tuple("V1::A").finish(), 974 V1::C(e) => f.debug_tuple("V1::C").field(e).finish(), 975 V1::D(e) => f.debug_tuple("V1::D").field(e).finish(), 976 V1::E(e) => f.debug_tuple("V1::E").field(e).finish(), 977 V1::F => f.debug_tuple("V1::F").finish(), 978 V1::G(e) => f.debug_tuple("V1::G").field(e).finish(), 979 } 980 } 981 } 982 const _: () = { 983 assert!(12 == < V1 as wasmtime::component::ComponentType >::SIZE32); 984 assert!(4 == < V1 as wasmtime::component::ComponentType >::ALIGN32); 985 }; 986 #[derive(wasmtime::component::ComponentType)] 987 #[derive(wasmtime::component::Lift)] 988 #[derive(wasmtime::component::Lower)] 989 #[component(variant)] 990 #[derive(Clone, Copy)] 991 pub enum Casts1 { 992 #[component(name = "a")] 993 A(i32), 994 #[component(name = "b")] 995 B(f32), 996 } 997 impl core::fmt::Debug for Casts1 { fmt( &self, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result998 fn fmt( 999 &self, 1000 f: &mut core::fmt::Formatter<'_>, 1001 ) -> core::fmt::Result { 1002 match self { 1003 Casts1::A(e) => f.debug_tuple("Casts1::A").field(e).finish(), 1004 Casts1::B(e) => f.debug_tuple("Casts1::B").field(e).finish(), 1005 } 1006 } 1007 } 1008 const _: () = { 1009 assert!( 1010 8 == < Casts1 as wasmtime::component::ComponentType >::SIZE32 1011 ); 1012 assert!( 1013 4 == < Casts1 as wasmtime::component::ComponentType >::ALIGN32 1014 ); 1015 }; 1016 #[derive(wasmtime::component::ComponentType)] 1017 #[derive(wasmtime::component::Lift)] 1018 #[derive(wasmtime::component::Lower)] 1019 #[component(variant)] 1020 #[derive(Clone, Copy)] 1021 pub enum Casts2 { 1022 #[component(name = "a")] 1023 A(f64), 1024 #[component(name = "b")] 1025 B(f32), 1026 } 1027 impl core::fmt::Debug for Casts2 { fmt( &self, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result1028 fn fmt( 1029 &self, 1030 f: &mut core::fmt::Formatter<'_>, 1031 ) -> core::fmt::Result { 1032 match self { 1033 Casts2::A(e) => f.debug_tuple("Casts2::A").field(e).finish(), 1034 Casts2::B(e) => f.debug_tuple("Casts2::B").field(e).finish(), 1035 } 1036 } 1037 } 1038 const _: () = { 1039 assert!( 1040 16 == < Casts2 as wasmtime::component::ComponentType >::SIZE32 1041 ); 1042 assert!( 1043 8 == < Casts2 as wasmtime::component::ComponentType >::ALIGN32 1044 ); 1045 }; 1046 #[derive(wasmtime::component::ComponentType)] 1047 #[derive(wasmtime::component::Lift)] 1048 #[derive(wasmtime::component::Lower)] 1049 #[component(variant)] 1050 #[derive(Clone, Copy)] 1051 pub enum Casts3 { 1052 #[component(name = "a")] 1053 A(f64), 1054 #[component(name = "b")] 1055 B(u64), 1056 } 1057 impl core::fmt::Debug for Casts3 { fmt( &self, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result1058 fn fmt( 1059 &self, 1060 f: &mut core::fmt::Formatter<'_>, 1061 ) -> core::fmt::Result { 1062 match self { 1063 Casts3::A(e) => f.debug_tuple("Casts3::A").field(e).finish(), 1064 Casts3::B(e) => f.debug_tuple("Casts3::B").field(e).finish(), 1065 } 1066 } 1067 } 1068 const _: () = { 1069 assert!( 1070 16 == < Casts3 as wasmtime::component::ComponentType >::SIZE32 1071 ); 1072 assert!( 1073 8 == < Casts3 as wasmtime::component::ComponentType >::ALIGN32 1074 ); 1075 }; 1076 #[derive(wasmtime::component::ComponentType)] 1077 #[derive(wasmtime::component::Lift)] 1078 #[derive(wasmtime::component::Lower)] 1079 #[component(variant)] 1080 #[derive(Clone, Copy)] 1081 pub enum Casts4 { 1082 #[component(name = "a")] 1083 A(u32), 1084 #[component(name = "b")] 1085 B(i64), 1086 } 1087 impl core::fmt::Debug for Casts4 { fmt( &self, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result1088 fn fmt( 1089 &self, 1090 f: &mut core::fmt::Formatter<'_>, 1091 ) -> core::fmt::Result { 1092 match self { 1093 Casts4::A(e) => f.debug_tuple("Casts4::A").field(e).finish(), 1094 Casts4::B(e) => f.debug_tuple("Casts4::B").field(e).finish(), 1095 } 1096 } 1097 } 1098 const _: () = { 1099 assert!( 1100 16 == < Casts4 as wasmtime::component::ComponentType >::SIZE32 1101 ); 1102 assert!( 1103 8 == < Casts4 as wasmtime::component::ComponentType >::ALIGN32 1104 ); 1105 }; 1106 #[derive(wasmtime::component::ComponentType)] 1107 #[derive(wasmtime::component::Lift)] 1108 #[derive(wasmtime::component::Lower)] 1109 #[component(variant)] 1110 #[derive(Clone, Copy)] 1111 pub enum Casts5 { 1112 #[component(name = "a")] 1113 A(f32), 1114 #[component(name = "b")] 1115 B(i64), 1116 } 1117 impl core::fmt::Debug for Casts5 { fmt( &self, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result1118 fn fmt( 1119 &self, 1120 f: &mut core::fmt::Formatter<'_>, 1121 ) -> core::fmt::Result { 1122 match self { 1123 Casts5::A(e) => f.debug_tuple("Casts5::A").field(e).finish(), 1124 Casts5::B(e) => f.debug_tuple("Casts5::B").field(e).finish(), 1125 } 1126 } 1127 } 1128 const _: () = { 1129 assert!( 1130 16 == < Casts5 as wasmtime::component::ComponentType >::SIZE32 1131 ); 1132 assert!( 1133 8 == < Casts5 as wasmtime::component::ComponentType >::ALIGN32 1134 ); 1135 }; 1136 #[derive(wasmtime::component::ComponentType)] 1137 #[derive(wasmtime::component::Lift)] 1138 #[derive(wasmtime::component::Lower)] 1139 #[component(variant)] 1140 #[derive(Clone, Copy)] 1141 pub enum Casts6 { 1142 #[component(name = "a")] 1143 A((f32, u32)), 1144 #[component(name = "b")] 1145 B((u32, u32)), 1146 } 1147 impl core::fmt::Debug for Casts6 { fmt( &self, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result1148 fn fmt( 1149 &self, 1150 f: &mut core::fmt::Formatter<'_>, 1151 ) -> core::fmt::Result { 1152 match self { 1153 Casts6::A(e) => f.debug_tuple("Casts6::A").field(e).finish(), 1154 Casts6::B(e) => f.debug_tuple("Casts6::B").field(e).finish(), 1155 } 1156 } 1157 } 1158 const _: () = { 1159 assert!( 1160 12 == < Casts6 as wasmtime::component::ComponentType >::SIZE32 1161 ); 1162 assert!( 1163 4 == < Casts6 as wasmtime::component::ComponentType >::ALIGN32 1164 ); 1165 }; 1166 #[derive(wasmtime::component::ComponentType)] 1167 #[derive(wasmtime::component::Lift)] 1168 #[derive(wasmtime::component::Lower)] 1169 #[component(enum)] 1170 #[derive(Clone, Copy, Eq, PartialEq)] 1171 #[repr(u8)] 1172 pub enum MyErrno { 1173 #[component(name = "bad1")] 1174 Bad1, 1175 #[component(name = "bad2")] 1176 Bad2, 1177 } 1178 impl MyErrno { name(&self) -> &'static str1179 pub fn name(&self) -> &'static str { 1180 match self { 1181 MyErrno::Bad1 => "bad1", 1182 MyErrno::Bad2 => "bad2", 1183 } 1184 } message(&self) -> &'static str1185 pub fn message(&self) -> &'static str { 1186 match self { 1187 MyErrno::Bad1 => "", 1188 MyErrno::Bad2 => "", 1189 } 1190 } 1191 } 1192 impl core::fmt::Debug for MyErrno { fmt( &self, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result1193 fn fmt( 1194 &self, 1195 f: &mut core::fmt::Formatter<'_>, 1196 ) -> core::fmt::Result { 1197 f.debug_struct("MyErrno") 1198 .field("code", &(*self as i32)) 1199 .field("name", &self.name()) 1200 .field("message", &self.message()) 1201 .finish() 1202 } 1203 } 1204 impl core::fmt::Display for MyErrno { fmt( &self, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result1205 fn fmt( 1206 &self, 1207 f: &mut core::fmt::Formatter<'_>, 1208 ) -> core::fmt::Result { 1209 write!(f, "{} (error {})", self.name(), * self as i32) 1210 } 1211 } 1212 impl core::error::Error for MyErrno {} 1213 const _: () = { 1214 assert!( 1215 1 == < MyErrno as wasmtime::component::ComponentType >::SIZE32 1216 ); 1217 assert!( 1218 1 == < MyErrno as wasmtime::component::ComponentType >::ALIGN32 1219 ); 1220 }; 1221 #[derive(wasmtime::component::ComponentType)] 1222 #[derive(wasmtime::component::Lift)] 1223 #[derive(wasmtime::component::Lower)] 1224 #[component(record)] 1225 #[derive(Clone)] 1226 pub struct IsClone { 1227 #[component(name = "v1")] 1228 pub v1: V1, 1229 } 1230 impl core::fmt::Debug for IsClone { fmt( &self, f: &mut core::fmt::Formatter<'_>, ) -> core::fmt::Result1231 fn fmt( 1232 &self, 1233 f: &mut core::fmt::Formatter<'_>, 1234 ) -> core::fmt::Result { 1235 f.debug_struct("IsClone").field("v1", &self.v1).finish() 1236 } 1237 } 1238 const _: () = { 1239 assert!( 1240 12 == < IsClone as wasmtime::component::ComponentType >::SIZE32 1241 ); 1242 assert!( 1243 4 == < IsClone as wasmtime::component::ComponentType >::ALIGN32 1244 ); 1245 }; 1246 #[derive(Clone)] 1247 pub struct Guest { 1248 e1_arg: wasmtime::component::Func, 1249 e1_result: wasmtime::component::Func, 1250 v1_arg: wasmtime::component::Func, 1251 v1_result: wasmtime::component::Func, 1252 bool_arg: wasmtime::component::Func, 1253 bool_result: wasmtime::component::Func, 1254 option_arg: wasmtime::component::Func, 1255 option_result: wasmtime::component::Func, 1256 casts: wasmtime::component::Func, 1257 result_arg: wasmtime::component::Func, 1258 result_result: wasmtime::component::Func, 1259 return_result_sugar: wasmtime::component::Func, 1260 return_result_sugar2: wasmtime::component::Func, 1261 return_result_sugar3: wasmtime::component::Func, 1262 return_result_sugar4: wasmtime::component::Func, 1263 return_option_sugar: wasmtime::component::Func, 1264 return_option_sugar2: wasmtime::component::Func, 1265 result_simple: wasmtime::component::Func, 1266 is_clone_arg: wasmtime::component::Func, 1267 is_clone_return: wasmtime::component::Func, 1268 } 1269 #[derive(Clone)] 1270 pub struct GuestIndices { 1271 e1_arg: wasmtime::component::ComponentExportIndex, 1272 e1_result: wasmtime::component::ComponentExportIndex, 1273 v1_arg: wasmtime::component::ComponentExportIndex, 1274 v1_result: wasmtime::component::ComponentExportIndex, 1275 bool_arg: wasmtime::component::ComponentExportIndex, 1276 bool_result: wasmtime::component::ComponentExportIndex, 1277 option_arg: wasmtime::component::ComponentExportIndex, 1278 option_result: wasmtime::component::ComponentExportIndex, 1279 casts: wasmtime::component::ComponentExportIndex, 1280 result_arg: wasmtime::component::ComponentExportIndex, 1281 result_result: wasmtime::component::ComponentExportIndex, 1282 return_result_sugar: wasmtime::component::ComponentExportIndex, 1283 return_result_sugar2: wasmtime::component::ComponentExportIndex, 1284 return_result_sugar3: wasmtime::component::ComponentExportIndex, 1285 return_result_sugar4: wasmtime::component::ComponentExportIndex, 1286 return_option_sugar: wasmtime::component::ComponentExportIndex, 1287 return_option_sugar2: wasmtime::component::ComponentExportIndex, 1288 result_simple: wasmtime::component::ComponentExportIndex, 1289 is_clone_arg: wasmtime::component::ComponentExportIndex, 1290 is_clone_return: wasmtime::component::ComponentExportIndex, 1291 } 1292 impl GuestIndices { 1293 /// Constructor for [`GuestIndices`] which takes a 1294 /// [`Component`](wasmtime::component::Component) as input and can be executed 1295 /// before instantiation. 1296 /// 1297 /// This constructor can be used to front-load string lookups to find exports 1298 /// within a component. new<_T>( _instance_pre: &wasmtime::component::InstancePre<_T>, ) -> wasmtime::Result<GuestIndices>1299 pub fn new<_T>( 1300 _instance_pre: &wasmtime::component::InstancePre<_T>, 1301 ) -> wasmtime::Result<GuestIndices> { 1302 let instance = _instance_pre 1303 .component() 1304 .get_export_index(None, "foo:foo/variants") 1305 .ok_or_else(|| { 1306 wasmtime::format_err!( 1307 "no exported instance named `foo:foo/variants`" 1308 ) 1309 })?; 1310 let mut lookup = move |name| { 1311 _instance_pre 1312 .component() 1313 .get_export_index(Some(&instance), name) 1314 .ok_or_else(|| { 1315 wasmtime::format_err!( 1316 "instance export `foo:foo/variants` does \ 1317 not have export `{name}`" 1318 ) 1319 }) 1320 }; 1321 let _ = &mut lookup; 1322 let e1_arg = lookup("e1-arg")?; 1323 let e1_result = lookup("e1-result")?; 1324 let v1_arg = lookup("v1-arg")?; 1325 let v1_result = lookup("v1-result")?; 1326 let bool_arg = lookup("bool-arg")?; 1327 let bool_result = lookup("bool-result")?; 1328 let option_arg = lookup("option-arg")?; 1329 let option_result = lookup("option-result")?; 1330 let casts = lookup("casts")?; 1331 let result_arg = lookup("result-arg")?; 1332 let result_result = lookup("result-result")?; 1333 let return_result_sugar = lookup("return-result-sugar")?; 1334 let return_result_sugar2 = lookup("return-result-sugar2")?; 1335 let return_result_sugar3 = lookup("return-result-sugar3")?; 1336 let return_result_sugar4 = lookup("return-result-sugar4")?; 1337 let return_option_sugar = lookup("return-option-sugar")?; 1338 let return_option_sugar2 = lookup("return-option-sugar2")?; 1339 let result_simple = lookup("result-simple")?; 1340 let is_clone_arg = lookup("is-clone-arg")?; 1341 let is_clone_return = lookup("is-clone-return")?; 1342 Ok(GuestIndices { 1343 e1_arg, 1344 e1_result, 1345 v1_arg, 1346 v1_result, 1347 bool_arg, 1348 bool_result, 1349 option_arg, 1350 option_result, 1351 casts, 1352 result_arg, 1353 result_result, 1354 return_result_sugar, 1355 return_result_sugar2, 1356 return_result_sugar3, 1357 return_result_sugar4, 1358 return_option_sugar, 1359 return_option_sugar2, 1360 result_simple, 1361 is_clone_arg, 1362 is_clone_return, 1363 }) 1364 } load( &self, mut store: impl wasmtime::AsContextMut, instance: &wasmtime::component::Instance, ) -> wasmtime::Result<Guest>1365 pub fn load( 1366 &self, 1367 mut store: impl wasmtime::AsContextMut, 1368 instance: &wasmtime::component::Instance, 1369 ) -> wasmtime::Result<Guest> { 1370 let _instance = instance; 1371 let _instance_pre = _instance.instance_pre(&store); 1372 let _instance_type = _instance_pre.instance_type(); 1373 let mut store = store.as_context_mut(); 1374 let _ = &mut store; 1375 let e1_arg = *_instance 1376 .get_typed_func::<(E1,), ()>(&mut store, &self.e1_arg)? 1377 .func(); 1378 let e1_result = *_instance 1379 .get_typed_func::<(), (E1,)>(&mut store, &self.e1_result)? 1380 .func(); 1381 let v1_arg = *_instance 1382 .get_typed_func::<(&V1,), ()>(&mut store, &self.v1_arg)? 1383 .func(); 1384 let v1_result = *_instance 1385 .get_typed_func::<(), (V1,)>(&mut store, &self.v1_result)? 1386 .func(); 1387 let bool_arg = *_instance 1388 .get_typed_func::<(bool,), ()>(&mut store, &self.bool_arg)? 1389 .func(); 1390 let bool_result = *_instance 1391 .get_typed_func::< 1392 (), 1393 (bool,), 1394 >(&mut store, &self.bool_result)? 1395 .func(); 1396 let option_arg = *_instance 1397 .get_typed_func::< 1398 ( 1399 Option<bool>, 1400 Option<()>, 1401 Option<u32>, 1402 Option<E1>, 1403 Option<f32>, 1404 Option<Option<bool>>, 1405 ), 1406 (), 1407 >(&mut store, &self.option_arg)? 1408 .func(); 1409 let option_result = *_instance 1410 .get_typed_func::< 1411 (), 1412 ( 1413 ( 1414 Option<bool>, 1415 Option<()>, 1416 Option<u32>, 1417 Option<E1>, 1418 Option<f32>, 1419 Option<Option<bool>>, 1420 ), 1421 ), 1422 >(&mut store, &self.option_result)? 1423 .func(); 1424 let casts = *_instance 1425 .get_typed_func::< 1426 (Casts1, Casts2, Casts3, Casts4, Casts5, Casts6), 1427 ((Casts1, Casts2, Casts3, Casts4, Casts5, Casts6),), 1428 >(&mut store, &self.casts)? 1429 .func(); 1430 let result_arg = *_instance 1431 .get_typed_func::< 1432 ( 1433 Result<(), ()>, 1434 Result<(), E1>, 1435 Result<E1, ()>, 1436 Result<(), ()>, 1437 Result<u32, &V1>, 1438 Result<&str, &[u8]>, 1439 ), 1440 (), 1441 >(&mut store, &self.result_arg)? 1442 .func(); 1443 let result_result = *_instance 1444 .get_typed_func::< 1445 (), 1446 ( 1447 ( 1448 Result<(), ()>, 1449 Result<(), E1>, 1450 Result<E1, ()>, 1451 Result<(), ()>, 1452 Result<u32, V1>, 1453 Result< 1454 wasmtime::component::__internal::String, 1455 wasmtime::component::__internal::Vec<u8>, 1456 >, 1457 ), 1458 ), 1459 >(&mut store, &self.result_result)? 1460 .func(); 1461 let return_result_sugar = *_instance 1462 .get_typed_func::< 1463 (), 1464 (Result<i32, MyErrno>,), 1465 >(&mut store, &self.return_result_sugar)? 1466 .func(); 1467 let return_result_sugar2 = *_instance 1468 .get_typed_func::< 1469 (), 1470 (Result<(), MyErrno>,), 1471 >(&mut store, &self.return_result_sugar2)? 1472 .func(); 1473 let return_result_sugar3 = *_instance 1474 .get_typed_func::< 1475 (), 1476 (Result<MyErrno, MyErrno>,), 1477 >(&mut store, &self.return_result_sugar3)? 1478 .func(); 1479 let return_result_sugar4 = *_instance 1480 .get_typed_func::< 1481 (), 1482 (Result<(i32, u32), MyErrno>,), 1483 >(&mut store, &self.return_result_sugar4)? 1484 .func(); 1485 let return_option_sugar = *_instance 1486 .get_typed_func::< 1487 (), 1488 (Option<i32>,), 1489 >(&mut store, &self.return_option_sugar)? 1490 .func(); 1491 let return_option_sugar2 = *_instance 1492 .get_typed_func::< 1493 (), 1494 (Option<MyErrno>,), 1495 >(&mut store, &self.return_option_sugar2)? 1496 .func(); 1497 let result_simple = *_instance 1498 .get_typed_func::< 1499 (), 1500 (Result<u32, i32>,), 1501 >(&mut store, &self.result_simple)? 1502 .func(); 1503 let is_clone_arg = *_instance 1504 .get_typed_func::< 1505 (&IsClone,), 1506 (), 1507 >(&mut store, &self.is_clone_arg)? 1508 .func(); 1509 let is_clone_return = *_instance 1510 .get_typed_func::< 1511 (), 1512 (IsClone,), 1513 >(&mut store, &self.is_clone_return)? 1514 .func(); 1515 Ok(Guest { 1516 e1_arg, 1517 e1_result, 1518 v1_arg, 1519 v1_result, 1520 bool_arg, 1521 bool_result, 1522 option_arg, 1523 option_result, 1524 casts, 1525 result_arg, 1526 result_result, 1527 return_result_sugar, 1528 return_result_sugar2, 1529 return_result_sugar3, 1530 return_result_sugar4, 1531 return_option_sugar, 1532 return_option_sugar2, 1533 result_simple, 1534 is_clone_arg, 1535 is_clone_return, 1536 }) 1537 } 1538 } 1539 impl Guest { call_e1_arg<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: E1, ) -> wasmtime::Result<()>1540 pub fn call_e1_arg<S: wasmtime::AsContextMut>( 1541 &self, 1542 mut store: S, 1543 arg0: E1, 1544 ) -> wasmtime::Result<()> { 1545 let callee = unsafe { 1546 wasmtime::component::TypedFunc::< 1547 (E1,), 1548 (), 1549 >::new_unchecked(self.e1_arg) 1550 }; 1551 let () = callee.call(store.as_context_mut(), (arg0,))?; 1552 Ok(()) 1553 } call_e1_result<S: wasmtime::AsContextMut>( &self, mut store: S, ) -> wasmtime::Result<E1>1554 pub fn call_e1_result<S: wasmtime::AsContextMut>( 1555 &self, 1556 mut store: S, 1557 ) -> wasmtime::Result<E1> { 1558 let callee = unsafe { 1559 wasmtime::component::TypedFunc::< 1560 (), 1561 (E1,), 1562 >::new_unchecked(self.e1_result) 1563 }; 1564 let (ret0,) = callee.call(store.as_context_mut(), ())?; 1565 Ok(ret0) 1566 } call_v1_arg<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: &V1, ) -> wasmtime::Result<()>1567 pub fn call_v1_arg<S: wasmtime::AsContextMut>( 1568 &self, 1569 mut store: S, 1570 arg0: &V1, 1571 ) -> wasmtime::Result<()> { 1572 let callee = unsafe { 1573 wasmtime::component::TypedFunc::< 1574 (&V1,), 1575 (), 1576 >::new_unchecked(self.v1_arg) 1577 }; 1578 let () = callee.call(store.as_context_mut(), (arg0,))?; 1579 Ok(()) 1580 } call_v1_result<S: wasmtime::AsContextMut>( &self, mut store: S, ) -> wasmtime::Result<V1>1581 pub fn call_v1_result<S: wasmtime::AsContextMut>( 1582 &self, 1583 mut store: S, 1584 ) -> wasmtime::Result<V1> { 1585 let callee = unsafe { 1586 wasmtime::component::TypedFunc::< 1587 (), 1588 (V1,), 1589 >::new_unchecked(self.v1_result) 1590 }; 1591 let (ret0,) = callee.call(store.as_context_mut(), ())?; 1592 Ok(ret0) 1593 } call_bool_arg<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: bool, ) -> wasmtime::Result<()>1594 pub fn call_bool_arg<S: wasmtime::AsContextMut>( 1595 &self, 1596 mut store: S, 1597 arg0: bool, 1598 ) -> wasmtime::Result<()> { 1599 let callee = unsafe { 1600 wasmtime::component::TypedFunc::< 1601 (bool,), 1602 (), 1603 >::new_unchecked(self.bool_arg) 1604 }; 1605 let () = callee.call(store.as_context_mut(), (arg0,))?; 1606 Ok(()) 1607 } call_bool_result<S: wasmtime::AsContextMut>( &self, mut store: S, ) -> wasmtime::Result<bool>1608 pub fn call_bool_result<S: wasmtime::AsContextMut>( 1609 &self, 1610 mut store: S, 1611 ) -> wasmtime::Result<bool> { 1612 let callee = unsafe { 1613 wasmtime::component::TypedFunc::< 1614 (), 1615 (bool,), 1616 >::new_unchecked(self.bool_result) 1617 }; 1618 let (ret0,) = callee.call(store.as_context_mut(), ())?; 1619 Ok(ret0) 1620 } call_option_arg<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: Option<bool>, arg1: Option<()>, arg2: Option<u32>, arg3: Option<E1>, arg4: Option<f32>, arg5: Option<Option<bool>>, ) -> wasmtime::Result<()>1621 pub fn call_option_arg<S: wasmtime::AsContextMut>( 1622 &self, 1623 mut store: S, 1624 arg0: Option<bool>, 1625 arg1: Option<()>, 1626 arg2: Option<u32>, 1627 arg3: Option<E1>, 1628 arg4: Option<f32>, 1629 arg5: Option<Option<bool>>, 1630 ) -> wasmtime::Result<()> { 1631 let callee = unsafe { 1632 wasmtime::component::TypedFunc::< 1633 ( 1634 Option<bool>, 1635 Option<()>, 1636 Option<u32>, 1637 Option<E1>, 1638 Option<f32>, 1639 Option<Option<bool>>, 1640 ), 1641 (), 1642 >::new_unchecked(self.option_arg) 1643 }; 1644 let () = callee 1645 .call( 1646 store.as_context_mut(), 1647 (arg0, arg1, arg2, arg3, arg4, arg5), 1648 )?; 1649 Ok(()) 1650 } call_option_result<S: wasmtime::AsContextMut>( &self, mut store: S, ) -> wasmtime::Result< ( Option<bool>, Option<()>, Option<u32>, Option<E1>, Option<f32>, Option<Option<bool>>, ), >1651 pub fn call_option_result<S: wasmtime::AsContextMut>( 1652 &self, 1653 mut store: S, 1654 ) -> wasmtime::Result< 1655 ( 1656 Option<bool>, 1657 Option<()>, 1658 Option<u32>, 1659 Option<E1>, 1660 Option<f32>, 1661 Option<Option<bool>>, 1662 ), 1663 > { 1664 let callee = unsafe { 1665 wasmtime::component::TypedFunc::< 1666 (), 1667 ( 1668 ( 1669 Option<bool>, 1670 Option<()>, 1671 Option<u32>, 1672 Option<E1>, 1673 Option<f32>, 1674 Option<Option<bool>>, 1675 ), 1676 ), 1677 >::new_unchecked(self.option_result) 1678 }; 1679 let (ret0,) = callee.call(store.as_context_mut(), ())?; 1680 Ok(ret0) 1681 } call_casts<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: Casts1, arg1: Casts2, arg2: Casts3, arg3: Casts4, arg4: Casts5, arg5: Casts6, ) -> wasmtime::Result< (Casts1, Casts2, Casts3, Casts4, Casts5, Casts6), >1682 pub fn call_casts<S: wasmtime::AsContextMut>( 1683 &self, 1684 mut store: S, 1685 arg0: Casts1, 1686 arg1: Casts2, 1687 arg2: Casts3, 1688 arg3: Casts4, 1689 arg4: Casts5, 1690 arg5: Casts6, 1691 ) -> wasmtime::Result< 1692 (Casts1, Casts2, Casts3, Casts4, Casts5, Casts6), 1693 > { 1694 let callee = unsafe { 1695 wasmtime::component::TypedFunc::< 1696 (Casts1, Casts2, Casts3, Casts4, Casts5, Casts6), 1697 ((Casts1, Casts2, Casts3, Casts4, Casts5, Casts6),), 1698 >::new_unchecked(self.casts) 1699 }; 1700 let (ret0,) = callee 1701 .call( 1702 store.as_context_mut(), 1703 (arg0, arg1, arg2, arg3, arg4, arg5), 1704 )?; 1705 Ok(ret0) 1706 } call_result_arg<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: Result<(), ()>, arg1: Result<(), E1>, arg2: Result<E1, ()>, arg3: Result<(), ()>, arg4: Result<u32, &V1>, arg5: Result<&str, &[u8]>, ) -> wasmtime::Result<()>1707 pub fn call_result_arg<S: wasmtime::AsContextMut>( 1708 &self, 1709 mut store: S, 1710 arg0: Result<(), ()>, 1711 arg1: Result<(), E1>, 1712 arg2: Result<E1, ()>, 1713 arg3: Result<(), ()>, 1714 arg4: Result<u32, &V1>, 1715 arg5: Result<&str, &[u8]>, 1716 ) -> wasmtime::Result<()> { 1717 let callee = unsafe { 1718 wasmtime::component::TypedFunc::< 1719 ( 1720 Result<(), ()>, 1721 Result<(), E1>, 1722 Result<E1, ()>, 1723 Result<(), ()>, 1724 Result<u32, &V1>, 1725 Result<&str, &[u8]>, 1726 ), 1727 (), 1728 >::new_unchecked(self.result_arg) 1729 }; 1730 let () = callee 1731 .call( 1732 store.as_context_mut(), 1733 (arg0, arg1, arg2, arg3, arg4, arg5), 1734 )?; 1735 Ok(()) 1736 } call_result_result<S: wasmtime::AsContextMut>( &self, mut store: S, ) -> wasmtime::Result< ( Result<(), ()>, Result<(), E1>, Result<E1, ()>, Result<(), ()>, Result<u32, V1>, Result< wasmtime::component::__internal::String, wasmtime::component::__internal::Vec<u8>, >, ), >1737 pub fn call_result_result<S: wasmtime::AsContextMut>( 1738 &self, 1739 mut store: S, 1740 ) -> wasmtime::Result< 1741 ( 1742 Result<(), ()>, 1743 Result<(), E1>, 1744 Result<E1, ()>, 1745 Result<(), ()>, 1746 Result<u32, V1>, 1747 Result< 1748 wasmtime::component::__internal::String, 1749 wasmtime::component::__internal::Vec<u8>, 1750 >, 1751 ), 1752 > { 1753 let callee = unsafe { 1754 wasmtime::component::TypedFunc::< 1755 (), 1756 ( 1757 ( 1758 Result<(), ()>, 1759 Result<(), E1>, 1760 Result<E1, ()>, 1761 Result<(), ()>, 1762 Result<u32, V1>, 1763 Result< 1764 wasmtime::component::__internal::String, 1765 wasmtime::component::__internal::Vec<u8>, 1766 >, 1767 ), 1768 ), 1769 >::new_unchecked(self.result_result) 1770 }; 1771 let (ret0,) = callee.call(store.as_context_mut(), ())?; 1772 Ok(ret0) 1773 } call_return_result_sugar<S: wasmtime::AsContextMut>( &self, mut store: S, ) -> wasmtime::Result<Result<i32, MyErrno>>1774 pub fn call_return_result_sugar<S: wasmtime::AsContextMut>( 1775 &self, 1776 mut store: S, 1777 ) -> wasmtime::Result<Result<i32, MyErrno>> { 1778 let callee = unsafe { 1779 wasmtime::component::TypedFunc::< 1780 (), 1781 (Result<i32, MyErrno>,), 1782 >::new_unchecked(self.return_result_sugar) 1783 }; 1784 let (ret0,) = callee.call(store.as_context_mut(), ())?; 1785 Ok(ret0) 1786 } call_return_result_sugar2<S: wasmtime::AsContextMut>( &self, mut store: S, ) -> wasmtime::Result<Result<(), MyErrno>>1787 pub fn call_return_result_sugar2<S: wasmtime::AsContextMut>( 1788 &self, 1789 mut store: S, 1790 ) -> wasmtime::Result<Result<(), MyErrno>> { 1791 let callee = unsafe { 1792 wasmtime::component::TypedFunc::< 1793 (), 1794 (Result<(), MyErrno>,), 1795 >::new_unchecked(self.return_result_sugar2) 1796 }; 1797 let (ret0,) = callee.call(store.as_context_mut(), ())?; 1798 Ok(ret0) 1799 } call_return_result_sugar3<S: wasmtime::AsContextMut>( &self, mut store: S, ) -> wasmtime::Result<Result<MyErrno, MyErrno>>1800 pub fn call_return_result_sugar3<S: wasmtime::AsContextMut>( 1801 &self, 1802 mut store: S, 1803 ) -> wasmtime::Result<Result<MyErrno, MyErrno>> { 1804 let callee = unsafe { 1805 wasmtime::component::TypedFunc::< 1806 (), 1807 (Result<MyErrno, MyErrno>,), 1808 >::new_unchecked(self.return_result_sugar3) 1809 }; 1810 let (ret0,) = callee.call(store.as_context_mut(), ())?; 1811 Ok(ret0) 1812 } call_return_result_sugar4<S: wasmtime::AsContextMut>( &self, mut store: S, ) -> wasmtime::Result<Result<(i32, u32), MyErrno>>1813 pub fn call_return_result_sugar4<S: wasmtime::AsContextMut>( 1814 &self, 1815 mut store: S, 1816 ) -> wasmtime::Result<Result<(i32, u32), MyErrno>> { 1817 let callee = unsafe { 1818 wasmtime::component::TypedFunc::< 1819 (), 1820 (Result<(i32, u32), MyErrno>,), 1821 >::new_unchecked(self.return_result_sugar4) 1822 }; 1823 let (ret0,) = callee.call(store.as_context_mut(), ())?; 1824 Ok(ret0) 1825 } call_return_option_sugar<S: wasmtime::AsContextMut>( &self, mut store: S, ) -> wasmtime::Result<Option<i32>>1826 pub fn call_return_option_sugar<S: wasmtime::AsContextMut>( 1827 &self, 1828 mut store: S, 1829 ) -> wasmtime::Result<Option<i32>> { 1830 let callee = unsafe { 1831 wasmtime::component::TypedFunc::< 1832 (), 1833 (Option<i32>,), 1834 >::new_unchecked(self.return_option_sugar) 1835 }; 1836 let (ret0,) = callee.call(store.as_context_mut(), ())?; 1837 Ok(ret0) 1838 } call_return_option_sugar2<S: wasmtime::AsContextMut>( &self, mut store: S, ) -> wasmtime::Result<Option<MyErrno>>1839 pub fn call_return_option_sugar2<S: wasmtime::AsContextMut>( 1840 &self, 1841 mut store: S, 1842 ) -> wasmtime::Result<Option<MyErrno>> { 1843 let callee = unsafe { 1844 wasmtime::component::TypedFunc::< 1845 (), 1846 (Option<MyErrno>,), 1847 >::new_unchecked(self.return_option_sugar2) 1848 }; 1849 let (ret0,) = callee.call(store.as_context_mut(), ())?; 1850 Ok(ret0) 1851 } call_result_simple<S: wasmtime::AsContextMut>( &self, mut store: S, ) -> wasmtime::Result<Result<u32, i32>>1852 pub fn call_result_simple<S: wasmtime::AsContextMut>( 1853 &self, 1854 mut store: S, 1855 ) -> wasmtime::Result<Result<u32, i32>> { 1856 let callee = unsafe { 1857 wasmtime::component::TypedFunc::< 1858 (), 1859 (Result<u32, i32>,), 1860 >::new_unchecked(self.result_simple) 1861 }; 1862 let (ret0,) = callee.call(store.as_context_mut(), ())?; 1863 Ok(ret0) 1864 } call_is_clone_arg<S: wasmtime::AsContextMut>( &self, mut store: S, arg0: &IsClone, ) -> wasmtime::Result<()>1865 pub fn call_is_clone_arg<S: wasmtime::AsContextMut>( 1866 &self, 1867 mut store: S, 1868 arg0: &IsClone, 1869 ) -> wasmtime::Result<()> { 1870 let callee = unsafe { 1871 wasmtime::component::TypedFunc::< 1872 (&IsClone,), 1873 (), 1874 >::new_unchecked(self.is_clone_arg) 1875 }; 1876 let () = callee.call(store.as_context_mut(), (arg0,))?; 1877 Ok(()) 1878 } call_is_clone_return<S: wasmtime::AsContextMut>( &self, mut store: S, ) -> wasmtime::Result<IsClone>1879 pub fn call_is_clone_return<S: wasmtime::AsContextMut>( 1880 &self, 1881 mut store: S, 1882 ) -> wasmtime::Result<IsClone> { 1883 let callee = unsafe { 1884 wasmtime::component::TypedFunc::< 1885 (), 1886 (IsClone,), 1887 >::new_unchecked(self.is_clone_return) 1888 }; 1889 let (ret0,) = callee.call(store.as_context_mut(), ())?; 1890 Ok(ret0) 1891 } 1892 } 1893 } 1894 } 1895 } 1896 } 1897