Skip to main content

Job

Trait Job 

Source
pub trait Job: Send {
    // Required method
    fn run(&self) -> Result<(), String>;

    // Provided method
    fn name(&self) -> &str { ... }
}
Available on crate feature jobs only.
Expand description

A unit of background work.

Implement run directly for named, stateful jobs, or rely on the blanket implementation below to submit a plain closure.

Required Methods§

Source

fn run(&self) -> Result<(), String>

Perform the work. Return Err(message) to trigger a retry (subject to the queue’s retry policy).

Provided Methods§

Source

fn name(&self) -> &str

Human-readable name used in retry/failure log lines. Defaults to "job".

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<F> Job for F
where F: Fn() -> Result<(), String> + Send,