Skip to content

Commit 0609d1a

Browse files
committed
Make Pwm trait method fallible
1 parent 62a5dc6 commit 0609d1a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/lib.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,9 @@ pub trait Capture {
847847
// reason: pre-singletons API. The `PwmPin` trait seems more useful because it models independent
848848
// PWM channels. Here a certain number of channels are multiplexed in a single implementer.
849849
pub trait Pwm {
850+
/// Enumeration of `Pwm` errors
851+
type Error;
852+
850853
/// Enumeration of channels that can be used with this `Pwm` interface
851854
///
852855
/// If your `Pwm` interface has no channels you can use the type `()`
@@ -863,25 +866,25 @@ pub trait Pwm {
863866
type Duty;
864867

865868
/// Disables a PWM `channel`
866-
fn disable(&mut self, channel: Self::Channel);
869+
fn disable(&mut self, channel: Self::Channel) -> Result<(), Self::Error>;
867870

868871
/// Enables a PWM `channel`
869-
fn enable(&mut self, channel: Self::Channel);
872+
fn enable(&mut self, channel: Self::Channel) -> Result<(), Self::Error>;
870873

871874
/// Returns the current PWM period
872-
fn get_period(&self) -> Self::Time;
875+
fn get_period(&self) -> Result<Self::Time, Self::Error>;
873876

874877
/// Returns the current duty cycle
875-
fn get_duty(&self, channel: Self::Channel) -> Self::Duty;
878+
fn get_duty(&self, channel: Self::Channel) -> Result<Self::Duty, Self::Error>;
876879

877880
/// Returns the maximum duty cycle value
878-
fn get_max_duty(&self) -> Self::Duty;
881+
fn get_max_duty(&self) -> Result<Self::Duty, Self::Error>;
879882

880883
/// Sets a new duty cycle
881-
fn set_duty(&mut self, channel: Self::Channel, duty: Self::Duty);
884+
fn set_duty(&mut self, channel: Self::Channel, duty: Self::Duty) -> Result<(), Self::Error>;
882885

883886
/// Sets a new PWM period
884-
fn set_period<P>(&mut self, period: P)
887+
fn set_period<P>(&mut self, period: P) -> Result<(), Self::Error>
885888
where
886889
P: Into<Self::Time>;
887890
}

0 commit comments

Comments
 (0)