Skip to main content

Module printer

Module printer 

Source
Expand description

Safe wrapper around cpdb_printer_obj_t.

§Ownership and lifetimes

Printers come in two flavours:

  • Borrowed — returned by [crate::Frontend::find_printer], [crate::Frontend::get_printer], [crate::Frontend::get_printers], and the default-printer accessors. The underlying C object is owned by the frontend’s hash table; the Rust binding carries the frontend’s lifetime so the borrow checker enforces that the printer cannot outlive its frontend.
  • Owned — returned by Printer::load_from_file. The C object was allocated independently; Rust frees it via cpdbDeletePrinterObj on drop. Owned printers have a 'static lifetime.

Printer deliberately does not implement Send or Sync. Most cpdb-libs methods on a printer object mutate shared state (the printer’s settings table is shared with the frontend), and the C library does not lock internally. If you need to dispatch printer operations from multiple threads, wrap a single printer in a std::sync::Mutex.

Structs§

Margin
Page margins in hundredths of a millimetre.
Margins
One or more Margin entries returned by the backend for a media type.
MediaSize
Media dimensions in hundredths of a millimetre.
PrintFdHandle
Handle returned by Printer::print_fd.
PrintSocketHandle
Handle returned by Printer::print_socket.
Printer
A safe handle to a cpdb printer object.
TranslationMap
An owned snapshot of a printer’s translation table.