Skip to main content

dispatch

Function dispatch 

Source
pub unsafe fn dispatch<F, E>(
    src_ptr: *const u8,
    src_len: u32,
    cfg_ptr: *const u8,
    cfg_len: u32,
    handler: F,
) -> *const u32
where F: FnOnce(&str, &str) -> Result<String, E>, E: Display,
Expand description

Run handler over two byte spans from the host and publish the result.

The function returns a pointer to [out_ptr, out_len, ok]. When the handler fails, or when a span is not UTF-8, ok is 0 and the payload is the message.

ยงSafety

Both (ptr, len) pairs must describe spans that this module allocated and that the host filled in.