pub fn rust_call<F, R>(out_status: &mut RustCallStatus, callback: F) -> RExpand description
Reexport items from other uniffi creates Handle a scaffolding calls
callback is responsible for making the actual Rust call and returning a special result type:
- For successfull calls, return
Ok(value) - For errors that should be translated into thrown exceptions in the foreign code, serialize
the error into a
RustBuffer, then returnOk(buf) - The success type, must implement
FfiDefault. Return::lower_returnreturnsResult<>types that meet the above criteria>- If the function returns a
Okvalue it will be unwrapped and returned - If the function returns a
Errvalue:out_status.codewill be set to RustCallStatusCode::Error.out_status.error_bufwill be set to a newly allocatedRustBuffercontaining the error. The calling code is responsible for freeing theRustBufferFfiDefault::ffi_default()is returned, although foreign code should ignore this value
- If the function panics:
out_status.codewill be set toCALL_PANICout_status.error_bufwill be set to a newly allocatedRustBuffercontaining a serialized error message. The calling code is responsible for freeing theRustBufferFfiDefault::ffi_default()is returned, although foreign code should ignore this value