pub trait SensorDevice: Send + Sync {
// Required methods
fn id(&self) -> &str;
fn kind(&self) -> SensorKind;
fn read(&self) -> Option<SensorReading>;
// Provided method
fn is_available(&self) -> bool { ... }
}Expand description
Trait for sensor devices.
Implementations may wrap real hardware (via C-ABI FFI when the
hardware feature is enabled) or provide stub/simulated readings.
Required Methods§
Sourcefn kind(&self) -> SensorKind
fn kind(&self) -> SensorKind
Sensor type.
Sourcefn read(&self) -> Option<SensorReading>
fn read(&self) -> Option<SensorReading>
Read current value. Returns None if the sensor is unavailable.
Provided Methods§
Sourcefn is_available(&self) -> bool
fn is_available(&self) -> bool
Whether the sensor is currently available/connected.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".