Skip to main content

Task

Trait Task 

Source
pub trait Task<S: Clone>:
    Send
    + Sync
    + Debug {
    // Required methods
    fn kind() -> &'static str
       where Self: Sized;
    fn build(id: TaskId, context: &str) -> ClResult<Arc<dyn Task<S>>>
       where Self: Sized;
    fn serialize(&self) -> String;
    fn run<'life0, 'life1, 'async_trait>(
        &'life0 self,
        state: &'life1 S,
    ) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn kind_of(&self) -> &'static str;

    // Provided method
    fn on_failed<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _state: &'life1 S,
        _attempts: u16,
        _last_error: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}

Required Methods§

Source

fn kind() -> &'static str
where Self: Sized,

Source

fn build(id: TaskId, context: &str) -> ClResult<Arc<dyn Task<S>>>
where Self: Sized,

Source

fn serialize(&self) -> String

Source

fn run<'life0, 'life1, 'async_trait>( &'life0 self, state: &'life1 S, ) -> Pin<Box<dyn Future<Output = ClResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

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

Provided Methods§

Source

fn on_failed<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _state: &'life1 S, _attempts: u16, _last_error: &'life2 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Called when the task transitions to Failed after exhausting retries (or on the very first failure when no retry policy is set). Lets the task perform irreversible cleanup — e.g. mark a related domain row as permanently failed — that should not happen on retryable failures. Default: no-op.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§