SharedService

Trait SharedService 

Source
pub trait SharedService: Any {
    // Required methods
    fn init<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Res<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn main<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Res<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn repeat<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Res<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn catch<'life0, 'async_trait>(
        &'life0 self,
        error: Error,
    ) -> Pin<Box<dyn Future<Output = Res<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn abort<'life0, 'async_trait>(
        &'life0 self,
        error: Error,
    ) -> Pin<Box<dyn Future<Output = Res<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn to_dyn(self) -> (DynamicSharedService, Weak<Self>)
       where Self: Sized + Sync + Send { ... }
}
Expand description

Services with a reference to self. Can be shared among threads. Useful for monitoring services and others.

Required Methods§

Source

fn init<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Res<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

only runs once at the start

Source

fn main<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Res<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

loops

Source

fn repeat<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Res<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

runs after main if main or repeat did not return errors

Source

fn catch<'life0, 'async_trait>( &'life0 self, error: Error, ) -> Pin<Box<dyn Future<Output = Res<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

runs after main if main returned an error

Source

fn abort<'life0, 'async_trait>( &'life0 self, error: Error, ) -> Pin<Box<dyn Future<Output = Res<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

run if catch was not successful

Provided Methods§

Source

fn to_dyn(self) -> (DynamicSharedService, Weak<Self>)
where Self: Sized + Sync + Send,

Implementors§