pub struct WorkManager { /* private fields */ }Expand description
Manages the execution of asynchronous jobs.
Implementations§
Source§impl WorkManager
impl WorkManager
Source§impl WorkManager
impl WorkManager
Sourcepub fn enqueue(
&mut self,
name: &str,
job: impl Job + 'static,
overwrite: bool,
) -> bool
pub fn enqueue( &mut self, name: &str, job: impl Job + 'static, overwrite: bool, ) -> bool
Enqueues a job for execution.
If a job with the same name already exists, it will be overwritten if overwrite is true.
Sourcepub fn enqueue_periodic<J, F>(
&mut self,
name: &str,
job: J,
interval: Duration,
overwrite: bool,
on_error: F,
) -> bool
pub fn enqueue_periodic<J, F>( &mut self, name: &str, job: J, interval: Duration, overwrite: bool, on_error: F, ) -> bool
Enqueues a periodic job for execution at specified intervals.
If a job with the same name already exists, it will be overwritten if overwrite is true.
on_error is a callback that is invoked whenever the job returns an error.
The callback receives the job’s error and returns Ok to continue or
Err to stop the periodic execution and finish the task.
Trait Implementations§
Source§impl Drop for WorkManager
impl Drop for WorkManager
Auto Trait Implementations§
impl Freeze for WorkManager
impl RefUnwindSafe for WorkManager
impl Send for WorkManager
impl Sync for WorkManager
impl Unpin for WorkManager
impl UnsafeUnpin for WorkManager
impl UnwindSafe for WorkManager
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