Skip to content

Commit ab070b4

Browse files
committed
Make Watchdog trait methods fallible
1 parent 0969b74 commit ab070b4

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/watchdog.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,43 @@
44
/// commonly referred to as "kicking" or "refreshing".
55
#[cfg(feature = "unproven")]
66
pub trait Watchdog {
7+
/// An enumeration of `Watchdog` errors.
8+
///
9+
/// For infallible implementations, will be `Infallible`
10+
type Error;
11+
712
/// Triggers the watchdog. This must be done once the watchdog is started
813
/// to prevent the processor being reset.
9-
fn feed(&mut self);
14+
fn try_feed(&mut self) -> Result<(), Self::Error>;
1015
}
1116

1217
/// Enables A watchdog timer to reset the processor if software is frozen or
1318
/// stalled.
1419
#[cfg(feature = "unproven")]
1520
pub trait WatchdogEnable {
21+
/// An enumeration of `WatchdogEnable` errors.
22+
///
23+
/// For infallible implementations, will be `Infallible`
24+
type Error;
25+
1626
/// Unit of time used by the watchdog
1727
type Time;
28+
1829
/// Starts the watchdog with a given period, typically once this is done
1930
/// the watchdog needs to be kicked periodically or the processor is reset.
20-
fn start<T>(&mut self, period: T)
31+
fn try_start<T>(&mut self, period: T) -> Result<(), Self::Error>
2132
where
2233
T: Into<Self::Time>;
2334
}
2435

2536
/// Disables a running watchdog timer so the processor won't be reset.
2637
#[cfg(feature = "unproven")]
2738
pub trait WatchdogDisable {
39+
/// An enumeration of `WatchdogDisable` errors.
40+
///
41+
/// For infallible implementations, will be `Infallible`
42+
type Error;
43+
2844
/// Disables the watchdog
29-
fn disable(&mut self);
45+
fn try_disable(&mut self) -> Result<(), Self::Error>;
3046
}

0 commit comments

Comments
 (0)