From b26cb1d982b514b36453f847cd8d1b88054c6f5a Mon Sep 17 00:00:00 2001 From: Adrien Date: Fri, 5 Apr 2024 17:23:48 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9E=95=20Use=20async-std=20to=20sleep=20asyn?= =?UTF-8?q?chronously=20(previously=20done=20with=20tokio)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 1 + src/main.rs | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9ebf1f6..de30a91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,7 @@ reqwest = "0.11.24" validator = { version = "0.17.0", features = ["derive"] } const_format = "0.2.32" zxcvbn = "2.2.2" +async-std = "1.12.0" [build] target = "x86_64-unknown-linux-gnu" diff --git a/src/main.rs b/src/main.rs index c47a94a..fea131e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,9 @@ mod infrastructure; mod ui; mod utils; +use std::time::Duration; + +use async_std::task; use dioxus::prelude::*; use tokio::time::{sleep, Duration}; use tracing::{debug, Level}; @@ -24,8 +27,8 @@ fn app() -> Element { // Dummy timer simulating the loading of the application let _: Coroutine<()> = use_coroutine(|_: UnboundedReceiver<_>| async move { debug!("Not ready"); - sleep(Duration::from_secs(3)).await; - // sleep(Duration::from_secs(0)).await; + task::sleep(Duration::from_secs(3)).await; + // task::sleep(Duration::from_secs(0)).await; debug!("Ready"); ready.set(true); });