wit_bindgen::examples

Module _4_exported_resources

Source
Expand description

An example of exporting resources from a world and the traits that they generate.

The code used to generate this module is:

crate::generate!({
    inline: r#"
        package example:exported-resources;

        world import-some-resources {
            export logging;
        }

        interface logging {
            enum level {
                debug,
                info,
                warn,
                error,
            }
            resource logger {
                constructor(max-level: level);

                get-max-level: func() -> level;
                set-max-level: func(level: level);

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

Modulesยง