Skip to main content

Crate cpdb_sys

Crate cpdb_sys 

Source
Expand description

Raw FFI bindings for the cpdb-libs C library (Common Print Dialog Backends).

§Overview

cpdb-sys is the low-level foundation of the cpdb-rs workspace. It uses bindgen to generate Rust declarations for every C function, type, and constant exposed by libcpdb and libcpdb-frontend, and wraps them in thin, safe-ish Rust modules.

Most Rust users should depend on cpdb-rs instead, either with the zbus-backend feature (async, pure-Rust, zero C dependencies) or the ffi feature (which re-exports this crate). Reach for cpdb-sys directly only when you need access to a C symbol that the higher-level crate hasn’t wrapped yet.

§Module structure

ModuleContents
bindingsRaw auto-generated bindgen output - all unsafe
callbacksSafe closure trampolines for cpdb_printer_callback and cpdb_async_callback
commonHelpers for paths, config dirs, and library init (cpdbInit)
errorerror::CpdbError enum and Result alias used by all modules
frontendSafe wrapper around cpdb_frontend_obj_t
optionsoptions::OptionsCollection - owned snapshot of a printer’s capabilities
printerSafe wrapper around cpdb_printer_obj_t
settingsSafe wrapper around cpdb_settings_t
utilInternal C-string helpers and COptions array builder

All raw C symbols (functions, types, constants) are additionally re-exported at the crate root via pub use bindings::*, so you can write cpdb_sys::cpdbInit() instead of cpdb_sys::bindings::cpdbInit().

§Safety

Everything in bindings is unsafe. The higher-level modules (frontend, printer, settings, …) encapsulate the most common usage patterns behind safe APIs, but they cannot prevent all misuse - read each module’s documentation carefully before calling into the C library directly.

§Build requirements

cpdb-sys links against libcpdb and libcpdb-frontend. Install the development headers before building:

# Debian / Ubuntu
sudo apt install libcpdb-dev

# Fedora / RHEL
sudo dnf install cpdb-libs-devel

Set CPDB_LIBS_PATH=<prefix> if the library is installed to a non-standard location where pkg-config cannot find it.

Re-exports§

pub use bindings::*;

Modules§

bindings
Raw, auto-generated bindings to the cpdb-libs C API.
callbacks
Closure-friendly wrappers over the two cpdb-libs C callback shapes.
common
Library-wide entry points: version query, one-shot initialisation, and the small set of path/config helpers cpdb-libs ships.
error
cpdb-sys workspace error type and Result alias.
frontend
Safe wrapper around cpdb_frontend_obj_t.
options
Printer options (capabilities) from C cpdb_options_t.
printer
Safe wrapper around cpdb_printer_obj_t.
settings
Safe wrappers around cpdb_settings_t, cpdb_options_t, and cpdb_media_t.
util
Small FFI utilities shared by the higher-level modules.