wit_bindgen/examples/
_1_interface_imports.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
crate::generate!({
    inline: r#"
        package example:interface-imports;

        interface logging {
            enum level {
                debug,
                info,
                warn,
                error,
            }

            log: func(level: level, msg: string);
        }

        world with-imports {
            // Local interfaces can be imported.
            import logging;

            // Dependencies can also be referenced, and they're loaded from the
            // `path` directive specified below.
            import wasi:cli/environment@0.2.0;
        }
    "#,

    path: "wasi-cli@0.2.0.wasm",

    // specify that this interface dependency should be generated as well.
    with: {
        "wasi:cli/environment@0.2.0": generate,
    }
});