summaryrefslogtreecommitdiff
path: root/runtime/ops/timers.rs
diff options
context:
space:
mode:
authorcrowlKats <13135287+crowlKats@users.noreply.github.com>2021-03-18 19:42:01 +0100
committerGitHub <noreply@github.com>2021-03-18 14:42:01 -0400
commitb59151f39eba2ddcfe9448dfecd043046d7a0852 (patch)
tree06591bbf8e26910f808f20c4bbeaf9eaf764339c /runtime/ops/timers.rs
parent62716422b9f57b11f3a0afb01f5011b63702226d (diff)
move runtime ops to serde ops (#9828)
Diffstat (limited to 'runtime/ops/timers.rs')
-rw-r--r--runtime/ops/timers.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/runtime/ops/timers.rs b/runtime/ops/timers.rs
index 7c1718ce7..445b7366c 100644
--- a/runtime/ops/timers.rs
+++ b/runtime/ops/timers.rs
@@ -15,7 +15,6 @@ use deno_core::futures;
use deno_core::futures::channel::oneshot;
use deno_core::futures::FutureExt;
use deno_core::futures::TryFutureExt;
-use deno_core::serde_json;
use deno_core::serde_json::json;
use deno_core::serde_json::Value;
use deno_core::BufVec;
@@ -94,7 +93,7 @@ fn op_global_timer_stop(
}
#[derive(Deserialize)]
-struct GlobalTimerArgs {
+pub struct GlobalTimerArgs {
timeout: u64,
}
@@ -105,12 +104,12 @@ struct GlobalTimerArgs {
//
// See https://github.com/denoland/deno/issues/7599 for more
// details.
+#[allow(clippy::unnecessary_wraps)]
fn op_global_timer_start(
state: &mut OpState,
- args: Value,
+ args: GlobalTimerArgs,
_zero_copy: &mut [ZeroCopyBuf],
) -> Result<Value, AnyError> {
- let args: GlobalTimerArgs = serde_json::from_value(args)?;
let val = args.timeout;
let deadline = Instant::now() + Duration::from_millis(val);
@@ -170,17 +169,17 @@ fn op_now(
}
#[derive(Deserialize)]
-struct SleepArgs {
+pub struct SleepArgs {
millis: u64,
}
+#[allow(clippy::unnecessary_wraps)]
fn op_sleep_sync(
state: &mut OpState,
- args: Value,
+ args: SleepArgs,
_zero_copy: &mut [ZeroCopyBuf],
) -> Result<Value, AnyError> {
super::check_unstable(state, "Deno.sleepSync");
- let args: SleepArgs = serde_json::from_value(args)?;
sleep(Duration::from_millis(args.millis));
Ok(json!({}))
}