[][src]Trait tari_service_framework::ServiceInitializer

pub trait ServiceInitializer {
    type Future: Future<Output = Result<(), ServiceInitializationError>>;
    fn initialize(
        &mut self,
        executor: Handle,
        handles_fut: ServiceHandlesFuture,
        shutdown: ShutdownSignal
    ) -> Self::Future; fn boxed(self) -> BoxedServiceInitializer
    where
        Self: Sized + Send + 'static,
        Self::Future: Send + 'static
, { ... } }

Implementors of this trait will initialize a service The StackBuilder builds impls of this trait.

Associated Types

type Future: Future<Output = Result<(), ServiceInitializationError>>

The future returned from the initialize function

Loading content...

Required methods

fn initialize(
    &mut self,
    executor: Handle,
    handles_fut: ServiceHandlesFuture,
    shutdown: ShutdownSignal
) -> Self::Future

Async initialization code for a service

Loading content...

Provided methods

fn boxed(self) -> BoxedServiceInitializer where
    Self: Sized + Send + 'static,
    Self::Future: Send + 'static, 

Create a boxed version of this ServiceInitializer.

Loading content...

Implementors

impl<TFunc, TFut> ServiceInitializer for TFunc where
    TFunc: FnMut(Handle, ServiceHandlesFuture, ShutdownSignal) -> TFut,
    TFut: Future<Output = Result<(), ServiceInitializationError>>, 
[src]

Implementation of ServiceInitializer for any function matching the signature of ServiceInitializer::initialize This allows the following "short-hand" syntax to be used:

This code runs with edition 2018
let my_initializer = |executor: runtime::Handle, handles_fut: ServiceHandlesFuture| {
    // initialization code
    futures::future::ready(Result::<_, ()>::Ok(()))
};

type Future = TFut

Loading content...