Trait ora::Task

source ·
pub trait Task: Serialize + DeserializeOwned + Send + Sync + 'static {
    type Output: Serialize + DeserializeOwned + Send + Sync + 'static;

    // Provided methods
    fn worker_selector() -> WorkerSelector { ... }
    fn format() -> TaskDataFormat { ... }
    fn timeout() -> TimeoutPolicy { ... }
    fn task(&self) -> TaskDefinition<Self>
       where Self: Serialize { ... }
}
Expand description

A strongly-typed serializable task type.

Required Associated Types§

source

type Output: Serialize + DeserializeOwned + Send + Sync + 'static

The output of the task.

Provided Methods§

source

fn worker_selector() -> WorkerSelector

The worker selector of the given type, defaults to the type’s name without the module path and any generics.

source

fn format() -> TaskDataFormat

Input and output data format to be used for serialization.

Defaults to TaskDataFormat::Json.

source

fn timeout() -> TimeoutPolicy

Return the default timeout policy.

Defaults to no timeout.

source

fn task(&self) -> TaskDefinition<Self>where Self: Serialize,

Create a task definition that contains the worker selector returned by Task::worker_selector and self serialized as the task data.

Panics

Panics if Task::format is TaskDataFormat::Unknown, or serialization fails.

Implementors§