pub type ForeignCallback = unsafe extern "C" fn(_: u64, _: u32, _: *const u8, _: i32, _: *mut RustBuffer) -> i32;
Expand description
Reexport items from other uniffi creates ForeignCallback is the Rust representation of a foreign language function. It is the basis for all callbacks interfaces. It is registered exactly once per callback interface, at library start up time. Calling this method is only done by generated objects which mirror callback interfaces objects in the foreign language.
- The
handle
is the key into a handle map on the other side of the FFI used to look up the foreign language object that implements the callback interface/trait. - The
method
selector specifies the method that will be called on the object, by looking it up in a list of methods from the IDL. The list is 1 indexed. Note that the list of methods is generated by UniFFI from the IDL and used in all bindings, so we can rely on the method list being stable within the same run of UniFFI. args_data
andargs_len
represents a serialized buffer of arguments to the function. The scaffolding code writes the callback arguments to this buffer, in order, usingFfiConverter.write()
. The bindings code reads the arguments from the buffer and passes them to the user’s callback.buf_ptr
is a pointer to where the resulting buffer will be written. UniFFI will allocate a buffer to write the result into.- Callbacks return one of the
CallbackResult
values Note: The output buffer might still contain 0 bytes of data.