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§
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.
sourcetype Task: RunnableTask
type Task: RunnableTask
The initialized runnable task type.
sourcetype TaskParams: Send
type TaskParams: Send
Optional parameters used to when initializing into task.
Required Associated Constants§
Required Methods§
A cloned instance of the shared data
sourcefn 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,
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.