Expand description
FFI utilities.
Re-exports§
pub use self::result::FfiResult;
pub use self::result::NativeResult;
pub use self::result::FFI_RESULT_OK;
pub use self::string::StringError;
Modules§
- bindgen_
utils - Utilities for binding generators.
- callback
- Helpers to work with extern “C” callbacks.
- result
- Utilities for handling results and errors across the FFI boundary.
- string
- Utilities for passing strings across FFI boundaries.
- test_
utils - Test utilities.
Macros§
- call_
result_ cb - Convert a result into an
FfiResult
and call a callback. - ffi_
error - Convert an error into a pair of
(error_code: i32, description: String)
to be used inNativeResult
. - ffi_
error_ code - Convert an error into an
i32
error code. - ffi_
result - Convert a result into a pair of
(error_code: i32, description: String)
to be used inNativeResult
. - ffi_
result_ code - Convert a result into an
i32
error code. - try_cb
- Given a result, calls the callback if it is an error, otherwise produces the wrapped value.
Should be called within
catch_unwind
, so returnsNone
on error.
Structs§
- Opaque
Ctx - Type that holds opaque user data handed into FFI functions.
Traits§
- Error
Code - Trait for types that can be converted to integer error code.
- ReprC
- Trait to convert between FFI and Rust representations of types.
- SafePtr
- Provides FFI-safe pointers, as opposed to raw
as_ptr()
inVec
andString
which can return values such as0x01
that can cause segmentation faults with the automatic pointer dereferencing on the front-end side (e.g. in Node.js).
Functions§
- base64_
decode - Decode base64 encoded data.
- base64_
encode - Encode the data using base64 encoding.
- catch_
unwind_ cb - Catch panics. On error call the callback.
- catch_
unwind_ result - Catches panics and returns the result.
- vec_
clone_ ⚠from_ raw_ parts - Converts a pointer and length to
Vec
by cloning the contents. Note: This does NOT free the memory pointed to byptr
. - vec_
from_ ⚠raw_ parts - Retakes ownership of a
Vec
that was transferred to C viavec_into_raw_parts
. - vec_
into_ raw_ parts - Consumes a
Vec
and transfers ownership of the data to a C caller, returning (pointer, size).