Skip to main content

classify_device

Function classify_device 

Source
pub fn classify_device<F>(
    dev: &InputDevice,
    model_name: F,
) -> Option<DeviceKind>
where F: Fn(&str) -> Option<String>,
Expand description

Classifies one device, consulting model_name only when the capabilities are ambiguous.

model_name receives the device’s sysfs path and returns the HID++ battery model string when one exists. It is injected rather than read directly so this stays a pure function — the same parameterised-resolver pattern display::parse_xrandr_displays_with uses, and for the same reason: a test must not depend on what is plugged into the machine running it.

Returns None for a device that is neither (a power button, a consumer-control endpoint) and for one that claims both capabilities with no model string to break the tie.