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

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§

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§

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. 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_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_err with PANIC_ERROR_CODE and the payload’s message. Generated thunks call this from their catch_unwind error 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 (&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§

weaveffi_handle_t
Public opaque handle type exposed to foreign callers.