Debian Codegraph @

.cargo/vendor/wit-bindgen/src/examples/_3_world_exports.rs

raw
1 crate::generate!({
2 inline: r#"
3 package example:world-exports;
4
5 world with-exports {
6 import log: func(msg: string);
7
8 export run: func();
9
10 /// An example of exporting an interface inline naming it directly.
11 export environment: interface {
12 get: func(var: string) -> string;
13 set: func(var: string, val: string);
14 }
15
16 /// An example of exporting an interface defined in this file.
17 export units;
18
19 /// An example of exporting an interface defined in a dependency.
20 export wasi:random/[email protected];
21 }
22
23 interface units {
24 use wasi:clocks/[email protected].{duration};
25
26 /// Renders the number of bytes as a human readable string.
27 bytes-to-string: func(bytes: u64) -> string;
28
29 /// Renders the provided duration as a human readable string.
30 duration-to-string: func(dur: duration) -> string;
31 }
32 "#,
33
34 // provided here to get the export macro rendered in documentation, not
35 // required for external use.
36 pub_export_macro: true,
37
38 // provided to specify the path to `wasi:*` dependencies referenced above.
39 path: "[email protected]",
40
41 // specify that these interface dependencies should be generated as well.
42 with: {
43 "wasi:random/[email protected]": generate,
44 "wasi:clocks/[email protected]": generate,
45 "wasi:io/[email protected]": generate
46 }
47 });