WorkManager

Struct WorkManager 

Source
pub struct WorkManager<E> { /* private fields */ }
Expand description

Manages the execution of asynchronous jobs.

Implementations§

Source§

impl<E> WorkManager<E>

Source

pub fn new() -> Self

Creates a new WorkManager.

Source

pub fn cancel(&mut self, name: &str)

Cancels an enqueued job by the given name.

Source

pub fn cancel_all(&mut self)

Cancels all enqueued jobs.

Source§

impl<E: Debug + Send + Sync + 'static> WorkManager<E>

Source

pub fn enqueue( &mut self, name: &str, job: impl Job<Error = E> + '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.

Source

pub fn enqueue_periodic( &mut self, name: &str, job: impl Job<Error = E> + Clone + 'static, interval: Duration, overwrite: bool, panic: bool, ) -> 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. If panic is true, the periodic job will cancel and return the error upon encountering one.

Trait Implementations§

Source§

impl<E> Drop for WorkManager<E>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<E> Freeze for WorkManager<E>

§

impl<E> RefUnwindSafe for WorkManager<E>

§

impl<E> Send for WorkManager<E>
where E: Send,

§

impl<E> Sync for WorkManager<E>
where E: Send,

§

impl<E> Unpin for WorkManager<E>

§

impl<E> UnwindSafe for WorkManager<E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.