WorkerOutputHandler

Trait WorkerOutputHandler 

Source
pub trait WorkerOutputHandler {
    // Required method
    fn handle_result(
        self,
        client: Client,
        job: ActivatedJob,
    ) -> impl Future<Output = ()> + Send + 'static;
}
Expand description

A trait for handling the output of job processing.

This trait defines how different output types should be handled after job processing is complete. It provides built-in implementations for common result types.

§Type Parameters

  • T - The type of output produced by the job handler

§Examples

impl WorkerOutputHandler for MyStruct {
    fn handle_result(self, client: Client, job: ActivatedJob) ->  impl Future<Output = ()> + Send + 'static {
        if let Ok(req) = client
                .complete_job()
                .with_job_key(job.key())
                .with_variables(self)
                {
                    let _ = req.send().await;
                }
    }

Required Methods§

Source

fn handle_result( self, client: Client, job: ActivatedJob, ) -> impl Future<Output = ()> + Send + 'static

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl WorkerOutputHandler for ()

Source§

fn handle_result( self, _client: Client, _job: ActivatedJob, ) -> impl Future<Output = ()> + Send + 'static

Source§

impl<Output, T> WorkerOutputHandler for Result<Output, WorkerError<T>>
where Output: Serialize + Send + 'static, T: Serialize + Send + 'static,

Source§

async fn handle_result(self, client: Client, job: ActivatedJob)

Implementors§