Expand description
The glue every generated thunk calls: per-family parameter lifting, return lowering, and the synchronous call driver.
The #[weaveffi::module] expansion emits one short call per parameter
and per return into this module instead of inlining the marshalling, so
sync thunks, async launchers, iterator steps, and callback-interface
wrappers share one implementation of each family’s rules:
lift_*functions turn a parameter’s C slots into the Rust value the producer’s function takes, or aMARSHAL_ERROR_CODEerror naming the parameter. A thunk lifts every parameter before it looks at any result, so a callback context or the object tokens in a buffer are always adopted (and released again) even when another parameter fails.lower_*functions (andCEnum::to_i32) turn a returned value into its C return and out slots.call_syncruns a synchronous thunk’s body undercatch_unwindand reports its outcome throughout_err.
Traits§
- CEnum
- A C-style enum: an
i32discriminant at the C ABI and inside value buffers. The#[weaveffi::module]expansion implements it for every#[repr(i32)]#[weaveffi::enumeration]. - Sentinel
- The zero value a C return slot carries when a call fails:
0,false,0.0, or null. Implemented for every C return type a thunk can have,()forvoid, and pairs and tuples of them (an async completion’s result slots).
Functions§
- buffer_
run - A value buffer as an async completion’s owned
(result_ptr, result_len)run. - byte_
slots - Borrow a bytes-like argument as the
(ptr, len)slots of a callback method call. - bytes_
run - Bytes as an async completion’s owned
(result_ptr, result_len)run. - call_
sync ⚠ - Run a synchronous thunk’s body and report its outcome:
Okclearsout_errand returns the value;Errstores the error and returns theSentinel; a panic is caught and reported with the panic code, so it never unwinds into C. - lift_
buffer_ ⚠param - Decode a value-buffer parameter (a record, rich enum, optional, list, or map), adopting any object tokens it carries.
- lift_
bytes_ ⚠param - Copy a bytes parameter into an owned
Vec<u8>. - lift_
callback_ ⚠opt_ param - Adopt an optional callback-interface parameter (
Cb?); a null vtable isNone. - lift_
callback_ ⚠param - Adopt a callback-interface parameter’s
(ctx, vtable)pair. - lift_
enum - Lift a C-style enum parameter.
- lift_
object_ ⚠arc_ opt_ param - Retain an optional object parameter (
I?); null isNone. - lift_
object_ ⚠arc_ param - Take a new strong reference to an object parameter, so the producer can retain it.
- lift_
object_ ⚠opt_ param - Borrow an optional object parameter (
I?); null isNone. - lift_
object_ ⚠param - Borrow an object parameter for the call.
- lift_
self ⚠ - Lift a method’s receiver (
self), borrowed for the call. - lift_
self_ ⚠arc - Lift a method’s receiver as a retained reference (
self: Arc<Self>, and every async method, whose future outlives the launcher). - lift_
slice_ ⚠param - Borrow a bytes parameter’s
(ptr, len)run as a slice. - lift_
str_ ⚠param - Borrow a string parameter’s UTF-8
(ptr, len)run as a&str. - lift_
string_ ⚠param - Copy a string parameter into an owned
String. - lower_
buffer_ ⚠ret - Encode a returned value buffer as a producer-allocated run plus
*out_len. - lower_
bytes_ ⚠ret - Lower returned bytes as a producer-allocated run plus
*out_len. - lower_
string_ ⚠ret - Lower a returned string as a producer-allocated run plus
*out_len. - read_
enum - Read a C-style enum from a value buffer (the body of its
BufferValue::read_value). - str_
slots - Borrow a string-like argument as the
(ptr, len)slots of a callback method call. - string_
run - A string as an async completion’s owned
(result_ptr, result_len)run. - write_
enum - Write a C-style enum into a value buffer (the body of its
BufferValue::write_value).