Skip to main content

Crate weaveffi_abi

Crate weaveffi_abi 

Source
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§

CancelToken
A safe, Send view of a foreign weaveffi_cancel_token handed to a cancellable async 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§

ErrorReport
Maps a producer error onto the ABI’s (code, message) pair.

Functions§

abi_version
Return ABI_VERSION; the body behind the exported weaveffi_abi_version thunk.
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 &str without copying. Returns None if ptr is null or the bytes aren’t valid UTF-8.
c_ptr_to_string
Convert a NUL-terminated C string pointer to an owned String. Returns None if ptr is 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_err with PANIC_ERROR_CODE and the payload’s message. Generated thunks call this from their catch_unwind error 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 buffer format).
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 (&str and String payloads; anything else yields a fixed placeholder).
result_to_out_err
Convenience adapter: map a Result<T, E> to Option<T> by writing into out_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_string or weaveffi_error_clear.

Type Aliases§

Handle
The producer-side spelling of the IDL’s opaque handle type.
weaveffi_handle_t
Public opaque handle type exposed to foreign callers.