-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvsensor_trait.rs
30 lines (26 loc) · 1.13 KB
/
envsensor_trait.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::sysc::OsResult;
use pwmp_client::pwmp_types::aliases::{AirPressure, Humidity, Temperature};
/// Contains functionality that an environment sensor must be able to do.
pub trait EnvironmentSensor {
/// Check if the environment sensor is connected.
///
/// # Errors
/// Upon a connection or communication error, an `Err(..)` value will be returned.
fn connected(&mut self) -> OsResult<bool>;
/// Read environment temperature.
///
/// # Errors
/// Upon a connection or communication error, an `Err(..)` value will be returned.
fn read_temperature(&mut self) -> OsResult<Temperature>;
/// Read environment *(relative)* humidity.
///
/// # Errors
/// Upon a connection or communication error, an `Err(..)` value will be returned.
fn read_humidity(&mut self) -> OsResult<Humidity>;
/// Read environment air pressure in hPa. If the sensor does not support this
/// feature, `Ok(None)` will be returned.
///
/// # Errors
/// Upon a connection or communication error, an `Err(..)` value will be returned.
fn read_air_pressure(&mut self) -> OsResult<Option<AirPressure>>;
}