1 bindgen!({
2     inline: r#"
3         package example:imported-resources;
4 
5         interface logging {
6             enum level {
7                 debug,
8                 info,
9                 warn,
10                 error,
11             }
12 
13             resource logger {
14                 constructor(max-level: level);
15 
16                 get-max-level: func() -> level;
17                 set-max-level: func(level: level);
18 
19                 log: func(level: level, msg: string);
20             }
21         }
22 
23         world import-some-resources {
24             import logging;
25         }
26     "#,
27 
28     // NEW: Make all imports/exports `async` by default, and additionally
29     // interactions with `ResourceTable` can possibly trap so enable the ability
30     // to return traps from generated functions with `trappable`.
31     imports: { default: async | trappable },
32     exports: { default: async },
33 
34     with: {
35         // Specify that our host resource is going to point to the `MyLogger`
36         // which is defined just below this macro.
37         "example:imported-resources/logging.logger": MyLogger,
38     },
39 });
40 
41 /// A sample host-defined type which contains arbitrary host-defined data.
42 ///
43 /// In this case this is relatively simple but there's no restrictions on what
44 /// this type can hold other than that it must be `'static + Send`.
45 pub struct MyLogger {
46     pub max_level: example::imported_resources::logging::Level,
47 }
48