1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Gets information about a timer.
//!
//! The Host can use this command to find out how much longer it will be
//! before a previously set timer will generate a callback.
use crate::ember::event::{Duration, Units};
crate::frame::parameters::frame!(
0x004E,
{ timer_id: u8 },
impl {
impl Command {
/// Creates command parameters.
#[must_use]
pub const fn new(timer_id: u8) -> Self {
Self { timer_id }
}
}
},
{ time: u16, units: u8, repeat: bool } => Utilities(utilities)::GetTimer,
impl {
impl Response {
/// Returns the time.
#[must_use]
pub const fn time(&self) -> u16 {
self.time
}
/// Returns the time units.
///
/// # Errors
///
/// Returns an error if the units are invalid.
pub fn units(&self) -> Result<Units, u8> {
Units::try_from(self.units)
}
/// Returns the time duration.
#[must_use]
pub fn duration(&self) -> Option<Duration> {
self.units()
.ok()
.and_then(|units| Duration::try_new(self.time, units).ok())
}
/// Returns whether the timer should repeat.
#[must_use]
pub const fn repeat(&self) -> bool {
self.repeat
}
}
}
);