Skip to content

Commit

Permalink
separate OutputPin.toggle() into ToggleableOutputPin, provide default…
Browse files Browse the repository at this point in the history
… impl for StatefulOutputPin
  • Loading branch information
astro committed Apr 12, 2018
1 parent 3f61ef2 commit 99b9937
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/digital.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@ pub trait OutputPin {

/// Output pin that can read its output state
#[cfg(feature = "unproven")]
trait StatefulOutputPin: OutputPin {
trait StatefulOutputPin {
/// Is the pin set to high?
fn is_set_high(&self) -> bool;

/// Is the pin set to low?
fn is_set_low(&self) -> bool;
}

/// Output pin that can be toggled
#[cfg(feature = "unproven")]
trait ToggleableOutputPin {
/// Toggle pin output
fn toggle(&mut self);
}

/// Output pin that can be toggled
#[cfg(feature = "unproven")]
impl<PIN: OutputPin + StatefulOutputPin> ToggleableOutputPin for PIN {
/// Toggle pin output
fn toggle(&mut self) {
if self.is_set_low() {
Expand Down

0 comments on commit 99b9937

Please sign in to comment.