pub trait IntoSwitch {
// Required method
fn into_switch<ActiveLevel>(self) -> Switch<Self, ActiveLevel>
where Self: Sized;
// Provided methods
fn into_active_low_switch(self) -> Switch<Self, ActiveLow>
where Self: Sized { ... }
fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>
where Self: Sized { ... }
}
Expand description
Convenience functions for converting InputPin and OutputPin to a Switch.
The type of Switch returned,
InputSwitch or OutputSwitch is
determined by whether the IoPin
being consumed is an InputPin
or OutputPin.
Required Methods§
sourcefn into_switch<ActiveLevel>(self) -> Switch<Self, ActiveLevel>where
Self: Sized,
fn into_switch<ActiveLevel>(self) -> Switch<Self, ActiveLevel>where
Self: Sized,
Consumes the IoPin
returning a Switch of the appropriate ActiveLevel
.
This method exists so other, more convenient functions, can have blanket implementations.
Prefer into_active_low_switch and into_active_high_switch.
§Examples
§Active High
use switch_hal::{ActiveHigh, OutputSwitch, IntoSwitch};
let led = pin.into_switch::<ActiveHigh>();
§Active Low
use switch_hal::{ActiveLow, InputSwitch, IntoSwitch};
let button = pin.into_switch::<ActiveLow>();
Provided Methods§
sourcefn into_active_low_switch(self) -> Switch<Self, ActiveLow>where
Self: Sized,
fn into_active_low_switch(self) -> Switch<Self, ActiveLow>where
Self: Sized,
Consumes the IoPin
returning a Switch<IoPin, ActiveLow>
.
§Examples
use switch_hal::IntoSwitch;
let led = pin.into_active_low_switch();
sourcefn into_active_high_switch(self) -> Switch<Self, ActiveHigh>where
Self: Sized,
fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>where
Self: Sized,
Consumes the IoPin
returning a Switch<IoPin, ActiveHigh>
.
§Examples
use switch_hal::IntoSwitch;
let button = pin.into_active_high_switch();