1use crate::{Brightness, SysClass};
2use std::io::Result;
3use std::path::{Path, PathBuf};
4
5#[derive(Clone)]
7pub struct Leds {
8 path: PathBuf,
9}
10
11impl SysClass for Leds {
12 fn class() -> &'static str {
13 "leds"
14 }
15
16 unsafe fn from_path_unchecked(path: PathBuf) -> Self {
17 Self { path }
18 }
19
20 fn path(&self) -> &Path {
21 &self.path
22 }
23}
24
25impl Leds {
26 pub fn iter_keyboards() -> impl Iterator<Item = Result<Self>>
28 where
29 Self: 'static,
30 {
31 Self::iter().filter(move |object| {
32 object
33 .as_ref()
34 .ok()
35 .map_or(true, |o| o.id().contains("kbd_backlight"))
36 })
37 }
38}
39
40impl Brightness for Leds {}