Skip to main content

ServiceManager

Trait ServiceManager 

Source
pub trait ServiceManager: Send + Sync {
    // Required methods
    fn install<'life0, 'life1, 'async_trait>(
        &'life0 self,
        service: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn uninstall<'life0, 'life1, 'async_trait>(
        &'life0 self,
        service: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn start<'life0, 'life1, 'async_trait>(
        &'life0 self,
        service: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn stop<'life0, 'life1, 'async_trait>(
        &'life0 self,
        service: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn is_active<'life0, 'life1, 'async_trait>(
        &'life0 self,
        service: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn reload<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn spawn<'life0, 'async_trait>(
        &'life0 self,
        service: Box<dyn Spawnable>,
    ) -> Pin<Box<dyn Future<Output = Result<SpawnedService>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn enable<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _service: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn ensure<'life0, 'life1, 'async_trait>(
        &'life0 self,
        service: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Service lifecycle management trait

Abstracts over systemd (Linux) vs standalone (process spawn) for service management.

Required Methods§

Source

fn install<'life0, 'life1, 'async_trait>( &'life0 self, service: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Install unit files (idempotent)

For systemd, this writes socket/service unit files to ~/.config/systemd/user/ For standalone mode, this is a no-op.

Source

fn uninstall<'life0, 'life1, 'async_trait>( &'life0 self, service: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Uninstall unit files

Stops the service, disables units, and removes unit files.

Source

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

Start a service

Source

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

Stop a service

Source

fn is_active<'life0, 'life1, 'async_trait>( &'life0 self, service: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if service is running

Source

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

Reload daemon configuration

For systemd, this calls daemon-reload. For standalone mode, this is a no-op.

Source

fn spawn<'life0, 'async_trait>( &'life0 self, service: Box<dyn Spawnable>, ) -> Pin<Box<dyn Future<Output = Result<SpawnedService>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Spawn a service (unified API for inproc and systemd)

For inproc mode, spawns in current process. For systemd mode, ensures systemd unit is running.

Provided Methods§

Source

fn enable<'life0, 'life1, 'async_trait>( &'life0 self, _service: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Enable a service for autostart at boot (systemctl enable)

For systemd, this calls enable_unit_files so the unit starts at boot. For standalone mode, this is a no-op.

Source

fn ensure<'life0, 'life1, 'async_trait>( &'life0 self, service: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Ensure service is available (install + start if needed)

This is the main entry point for CLI commands that need services.

Implementors§