Expand description
The error struct every fallible symbol reports through, the reserved
runtime codes, and the ErrorReport mapping from producer errors.
A synchronous call takes a caller-owned {prefix}_error* out_err slot; an
async completion receives a heap-boxed one it releases with
{prefix}_error_free. Either way the producer allocates the message (a
NUL-terminated C string) and the optional payload (a value buffer), so the
producer is also the one that frees them.
Structs§
- FfiError
- The error struct passed across the C ABI boundary (
{prefix}_errorin C).
Constants§
- CANCELLED_
ERROR_ CODE - The reserved error code reporting that an async call was cancelled: its cancel token fired, or the executor dropped the future before it completed. The completion callback still fires exactly once, with this code.
- FOREIGN_
ERROR_ CODE - The reserved error code reporting that a consumer callback-interface implementation failed.
- GENERIC_
ERROR_ CODE - The reserved error code for an untyped producer error: the default
ErrorReport::code, used byResult<T, String>and other error types that don’t map onto a declared domain code. - MARSHAL_
ERROR_ CODE - The reserved error code reporting a marshalling failure: an argument that could not be lifted at the boundary (a null pointer with a non-zero length, 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
Domain - An error type the
#[weaveffi::error]expansion generates: a module’s error domain, decodable from a code and its payload. - Error
Report - Maps a producer error onto the ABI’s
(code, message, payload)triple.
Functions§
- boxed_
error - Box
errfor an async completion callback, which hands ownership to the consumer (released with{prefix}_error_free). - error_
clear ⚠ - The body of
{prefix}_error_clear: free any message and payload and set the code to0. A nullerris a no-op. - error_
free ⚠ - The body of
{prefix}_error_free: release a heap-boxed error delivered through an async completion, including the box. A nullerris a no-op. - error_
set ⚠ - Fill the caller’s
out_errslot withcodeand a copy ofmessage, releasing anything it held before. A nullout_erris a no-op. - error_
set_ ⚠c - The body of
{prefix}_error_set: fillout_errfrom a borrowed C string the consumer owns. - error_
set_ ⚠payload_ c - The body of
{prefix}_error_set_payload: replaceout_err’s payload with a producer-owned copy of thelenbytes atptr. A nullout_erris a no-op; a nullptr(or alenof0) clears the payload. - error_
store ⚠ - Move
valueinto the caller’sout_errslot, releasing anything it held before. A nullout_errdropsvalue. - panic_
message - Best-effort extraction of a panic payload’s message (
&strandStringpayloads; anything else yields a fixed placeholder).