pub trait Sensor: Serializable + Deserializable {
// Required methods
fn low(&self) -> u16;
fn high(&self) -> u16;
// Provided method
fn percentage(&self, value: u16) -> f32 { ... }
}
Expand description
Defines common behaviour for all sensors, such as getting the calibrated low and high values, and provides a function to compute where a value fits within the calibrated boundaries.
Required Methods§
Provided Methods§
Sourcefn percentage(&self, value: u16) -> f32
fn percentage(&self, value: u16) -> f32
Given a value, returns the percentage it falls within the calibrated boundaries.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.