TasksCollection

Trait TasksCollection 

Source
pub trait TasksCollection<'c> {
    type Context: 'c;
    type Target: Send + 'static;
    type Executor: TaskExecutor + Default;

    // Required methods
    fn name() -> &'static str;
    fn handle(context: Self::Context) -> Handler<'c, Self::Target>;
}
Expand description

Describes the collection of tasks.


struct SimpleCollection;

impl<'c> TasksCollection<'c> for SimpleCollection {
    type Context = ();

    type Target = String;

    type Executor = executors::Linear;

    fn name() -> &'static str {
        "Simple collection"
    }

    fn handle(context: Self::Context) -> Handler<'c, Self::Target> {
        Handler::new(|result| println!("Received a value! {result}"))
    }
}

Required Associated Types§

Source

type Context: 'c

Context that you can pass into the result handle.

Source

type Target: Send + 'static

The vale that tasks in this collection must return.

Source

type Executor: TaskExecutor + Default

Executor that is used to control the execution process for this collection.

Required Methods§

Source

fn name() -> &'static str

Collection’s name that will be displayed.

Source

fn handle(context: Self::Context) -> Handler<'c, Self::Target>

Handle that handles task’s results. It can capture the context provided by the Context.

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§