Skip to main content

Job

Trait Job 

Source
pub trait Job:
    Send
    + Sync
    + Serialize
    + for<'de> Deserialize<'de> {
    // Required method
    fn perform<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = JobResult> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn max_retries(&self) -> u32 { ... }
    fn backoff(&self, attempt: u32) -> Duration { ... }
    fn priority(&self) -> i32 { ... }
    fn name(&self) -> &'static str { ... }
}
Expand description

Trait for background jobs

Required Methods§

Source

fn perform<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = JobResult> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Perform the job

Provided Methods§

Source

fn max_retries(&self) -> u32

Maximum number of retries

Source

fn backoff(&self, attempt: u32) -> Duration

Backoff duration for retries

Source

fn priority(&self) -> i32

Job priority (higher = more important)

Source

fn name(&self) -> &'static str

Job name for identification

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§