Skip to main content

declare_inbound_reply

Macro declare_inbound_reply 

Source
macro_rules! declare_inbound_reply {
    ($name:ident, $handler:path) => { ... };
    ($handler:path) => { ... };
}
Expand description

Generate the optional code_module_inbound_reply export, which is how a module hears what the program answered to something it pushed.

Takes the function to hand it to — fn(particle: &CodeValue, result: &CodeValue). result is a CODE_NULL value when no handler matched; both references are the host’s and are only valid for the duration of the call, so read what you need and copy it out.

fn answered(particle: &CodeValue, result: &CodeValue) { /* ... */ }
code_native::declare_inbound_reply!(answered);

A macro rather than a plain function for the same reason as declare_inbound!: a #[no_mangle] symbol defined in a dependency is not reliably kept in the final cdylib.