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 {
17
17
/// callbacks can take the current [`Time`] as an argument, or [`Time`], or take
18
18
/// no argument at all.
19
19
pub trait TimerCallRepeating < Args > : Send + ' static {
20
+ /// Convert a suitable object into a repeating timer callback
20
21
fn into_repeating_timer_callback ( self ) -> AnyTimerCallback ;
21
22
}
22
23
42
43
/// callbacks can take the current [`Time`] as an argument, or [`Time`], or take
43
44
/// no argument at all.
44
45
pub trait TimerCallOnce < Args > : Send + ' static {
46
+ /// Convert a suitable object into a one-shot timer callback
45
47
fn into_oneshot_timer_callback ( self ) -> AnyTimerCallback ;
46
48
}
47
49
Original file line number Diff line number Diff line change @@ -9,11 +9,15 @@ use crate::{Clock, Node};
9
9
#[ derive( Debug , Clone , Copy ) ]
10
10
#[ non_exhaustive]
11
11
pub struct TimerOptions < ' a > {
12
+ /// The period of the timer's interval
12
13
pub period : Duration ,
14
+ /// The clock that the timer will reference for its intervals
13
15
pub clock : TimerClock < ' a > ,
14
16
}
15
17
16
18
impl TimerOptions < ' _ > {
19
+ /// Make a new timer with a certain interval period, with all other options
20
+ /// as default.
17
21
pub fn new ( period : Duration ) -> Self {
18
22
Self {
19
23
period,
@@ -22,7 +26,10 @@ impl TimerOptions<'_> {
22
26
}
23
27
}
24
28
29
+ /// Trait to implicitly convert a suitable object into [`TimerOptions`].
25
30
pub trait IntoTimerOptions < ' a > : Sized {
31
+ /// Convert a suitable object into [`TimerOptions`]. This can be used on
32
+ /// [`Duration`] or [`TimerOptions`] itself.
26
33
fn into_timer_options ( self ) -> TimerOptions < ' a > ;
27
34
28
35
/// Use [`std::time::Instant`] for the timer. This the default so you
You can’t perform that action at this time.
0 commit comments