Expand description
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.
Enums§
- Error
Kind - Fan error kind.