Skip to main content

ManagedService

Trait ManagedService 

Source
pub trait ManagedService: Send + Sync {
    // Required methods
    fn start<'life0, 'life1, 'async_trait>(
        &'life0 self,
        context: &'life1 ServiceContext,
    ) -> Pin<Box<dyn Future<Output = RuntimeResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn stop<'life0, 'life1, 'async_trait>(
        &'life0 self,
        context: &'life1 ServiceContext,
    ) -> Pin<Box<dyn Future<Output = RuntimeResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn serve<'life0, 'async_trait>(
        &'life0 self,
        context: ServiceContext,
    ) -> Pin<Box<dyn Future<Output = RuntimeResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn status(&self) -> ServiceStatus;
    fn snapshot<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = RuntimeResult<ServiceSnapshot>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn register_devices(&self, _registry: &DeviceRegistry) -> RuntimeResult<()> { ... }
}
Expand description

Shared lifecycle contract for protocol services.

Required Methods§

Source

fn start<'life0, 'life1, 'async_trait>( &'life0 self, context: &'life1 ServiceContext, ) -> Pin<Box<dyn Future<Output = RuntimeResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Performs any non-blocking startup work.

Source

fn stop<'life0, 'life1, 'async_trait>( &'life0 self, context: &'life1 ServiceContext, ) -> Pin<Box<dyn Future<Output = RuntimeResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Requests a graceful stop.

Source

fn serve<'life0, 'async_trait>( &'life0 self, context: ServiceContext, ) -> Pin<Box<dyn Future<Output = RuntimeResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Runs the service until completion or cancellation.

Source

fn status(&self) -> ServiceStatus

Returns the current status.

Source

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

Returns a structured snapshot.

Provided Methods§

Source

fn register_devices(&self, _registry: &DeviceRegistry) -> RuntimeResult<()>

Publishes any controller-visible device ports exposed by this service.

Implementors§