pub struct Task<R: Runtime> {
pub schedule: Box<dyn Schedule + Send>,
pub run: Box<RunTaskFn<R>>,
}Expand description
Fields§
§schedule: Box<dyn Schedule + Send>§run: Box<RunTaskFn<R>>Implementations§
Source§impl Task<AsyncStd>
impl Task<AsyncStd>
Source§impl Task<Tokio>
impl Task<Tokio>
Source§impl Task<Promise>
impl Task<Promise>
Source§impl<R: Runtime> Task<R>
impl<R: Runtime> Task<R>
Sourcepub fn new<S, F, A>(schedule: S, run: F) -> Selfwhere
S: IntoSchedule,
F: IntoRunTaskFn<R, A>,
pub fn new<S, F, A>(schedule: S, run: F) -> Selfwhere
S: IntoSchedule,
F: IntoRunTaskFn<R, A>,
Create a new task.
The run function could have the following signature:
Fn(<&mut Runtime>?, ..Args)
the Args could be any type that implements TaskRunArg.
For now, these types are supported:
TaskRun: information about this run.TaskUid: the task unique identifier.Dtu: the time when this task is scheduled to run.
For example, you can call this function like this:
let task = Task::<Local>::new(now(), |time: Dtu, id: TaskUid| {
println!("Time: {time}, Uid: {id}");
});Source§impl<R: AsyncRuntime> Task<R>
impl<R: AsyncRuntime> Task<R>
Sourcepub fn new_async<S, F, A, Fut>(schedule: S, run: F) -> Selfwhere
S: IntoSchedule,
F: IntoRunTaskFn<R, Async<A, Fut>>,
pub fn new_async<S, F, A, Fut>(schedule: S, run: F) -> Selfwhere
S: IntoSchedule,
F: IntoRunTaskFn<R, Async<A, Fut>>,
This is basically the same as Task::new but with more hint for compiler that this is an async function.
Trait Implementations§
Auto Trait Implementations§
impl<R> Freeze for Task<R>
impl<R> !RefUnwindSafe for Task<R>
impl<R> Send for Task<R>
impl<R> !Sync for Task<R>
impl<R> Unpin for Task<R>
impl<R> !UnwindSafe for Task<R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more