Skip to main content

DeviceBackend

Trait DeviceBackend 

Source
pub trait DeviceBackend: Send + Sync {
    // Required methods
    fn list(&self, emit: &mut dyn FnMut(&str, &str, &str) -> bool);
    fn driver_for_device(
        &self,
        device_id: &str,
        device_uri: &str,
    ) -> Option<String>;

    // Provided methods
    fn poll_status(&self, _config: &PrinterConfig) -> Option<PollStatus> { ... }
    fn identify(&self, _config: &PrinterConfig, _actions: &[String]) { ... }
}
Expand description

Enumerate physical printers and report their live health.

Implementations describe how to discover devices (e.g. via sysfs, BlueZ, USB enumeration) and how to map their identifying strings to a driver name registered with the framework.

Required Methods§

Source

fn list(&self, emit: &mut dyn FnMut(&str, &str, &str) -> bool)

Call emit(info, uri, device_id) for each discovered device. The closure returns true to continue enumeration, false to stop early.

Source

fn driver_for_device(&self, device_id: &str, device_uri: &str) -> Option<String>

Map a device’s IEEE 1284 device-id string and URI to a driver name that this backend recognises. Return None for “this isn’t one of mine, skip it”.

Provided Methods§

Source

fn poll_status(&self, _config: &PrinterConfig) -> Option<PollStatus>

Query live status for a registered printer. The background status loop calls this on each idle printer and updates the IPP attributes when the value changes. Returning None means “no update” (keep whatever the registry already holds); returning Some carries the fresh reasons and, optionally, the loaded media and remaining-supply level.

Source

fn identify(&self, _config: &PrinterConfig, _actions: &[String])

Handle an Identify-Printer request (PWG 5100.14 §5.1) — make the physical device announce itself (beep, flash an LED, …). actions holds the requested identify-actions keywords (display, sound, flash, speak); an empty slice means “use the default action”. Default: no-op.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§