Skip to content

Commit 198e96d

Browse files
Drew TadaDrew Tada
authored andcommitted
timer updated to latest api
1 parent bbce1cc commit 198e96d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/timer.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
use crate::*;
22
use anyhow::Result;
33

4+
#[derive(Debug, Clone, Serialize, Deserialize)]
5+
pub enum TimerAction {
6+
Debug,
7+
SetTimer(u64),
8+
}
9+
410
/// Set a timer using the runtime that will return a Response after the specified duration.
511
/// The duration should be a number of milliseconds.
612
pub fn set_timer(duration: u64, context: Option<Context>) {
@@ -11,7 +17,7 @@ pub fn set_timer(duration: u64, context: Option<Context>) {
1117
"our",
1218
ProcessId::new(Some("timer"), "distro", "sys"),
1319
))
14-
.body(duration.to_le_bytes())
20+
.body(serde_json::to_vec(&TimerAction::SetTimer(duration)).unwrap())
1521
.expects_response((duration / 1000) + 1)
1622
// safe to unwrap this call when we know we've set both target and body
1723
.send()
@@ -23,7 +29,7 @@ pub fn set_timer(duration: u64, context: Option<Context>) {
2329
"our",
2430
ProcessId::new(Some("timer"), "distro", "sys"),
2531
))
26-
.body(duration.to_le_bytes())
32+
.body(serde_json::to_vec(&TimerAction::SetTimer(duration)).unwrap())
2733
.expects_response((duration / 1000) + 1)
2834
.context(context)
2935
// safe to unwrap this call when we know we've set both target and body
@@ -41,7 +47,7 @@ pub fn set_and_await_timer(duration: u64) -> Result<Message, SendError> {
4147
"our",
4248
ProcessId::new(Some("timer"), "distro", "sys"),
4349
))
44-
.body(duration.to_le_bytes())
50+
.body(serde_json::to_vec(&TimerAction::SetTimer(duration)).unwrap())
4551
// safe to unwrap this call when we know we've set both target and body
4652
.send_and_await_response((duration / 1000) + 1)
4753
.unwrap()

0 commit comments

Comments
 (0)