pub trait Service:
Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &str;
fn schedule(&self) -> Schedule;
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 ServiceContext,
) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
// Provided methods
fn start<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 ServiceContext,
) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
}Expand description
Work a ServiceHost runs in the background.
Required Methods§
fn name(&self) -> &str
fn schedule(&self) -> Schedule
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 ServiceContext,
) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Provided Methods§
Sourcefn start<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 ServiceContext,
) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn start<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 ServiceContext,
) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Once, before any service’s first run. A failure is reported and the service still runs.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".