feat(sched): accept &str and String in schedule functions

This commit is contained in:
Lucas Colombo 2024-04-17 08:30:51 -03:00
parent f26691a968
commit 389e9f71f1
Signed by: lucas
GPG Key ID: EF34786CFEFFAE35
2 changed files with 7 additions and 3 deletions

View File

@ -88,10 +88,12 @@ impl Scheduler {
/// 🧉 » schedule a task /// 🧉 » schedule a task
/// ///
/// schedules a task to be executed at times determined by the provided rules. /// schedules a task to be executed at times determined by the provided rules.
pub fn schedule<F>(&mut self, name: &str, action: F, rules: SchedulingRule) -> TaskHandler pub fn schedule<F, Str>(&mut self, name: Str, action: F, rules: SchedulingRule) -> TaskHandler
where where
F: FnMut() + Send + Sync + 'static, F: FnMut() + Send + Sync + 'static,
Str: AsRef<str>,
{ {
let name = name.as_ref();
self.schedule_many_rules(name, action, vec![rules]) self.schedule_many_rules(name, action, vec![rules])
} }

View File

@ -80,16 +80,18 @@ impl Scheduler {
/// 🧉 » schedule a task /// 🧉 » schedule a task
/// ///
/// schedules a task to be executed at times determined by the provided rules. /// schedules a task to be executed at times determined by the provided rules.
pub async fn schedule<F, Fut>( pub async fn schedule<F, Fut, Str>(
&mut self, &mut self,
name: &str, name: Str,
func: F, func: F,
rules: SchedulingRule, rules: SchedulingRule,
) -> TaskHandler ) -> TaskHandler
where where
F: FnMut() -> Fut + Send + 'static, F: FnMut() -> Fut + Send + 'static,
Fut: Future<Output = ()> + Send + 'static, Fut: Future<Output = ()> + Send + 'static,
Str: AsRef<str>,
{ {
let name = name.as_ref();
self.schedule_many_rules(name, func, vec![rules]).await self.schedule_many_rules(name, func, vec![rules]).await
} }