Skip to main content

Module callback

Module callback 

Source
Expand description

§callback — Named callback registry

Provides a thread-safe, global registry of named callbacks. Callbacks can be registered either from Rust (typed closure) or from the C/Go side via ffi_register_callback (C function pointer).

§Design

The registry is a Mutex<HashMap<String, CallbackFn>> initialized lazily via once_cell. All exported functions are panic-safe via catch_panic.

§Thread safety

The registry is protected by a std::sync::Mutex. If a thread panics while holding the lock, the lock becomes poisoned and all subsequent operations return FfiError::LockPoisoned.

Functions§

callback_count
Return the number of currently registered callbacks.
ffi_callback_count
Return the number of registered callbacks.
ffi_invoke_callback
Invoke a registered callback by name.
ffi_register_callback
Register a C function pointer as a named callback.
ffi_unregister_callback
Remove a registered callback by name.
register_callback
Register a named callback from Rust code.
unregister_callback
Remove a callback by name from Rust code.