Macro interoptopus::callback [−][src]
macro_rules! callback { ($name : ident($($param : ident : $ty : ty), *) $(-> $rval : ty) ?) => { ... }; }
Expand description
Defines a callback type, akin to a fn f(T) -> R
wrapped in an Option.
A named delegate will be emitted in languages supporting them, otherwise a regular function pointer. For details, please see the callbacks module.
Example
This defines a type MyCallback
with a parameter slice
returning an u8
.
use interoptopus::callback; use interoptopus::patterns::slice::FFISlice; callback!(MyCallback(slice: FFISlice<u8>) -> u8);
The generated type definition similar to:
#[repr(transparent)] pub struct MyCallback(Option<extern "C" fn(FFISlice<u8>) -> u8>);