Skip to main content

Module callbacks

Module callbacks 

Source
Expand description

Closure-friendly wrappers over the two cpdb-libs C callback shapes.

cpdb-libs has two callback types:

  1. cpdb_printer_callback — fires when a printer is added, removed, or changes state. It carries no user_data, so a thin-pointer Box trampoline cannot work. We use a global registry keyed on the frontend pointer; the trampoline looks the closure up by that key.

  2. cpdb_async_callback — completion for cpdbAcquireDetails and cpdbAcquireTranslations. It does carry user_data, so we use the standard Box<Box<dyn FnOnce>> thin-pointer trampoline.

Both trampolines wrap the user closure in catch_unwind so a Rust panic does not unwind across the FFI boundary (which is UB).

Enums§

PrinterUpdate
The change reported by a printer callback.