Skip to content

Commit b26cfd8

Browse files
committed
Make PwmPin methods fallible
1 parent 0609d1a commit b26cfd8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/lib.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -893,26 +893,29 @@ pub trait Pwm {
893893
///
894894
/// See `Pwm` for details
895895
pub trait PwmPin {
896+
/// Enumeration of `PwmPin` errors
897+
type Error;
898+
896899
/// Type for the `duty` methods
897900
///
898901
/// The implementer is free to choose a float / percentage representation
899902
/// (e.g. `0.0 .. 1.0`) or an integer representation (e.g. `0 .. 65535`)
900903
type Duty;
901904

902905
/// Disables a PWM `channel`
903-
fn disable(&mut self);
906+
fn disable(&mut self) -> Result<(), Self::Error>;
904907

905908
/// Enables a PWM `channel`
906-
fn enable(&mut self);
909+
fn enable(&mut self) -> Result<(), Self::Error>;
907910

908911
/// Returns the current duty cycle
909-
fn get_duty(&self) -> Self::Duty;
912+
fn get_duty(&self) -> Result<Self::Duty, Self::Error>;
910913

911914
/// Returns the maximum duty cycle value
912-
fn get_max_duty(&self) -> Self::Duty;
915+
fn get_max_duty(&self) -> Result<Self::Duty, Self::Error>;
913916

914917
/// Sets a new duty cycle
915-
fn set_duty(&mut self, duty: Self::Duty);
918+
fn set_duty(&mut self, duty: Self::Duty) -> Result<(), Self::Error>;
916919
}
917920

918921
/// Quadrature encoder interface

0 commit comments

Comments
 (0)