Struct omnisensor::sensor::SensorIOCtx
source · [−]pub struct SensorIOCtx {
io: SensorIO,
bridge_gpio: Option<BridgeGPIO>,
i2cdev: Option<Arc<I2CDevice>>,
next_update: Box<dyn FnMut(&Sensor) -> BoxFuture<'static, ()> + Send + Sync>,
}
Expand description
A SensorIO
plus some surrounding context.
Fields
io: SensorIO
The sensor I/O mechanism.
bridge_gpio: Option<BridgeGPIO>
A GPIO that must be asserted before reading the sensor.
i2cdev: Option<Arc<I2CDevice>>
A reference to an I2C device associated with the sensor.
next_update: Box<dyn FnMut(&Sensor) -> BoxFuture<'static, ()> + Send + Sync>
Function returning a future to await before performing an update of the sensor’s value.
Implementations
sourceimpl SensorIOCtx
impl SensorIOCtx
sourcepub fn with_bridge_gpio(self, bridge_gpio: Option<BridgeGPIO>) -> Self
pub fn with_bridge_gpio(self, bridge_gpio: Option<BridgeGPIO>) -> Self
Add a BridgeGPIO
to a sensor I/O context.
sourcepub fn with_i2cdev(self, i2cdev: Option<Arc<I2CDevice>>) -> Self
pub fn with_i2cdev(self, i2cdev: Option<Arc<I2CDevice>>) -> Self
Add an I2CDevice
to a sensor I/O context.
sourcepub fn with_next_update(
self,
next: Box<dyn FnMut(&Sensor) -> BoxFuture<'static, ()> + Send + Sync>
) -> Self
pub fn with_next_update(
self,
next: Box<dyn FnMut(&Sensor) -> BoxFuture<'static, ()> + Send + Sync>
) -> Self
Replace the default (periodic polling) next_update
function of a sensor I/O context.
Auto Trait Implementations
impl !RefUnwindSafe for SensorIOCtx
impl Send for SensorIOCtx
impl Sync for SensorIOCtx
impl Unpin for SensorIOCtx
impl !UnwindSafe for SensorIOCtx
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more