Skip to main content

SensorDevice

Trait SensorDevice 

Source
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§

Source

fn id(&self) -> &str

Unique sensor identifier.

Source

fn kind(&self) -> SensorKind

Sensor type.

Source

fn read(&self) -> Option<SensorReading>

Read current value. Returns None if the sensor is unavailable.

Provided Methods§

Source

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".

Implementors§