Skip to main content

Crate cpdb_rs

Crate cpdb_rs 

Source
Expand description

Crate-level documentation for cpdb-rs.

This library provides a native async Rust client for the Common Print Dialog Backends (CPDB) system. It communicates with CPDB backends (e.g. cpdb-backend-cups) over D-Bus using zbus, requiring no C dependencies.

§Features

  • zbus-backend (default) - Native async D-Bus client via CpdbClient. (Note: This uses zbus with the tokio runtime feature exclusively. Other async runtimes like async-std are not currently supported by the high-level client).
  • ffi - Legacy synchronous C FFI bindings via cpdb-libs.

§Quick start

use cpdb_rs::CpdbClient;

let client = CpdbClient::new().await?;
let printers = client.get_all_printers().await?;

for p in &printers {
    println!("{} [{}] - {}", p.name, p.id, p.make_model);
}

if let Some(p) = printers.first() {
    let (options, media) = client
        .get_printer_details(&p.id, &p.backend)
        .await?;
    println!("{} options, {} media sizes", options.len(), media.len());
}

Re-exports§

pub use client::CpdbClient;zbus-backend
pub use config::PrinterConfig;zbus-backend
pub use events::DiscoveryEvent;zbus-backend
pub use events::PrinterSnapshot;zbus-backend
pub use media::MarginInfo;zbus-backend
pub use media::MediaCollection;zbus-backend
pub use media::MediaInfo;zbus-backend
pub use types::PrinterState;zbus-backend
pub use error::CpdbError;
pub use error::Result;
pub use options::OptionInfo;
pub use options::OptionsCollection;

Modules§

clientzbus-backend
Async CPDB client.
configzbus-backend
Printer configuration persistence types.
error
Crate-wide error type and Result alias.
eventszbus-backend
Discovery events emitted by CPDB backends.
mediazbus-backend
Paper sizes and margins returned by GetAllOptions.
options
Printer options (capabilities) returned by GetAllOptions.
proxyzbus-backend
D-Bus proxy for the org.openprinting.PrintBackend interface.
typeszbus-backend
Shared utility types for cpdb-rs.