Skip to content

Commit d2135c4

Browse files
committed
Make PwmPin trait fallible
1 parent a4fb672 commit d2135c4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/lib.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -897,26 +897,29 @@ pub trait Pwm {
897897
///
898898
/// See `Pwm` for details
899899
pub trait PwmPin {
900+
/// Enumeration of `PwmPin` errors
901+
type Error;
902+
900903
/// Type for the `duty` methods
901904
///
902905
/// The implementer is free to choose a float / percentage representation
903906
/// (e.g. `0.0 .. 1.0`) or an integer representation (e.g. `0 .. 65535`)
904907
type Duty;
905908

906909
/// Disables a PWM `channel`
907-
fn disable(&mut self);
910+
fn try_disable(&mut self) -> Result<(), Self::Error>;
908911

909912
/// Enables a PWM `channel`
910-
fn enable(&mut self);
913+
fn try_enable(&mut self) -> Result<(), Self::Error>;
911914

912915
/// Returns the current duty cycle
913-
fn get_duty(&self) -> Self::Duty;
916+
fn try_get_duty(&self) -> Result<Self::Duty, Self::Error>;
914917

915918
/// Returns the maximum duty cycle value
916-
fn get_max_duty(&self) -> Self::Duty;
919+
fn try_get_max_duty(&self) -> Result<Self::Duty, Self::Error>;
917920

918921
/// Sets a new duty cycle
919-
fn set_duty(&mut self, duty: Self::Duty);
922+
fn try_set_duty(&mut self, duty: Self::Duty) -> Result<(), Self::Error>;
920923
}
921924

922925
/// Quadrature encoder interface

0 commit comments

Comments
 (0)