lhm-client

Crates.iolhm-client
lib.rslhm-client
version0.3.0
created_at2025-05-12 05:33:46.963375+00
updated_at2025-08-02 04:47:35.473951+00
descriptionClient for using the LHM service
homepage
repositoryhttps://github.com/jacobtread/lhm-service
max_upload_size
id1670034
size43,940
Jacob (jacobtread)

documentation

README

LHM Client

Client that can consume the LHM Service from user-land

use lhm_client::{ComputerOptions, Hardware, HardwareType, LHMClient, SensorType};

let mut client = LHMClient::connect().await.unwrap();

client
    .set_options(ComputerOptions {
        controller_enabled: true,
        cpu_enabled: true,
        gpu_enabled: true,
        motherboard_enabled: true,
        ..Default::default()
    })
    .await
    .unwrap();

client.update().await.unwrap();

let hardware = client.get_hardware().await.unwrap();

let cpus: Vec<&Hardware> = hardware
    .iter()
    .filter(|value| matches!(value.ty, HardwareType::Cpu))
    .collect();

let cpu_temps = cpus
    .iter()
    .flat_map(|value| {
        value
            .sensors
            .iter()
            .filter(|value| matches!(value.ty, SensorType::Temperature))
    })
    .collect::<Vec<_>>();

let temp = cpu_temps
    .iter()
    .find(|sensor| sensor.name.eq("CPU Package"));

let temp = temp.map(|value| value.value).expect("Unknown CPU Temp");

println!("CPU is {temp}°C");
Commit count: 56

cargo fmt