Skip to main content

set_callbacks

Function set_callbacks 

Source
pub fn set_callbacks(callbacks: &'static Callbacks) -> bool
Expand description

Install callbacks, replacing any previous table. Returns false if the C library refused the table.

'static is what makes this safe: the C side keeps the pointer until the table is replaced or cleared, which is exactly the header’s “arg pointers are caller-owned and must stay valid” requirement.

Callbacks run with no allocator locks held and may allocate, but a hook that fires while another hook’s callback is running on the same thread is suppressed — so bytes a callback itself allocates never reach the running totals. Keep them short, and let them return normally: a panic is caught and swallowed here, but a C longjmp out of one is unsupported.