Expand description
C ABI runtime: error struct, memory helpers, and utility functions.
Re-exports§
pub use convert::lift_byte_slice;pub use convert::lift_bytes;pub use convert::lift_opt_scalar;pub use convert::lift_opt_string;pub use convert::lift_ptr_vec;pub use convert::lift_scalar_vec;pub use convert::lift_string_vec;pub use convert::lower_bytes;pub use convert::lower_opt_scalar;pub use convert::lower_opt_string;pub use convert::lower_ptr_vec;pub use convert::lower_scalar_vec;pub use convert::lower_string_vec;pub use convert::write_map_out;
Modules§
- arena
- Batch handle management via an arena that tracks pointers and their destructors.
- convert
- Marshalling helpers that bridge owned Rust values and the C ABI slots.
Macros§
- export_
runtime - Emit
#[no_mangle] extern "C"thunks for every runtime symbol that the WeaveFFI generators expect to find in the consuming cdylib.
Structs§
- Cancel
Token - A safe,
Sendview of a foreignweaveffi_cancel_tokenhanded to a cancellableasync fn. - Iter
- An owned, type-erased iterator handed across the C ABI boundary.
- weaveffi_
cancel_ token - Opaque cancellation token passed across the C ABI boundary.
- weaveffi_
error - Error struct passed across the C ABI boundary.
Constants§
- PANIC_
ERROR_ CODE - The reserved error code reporting a producer panic.
Traits§
- Error
Report - Maps a producer error onto the ABI’s
(code, message)pair.
Functions§
- block_
on - Drive a future to completion on the current thread, blocking until it resolves.
- c_
ptr_ to_ string - Convert a NUL-terminated C string pointer to an owned
String. ReturnsNoneifptris null or not valid UTF-8. - cancel_
token_ cancel - Signal cancellation on the token (thread-safe).
- cancel_
token_ create - Allocate a new cancel token. The caller owns the returned pointer and must
eventually call
weaveffi_cancel_token_destroy. - cancel_
token_ destroy - Destroy a cancel token previously created by
cancel_token_create. - cancel_
token_ is_ cancelled - Check whether the token has been cancelled (thread-safe).
- error_
clear - Clear an error by freeing any message and zeroing fields.
- error_
set - Populate an error with the given code and message (copying message).
- error_
set_ ok - Set the error to OK (code = 0) and free any prior message.
- error_
set_ panic - Report a caught panic through
out_errwithPANIC_ERROR_CODEand the payload’s message. Generated thunks call this from theircatch_unwinderror arm. - free_
bytes - Free a byte buffer previously allocated by Rust and returned to foreign code.
- free_
string - Free a C string previously allocated by this runtime.
- panic_
message - Best-effort extraction of a panic payload’s message (
&strandStringpayloads; anything else yields a fixed placeholder). - result_
to_ out_ err - Convenience adapter: map a
Result<T, E>toOption<T>by writing intoout_err. - string_
to_ c_ ptr - Allocate a new C string from a Rust string, returning an owned pointer.
Caller must later free with
weaveffi_free_stringorweaveffi_error_clear.
Type Aliases§
- weaveffi_
handle_ t - Public opaque handle type exposed to foreign callers.