2 unstable releases
| 0.2.0 | Jul 31, 2025 |
|---|---|
| 0.1.0 | May 26, 2025 |
#2121 in Embedded development
3,399 downloads per month
15KB
186 lines
Async Fan API
This API provides generic methods for interfacing with fans.
For HAL authors
Here is an example of an embedded-fans implementation of the Fan and RpmSense traits.
use embedded_fans_async::{self, Fan, RpmSense};
// A struct representing a fan device.
pub struct MyFan {
// ...
}
#[derive(Clone, Copy, Debug)]
pub enum Error {
// ...
}
impl embedded_fans_async::Error for Error {
fn kind(&self) -> embedded_fans::ErrorKind {
match *self {
// ...
}
}
}
impl embedded_fans_async::ErrorType for MyFan {
type Error = Error;
}
impl Fan for MyFan {
fn max_rpm(&self) -> u16 {
3150
}
fn min_rpm(&self) -> u16 {
0
}
fn min_start_rpm(&self) -> u16 {
1120
}
async fn set_speed_rpm(&mut self, rpm: u16) -> Result<u16, Self::Error> {
// ...
Ok(rpm)
}
}
impl RpmSense for MyFan {
async fn rpm(&mut self) -> Result<u16, Self::Error> {
// ...
Ok(42)
}
}
embedded-fans-async
This crate contains async traits which define the embedded-fans interface.
Dependencies
~135KB