File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ pub enum AnyTimerCallback {
1717/// callbacks can take the current [`Time`] as an argument, or [`Time`], or take
1818/// no argument at all.
1919pub trait TimerCallRepeating < Args > : Send + ' static {
20+ /// Convert a suitable object into a repeating timer callback
2021 fn into_repeating_timer_callback ( self ) -> AnyTimerCallback ;
2122}
2223
4243/// callbacks can take the current [`Time`] as an argument, or [`Time`], or take
4344/// no argument at all.
4445pub trait TimerCallOnce < Args > : Send + ' static {
46+ /// Convert a suitable object into a one-shot timer callback
4547 fn into_oneshot_timer_callback ( self ) -> AnyTimerCallback ;
4648}
4749
Original file line number Diff line number Diff line change @@ -9,11 +9,15 @@ use crate::{Clock, Node};
99#[ derive( Debug , Clone , Copy ) ]
1010#[ non_exhaustive]
1111pub struct TimerOptions < ' a > {
12+ /// The period of the timer's interval
1213 pub period : Duration ,
14+ /// The clock that the timer will reference for its intervals
1315 pub clock : TimerClock < ' a > ,
1416}
1517
1618impl TimerOptions < ' _ > {
19+ /// Make a new timer with a certain interval period, with all other options
20+ /// as default.
1721 pub fn new ( period : Duration ) -> Self {
1822 Self {
1923 period,
@@ -22,7 +26,10 @@ impl TimerOptions<'_> {
2226 }
2327}
2428
29+ /// Trait to implicitly convert a suitable object into [`TimerOptions`].
2530pub trait IntoTimerOptions < ' a > : Sized {
31+ /// Convert a suitable object into [`TimerOptions`]. This can be used on
32+ /// [`Duration`] or [`TimerOptions`] itself.
2633 fn into_timer_options ( self ) -> TimerOptions < ' a > ;
2734
2835 /// Use [`std::time::Instant`] for the timer. This the default so you
You can’t perform that action at this time.
0 commit comments