Job

Trait Job 

Source
pub trait Job:
    Send
    + Sync
    + Sized {
    type Output: Send + Sync + 'static;
    type Error: Send + Sync + 'static + Into<Box<dyn Error + Send + Sync>>;

    // Required method
    fn run(
        self,
    ) -> impl Future<Output = Result<Self::Output, Self::Error>> + Send + Sync;

    // Provided method
    fn then<F, Next>(self, next: F) -> Sequence<Self, Next, F>
       where F: FnOnce(Result<Self::Output, Self::Error>) -> Result<Next, Self::Error> + Send + Sync,
             Next: Job<Error = Self::Error> { ... }
}
Expand description

A job that can be run asynchronously.

Required Associated Types§

Source

type Output: Send + Sync + 'static

Source

type Error: Send + Sync + 'static + Into<Box<dyn Error + Send + Sync>>

Job-specific error type. Must be convertible into a boxed error so WorkManager does not need to be generic over the error.

Required Methods§

Source

fn run( self, ) -> impl Future<Output = Result<Self::Output, Self::Error>> + Send + Sync

Runs the job and returns the result.

Provided Methods§

Source

fn then<F, Next>(self, next: F) -> Sequence<Self, Next, F>
where F: FnOnce(Result<Self::Output, Self::Error>) -> Result<Next, Self::Error> + Send + Sync, Next: Job<Error = Self::Error>,

Turns this job into a sequence where the next job depends on the output of this job. Does not execute anything until the entire sequence is run.

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.

Implementors§

Source§

impl<Prev, Next, F> Job for Sequence<Prev, Next, F>
where Prev: Job, F: FnOnce(Result<Prev::Output, Prev::Error>) -> Result<Next, Prev::Error> + Send + Sync, Next: Job<Error = Prev::Error>,

Source§

type Output = <Next as Job>::Output

Source§

type Error = <Prev as Job>::Error