cpdb_sys/lib.rs
1//! Raw FFI bindings for the [cpdb-libs](https://github.com/OpenPrinting/cpdb-libs)
2//! C library (Common Print Dialog Backends).
3//!
4//! # Overview
5//!
6//! `cpdb-sys` is the low-level foundation of the `cpdb-rs` workspace. It
7//! uses [`bindgen`](https://crates.io/crates/bindgen) to generate Rust
8//! declarations for every C function, type, and constant exposed by
9//! `libcpdb` and `libcpdb-frontend`, and wraps them in thin, safe-ish
10//! Rust modules.
11//!
12//! **Most Rust users should depend on [`cpdb-rs`](https://crates.io/crates/cpdb-rs)
13//! instead**, either with the `zbus-backend` feature (async, pure-Rust,
14//! zero C dependencies) or the `ffi` feature (which re-exports this crate).
15//! Reach for `cpdb-sys` directly only when you need access to a C symbol
16//! that the higher-level crate hasn't wrapped yet.
17//!
18//! # Module structure
19//!
20//! | Module | Contents |
21//! |--------|----------|
22//! | [`bindings`] | Raw auto-generated `bindgen` output - all `unsafe` |
23//! | [`callbacks`] | Safe closure trampolines for `cpdb_printer_callback` and `cpdb_async_callback` |
24//! | [`common`] | Helpers for paths, config dirs, and library init (`cpdbInit`) |
25//! | [`error`] | [`error::CpdbError`] enum and `Result` alias used by all modules |
26//! | [`frontend`] | Safe wrapper around `cpdb_frontend_obj_t` |
27//! | [`options`] | [`options::OptionsCollection`] - owned snapshot of a printer's capabilities |
28//! | [`printer`] | Safe wrapper around `cpdb_printer_obj_t` |
29//! | [`settings`] | Safe wrapper around `cpdb_settings_t` |
30//! | [`util`] | Internal C-string helpers and `COptions` array builder |
31//!
32//! All raw C symbols (functions, types, constants) are additionally
33//! re-exported at the crate root via `pub use bindings::*`, so you can
34//! write `cpdb_sys::cpdbInit()` instead of `cpdb_sys::bindings::cpdbInit()`.
35//!
36//! # Safety
37//!
38//! Everything in [`bindings`] is `unsafe`. The higher-level modules
39//! (`frontend`, `printer`, `settings`, ...) encapsulate the most common
40//! usage patterns behind safe APIs, but they cannot prevent all misuse -
41//! read each module's documentation carefully before calling into the C
42//! library directly.
43//!
44//! # Build requirements
45//!
46//! `cpdb-sys` links against `libcpdb` and `libcpdb-frontend`. Install
47//! the development headers before building:
48//!
49//! ```text
50//! # Debian / Ubuntu
51//! sudo apt install libcpdb-dev
52//!
53//! # Fedora / RHEL
54//! sudo dnf install cpdb-libs-devel
55//! ```
56//!
57//! Set `CPDB_LIBS_PATH=<prefix>` if the library is installed to a
58//! non-standard location where `pkg-config` cannot find it.
59
60#![allow(non_upper_case_globals)]
61#![allow(non_camel_case_types)]
62#![allow(non_snake_case)]
63#![allow(missing_docs)]
64
65pub mod bindings;
66pub mod callbacks;
67pub mod common;
68pub mod error;
69pub mod frontend;
70pub mod options;
71pub mod printer;
72pub mod settings;
73pub mod util;
74
75#[allow(unused_imports)]
76pub use bindings::*;