mod status

module status

Error handling following the metatensor/rgpot pattern.

Provides: 1. rsx_status_t – integer enum returned from every extern "C" function. 2. Thread-local error message retrievable via rsx_last_error(). 3. catch_unwind wrapper to prevent panics crossing the FFI boundary.

Functions

fn catch_unwind<F>(f: F) -> rsx_status_t
where
    F: FnOnce) -> rsx_status_t + std::panic::UnwindSafe

Execute a closure, catching any panics and converting them to status codes.

unsafe extern C fn rsx_last_error() -> *const c_char

Retrieve a pointer to the last error message for the current thread.

The pointer is valid until the next call to any radsex_* function on the same thread.

Safety This is intended to be called from C. The returned pointer must not be freed by the caller.

fn set_last_error(msg: &str)

Store an error message in the thread-local slot.

Enums

enum rsx_status_t

Status codes returned by all C API functions.

RSX_SUCCESS

Operation completed successfully.

RSX_INVALID_PARAMETER

An invalid parameter was passed (null pointer, wrong size, etc.).

RSX_INTERNAL_ERROR

An internal error occurred (e.g. a Rust panic was caught).

RSX_IO_ERROR

An I/O error occurred (file not found, permission denied, etc.).

RSX_ALIGNMENT_ERROR

An alignment error occurred (index missing, alignment failed, etc.).