switch_hal

Trait StatefulOutputSwitch

Source
pub trait StatefulOutputSwitch {
    type Error;

    // Required methods
    fn is_on(&mut self) -> Result<bool, Self::Error>;
    fn is_off(&mut self) -> Result<bool, Self::Error>;
}
Expand description

Checks current switch state

§Notes

This is only available if the underlying hal has implemented StatefulOutputPin

Required Associated Types§

Required Methods§

Source

fn is_on(&mut self) -> Result<bool, Self::Error>

Checks whether the switch is on

§Examples
use switch_hal::{OutputSwitch, Switch, StatefulOutputSwitch, IntoSwitch};
let mut led = pin.into_active_high_switch();
led.off().ok();
assert!(!led.is_on().unwrap());
Source

fn is_off(&mut self) -> Result<bool, Self::Error>

Checks whether the switch is off

§Examples
use switch_hal::{OutputSwitch, Switch, StatefulOutputSwitch, IntoSwitch};
let mut led = pin.into_active_high_switch();
led.off().ok();
assert!(led.is_off().unwrap());

Implementors§