From 389e9f71f148f11585e171a1b37dd5bb402f9b5f Mon Sep 17 00:00:00 2001 From: Lucas Colombo Date: Wed, 17 Apr 2024 08:30:51 -0300 Subject: [PATCH] =?UTF-8?q?feat(sched):=20=E2=9C=A8=20accept=20&str=20and?= =?UTF-8?q?=20String=20in=20schedule=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/sched/scheduler/threads.rs | 4 +++- lib/sched/scheduler/tokio.rs | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/sched/scheduler/threads.rs b/lib/sched/scheduler/threads.rs index 83ad267..6f6a9e1 100644 --- a/lib/sched/scheduler/threads.rs +++ b/lib/sched/scheduler/threads.rs @@ -88,10 +88,12 @@ impl Scheduler { /// 🧉 » schedule a task /// /// schedules a task to be executed at times determined by the provided rules. - pub fn schedule(&mut self, name: &str, action: F, rules: SchedulingRule) -> TaskHandler + pub fn schedule(&mut self, name: Str, action: F, rules: SchedulingRule) -> TaskHandler where F: FnMut() + Send + Sync + 'static, + Str: AsRef, { + let name = name.as_ref(); self.schedule_many_rules(name, action, vec![rules]) } diff --git a/lib/sched/scheduler/tokio.rs b/lib/sched/scheduler/tokio.rs index 58d97dd..f92d841 100644 --- a/lib/sched/scheduler/tokio.rs +++ b/lib/sched/scheduler/tokio.rs @@ -80,16 +80,18 @@ impl Scheduler { /// 🧉 » schedule a task /// /// schedules a task to be executed at times determined by the provided rules. - pub async fn schedule( + pub async fn schedule( &mut self, - name: &str, + name: Str, func: F, rules: SchedulingRule, ) -> TaskHandler where F: FnMut() -> Fut + Send + 'static, Fut: Future + Send + 'static, + Str: AsRef, { + let name = name.as_ref(); self.schedule_many_rules(name, func, vec![rules]).await }