[][src]Trait switch_hal::IntoSwitch

pub trait IntoSwitch {
    fn into_switch<ActiveLevel>(self) -> Switch<Self, ActiveLevel>
    where
        Self: Sized
; fn into_active_low_switch(self) -> Switch<Self, ActiveLow>
    where
        Self: Sized
, { ... }
fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>
    where
        Self: Sized
, { ... } }

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

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>();
Loading content...

Provided methods

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();

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();
Loading content...

Implementors

impl<T> IntoSwitch for T[src]

Loading content...