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