Trait fuel_core_services::RunnableService

source ·
pub trait RunnableService: Send {
    type SharedData: Clone + Send + Sync;
    type Task: RunnableTask;
    type TaskParams: Send;

    const NAME: &'static str;

    // Required methods
    fn shared_data(&self) -> Self::SharedData;
    fn into_task<'life0, 'async_trait>(
        self,
        state_watcher: &'life0 StateWatcher,
        params: Self::TaskParams,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Task>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait used by ServiceRunner to encapsulate the business logic tasks for a service.

Required Associated Types§

source

type SharedData: Clone + Send + Sync

Service specific shared data. This is used when you have data that needs to be shared by one or more tasks. It is the implementors responsibility to ensure cloning this type is shallow and doesn’t provide a full duplication of data that is meant to be shared between asynchronous processes.

source

type Task: RunnableTask

The initialized runnable task type.

source

type TaskParams: Send

Optional parameters used to when initializing into task.

Required Associated Constants§

source

const NAME: &'static str

The name of the runnable service, used for namespacing error messages.

Required Methods§

source

fn shared_data(&self) -> Self::SharedData

A cloned instance of the shared data

source

fn into_task<'life0, 'async_trait>( self, state_watcher: &'life0 StateWatcher, params: Self::TaskParams, ) -> Pin<Box<dyn Future<Output = Result<Self::Task>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Converts the service into a runnable task before the main run loop.

The state is a State watcher of the service. Some tasks may handle state changes on their own.

Object Safety§

This trait is not object safe.

Implementors§