Skip to main content

Task

Trait Task 

Source
pub trait Task:
    Send
    + Sync
    + Serialize
    + for<'de> Deserialize<'de>
    + Debug {
    // Required methods
    fn execute<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = TaskResult> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn name(&self) -> &str;

    // Provided methods
    fn max_retries(&self) -> u32 { ... }
    fn timeout_seconds(&self) -> u64 { ... }
    fn priority(&self) -> TaskPriority { ... }
    fn resource_requirements(&self) -> TaskResourceRequirements { ... }
    fn retry_delay_strategy(&self) -> RetryStrategy { ... }
}
Expand description

Enhanced Task trait with improved type safety and async characteristics

Required Methods§

Source

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

Execute the task with comprehensive error handling

Source

fn name(&self) -> &str

Task identifier for registration and execution

Provided Methods§

Source

fn max_retries(&self) -> u32

Maximum retry attempts (default: 3)

Source

fn timeout_seconds(&self) -> u64

Task timeout in seconds (default: 300s/5min)

Source

fn priority(&self) -> TaskPriority

Task priority level (default: Normal)

Source

fn resource_requirements(&self) -> TaskResourceRequirements

Estimate task resource requirements for better scheduling

Source

fn retry_delay_strategy(&self) -> RetryStrategy

Custom retry delay strategy

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§