export

Macro export 

Source
macro_rules! export {
    ($ty:ident) => { ... };
    ($ty:ident with_types_in $($path_to_types_root:tt)*) => { ... };
}
Expand description

Generate an exported instance of the wasi:http/proxy world.

This macro will generate #[no_mangle] functions as necessary to export an implementation of the exports::http::incoming_handler::Guest trait. This macro takes an argument which is a type that implements this trait:

use wasip2::http::types::{IncomingRequest, ResponseOutparam};

struct MyIncomingHandler;

impl wasip2::exports::http::incoming_handler::Guest for MyIncomingHandler {
    fn handle(request: IncomingRequest, response_out: ResponseOutparam) {
        // ...
    }
}

wasip2::http::proxy::export!(MyIncomingHandler);

Generates #[unsafe(no_mangle)] functions to export the specified type as the root implementation of all generated traits.

For more information see the documentation of wit_bindgen::generate!.

struct MyType;

impl Guest for MyType {
    // ...
}

_export_proxy!(MyType);