1*799534a9SNick Fitzgerald use wasmtime::Result;
2804060c8SJoel Dice use wasmtime::component::Resource;
3804060c8SJoel Dice 
4804060c8SJoel Dice use super::Ctx;
5804060c8SJoel Dice 
6804060c8SJoel Dice pub mod bindings {
7804060c8SJoel Dice     wasmtime::component::bindgen!({
8804060c8SJoel Dice         path: "wit",
9804060c8SJoel Dice         world: "borrowing-host",
101155d6dfSAlex Crichton         imports: { default: trappable },
11804060c8SJoel Dice         with: {
128c03849bSDan Gohman             "local:local/borrowing-types.x": super::MyX,
13804060c8SJoel Dice         }
14804060c8SJoel Dice     });
15804060c8SJoel Dice }
16804060c8SJoel Dice 
178c03849bSDan Gohman /// Used as the borrowing type (`local:local/borrowing-types.x`)
18804060c8SJoel Dice pub struct MyX;
19804060c8SJoel Dice 
20804060c8SJoel Dice impl bindings::local::local::borrowing_types::HostX for &mut Ctx {
new(&mut self) -> Result<Resource<MyX>>21804060c8SJoel Dice     fn new(&mut self) -> Result<Resource<MyX>> {
220a074afcSAlex Crichton         Ok(self.table.push(MyX)?)
23804060c8SJoel Dice     }
24804060c8SJoel Dice 
foo(&mut self, x: Resource<MyX>) -> Result<()>25804060c8SJoel Dice     fn foo(&mut self, x: Resource<MyX>) -> Result<()> {
260a074afcSAlex Crichton         _ = self.table.get(&x)?;
27804060c8SJoel Dice         Ok(())
28804060c8SJoel Dice     }
29804060c8SJoel Dice 
drop(&mut self, x: Resource<MyX>) -> Result<()>30804060c8SJoel Dice     fn drop(&mut self, x: Resource<MyX>) -> Result<()> {
310a074afcSAlex Crichton         self.table.delete(x)?;
32804060c8SJoel Dice         Ok(())
33804060c8SJoel Dice     }
34804060c8SJoel Dice }
35804060c8SJoel Dice 
36804060c8SJoel Dice impl bindings::local::local::borrowing_types::Host for &mut Ctx {}
37