feat(sched): ✨ accept &str and String in schedule functions
This commit is contained in:
parent
f26691a968
commit
389e9f71f1
@ -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])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user