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 method
    fn poll_status(&self, _config: &PrinterConfig) -> Option<PrinterReason> { ... }
}
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<PrinterReason>

Query live printer-state-reasons for a registered printer. The background status loop calls this on each registered printer and updates the IPP attribute when the value changes. Returning None means “no update” (keep whatever the registry already holds).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§