Expand description
C ABI runtime: error struct, memory helpers, and utility functions.
Re-exports§
pub use buffer::decode_value;pub use buffer::encode_value;pub use buffer::BufferDecodeError;pub use buffer::BufferReader;pub use buffer::BufferValue;pub use buffer::BufferWriter;pub use convert::lift_byte_slice;pub use convert::lift_bytes;pub use convert::lower_bytes;
Modules§
- arena
- Batch handle management via an arena that tracks pointers and their destructors.
- buffer
- The WeaveFFI value-buffer protocol: the by-value serialization format records, rich enums, optionals, lists, maps, and error payloads use to cross the C ABI.
- 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§
- ABI_
VERSION - The revision of the WeaveFFI C ABI this runtime implements.
- MARSHAL_
ERROR_ CODE - The reserved error code reporting a marshalling failure: an argument that could not be lifted at the boundary (a null or invalid pointer, a non-UTF-8 string, an out-of-range enum discriminant, or a malformed value buffer).
- 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§
- abi_
version - Return
ABI_VERSION; the body behind the exportedweaveffi_abi_versionthunk. - block_
on - Drive a future to completion on the current thread, blocking until it resolves.
- c_
ptr_ ⚠to_ str - Borrow a NUL-terminated C string as a
&strwithout copying. ReturnsNoneifptris null or the bytes aren’t valid UTF-8. - 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_
free - Free a heap-boxed error delivered through an async completion callback.
- error_
set - Populate an error with the given code and message (copying message), clearing any prior payload.
- error_
set_ ok - Set the error to OK (code = 0) and free any prior message and payload.
- error_
set_ panic - Report a caught panic through
out_errwithPANIC_ERROR_CODEand the payload’s message. Generated thunks call this from theircatch_unwinderror arm. - error_
set_ with_ payload - Populate an error with a code, message, and an owned payload buffer (the
matched error code’s fields serialized in the
bufferformat). - 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§
- Handle
- The producer-side spelling of the IDL’s opaque
handletype. - weaveffi_
handle_ t - Public opaque handle type exposed to foreign callers.