pub trait OneshotSensorSync {
type Error: Debug;
type Measurement: Measurement;
// Required method
fn measure(&mut self) -> Result<Self::Measurement, Self::Error>;
}Expand description
A sensor supporting one-shot measurements.
If the hardware device itself doesn’t support one-shot measurements but they can be meaningfully emulated by starting and stopping continuous measurements without drawbacks, it may also implement this trait. If the sensor requires a certain amount of time in continuous measurement mode to yield meaningful results, this trait should not be implemented.
Required Associated Types§
Sourcetype Measurement: Measurement
type Measurement: Measurement
A type holding the measurements obtained by this sensor
Required Methods§
Sourcefn measure(&mut self) -> Result<Self::Measurement, Self::Error>
fn measure(&mut self) -> Result<Self::Measurement, Self::Error>
Performs a one-shot measurement.
If the device supports several measurement modes, this function attempts to switch to oneshot mode on best effort. The mode in which the device is left after measurement is not specified further, but if possible, a sleep mode or equivalent mode should be preferred.