ServiceManager

Trait ServiceManager 

Source
pub trait ServiceManager {
    // Required methods
    fn available(&self) -> Result<bool>;
    fn install(&self, ctx: ServiceInstallCtx) -> Result<()>;
    fn uninstall(&self, ctx: ServiceUninstallCtx) -> Result<()>;
    fn start(&self, ctx: ServiceStartCtx) -> Result<()>;
    fn stop(&self, ctx: ServiceStopCtx) -> Result<()>;
    fn level(&self) -> ServiceLevel;
    fn set_level(&mut self, level: ServiceLevel) -> Result<()>;
    fn status(&self, ctx: ServiceStatusCtx) -> Result<ServiceStatus>;
}
Expand description

Interface for a service manager

Required Methods§

Source

fn available(&self) -> Result<bool>

Determines if the service manager exists (e.g. is launchd available on the system?) and can be used

Source

fn install(&self, ctx: ServiceInstallCtx) -> Result<()>

Installs a new service using the manager

Source

fn uninstall(&self, ctx: ServiceUninstallCtx) -> Result<()>

Uninstalls an existing service using the manager

Source

fn start(&self, ctx: ServiceStartCtx) -> Result<()>

Starts a service using the manager

Source

fn stop(&self, ctx: ServiceStopCtx) -> Result<()>

Stops a running service using the manager

Source

fn level(&self) -> ServiceLevel

Returns the current target level for the manager

Source

fn set_level(&mut self, level: ServiceLevel) -> Result<()>

Sets the target level for the manager

Source

fn status(&self, ctx: ServiceStatusCtx) -> Result<ServiceStatus>

Return the service status info

Implementations§

Source§

impl dyn ServiceManager

Source

pub fn target_or_native( kind: impl Into<Option<ServiceManagerKind>>, ) -> Result<Box<dyn ServiceManager>>

Creates a new service using the specified type, falling back to selecting based on native service manager for the current operating system if no type provided

Source

pub fn target(kind: ServiceManagerKind) -> Box<dyn ServiceManager>

Creates a new service manager targeting the specific service manager kind using the default service manager instance

Source

pub fn native() -> Result<Box<dyn ServiceManager>>

Attempts to select a native service manager for the current operating system

Trait Implementations§

Source§

impl<'a, S> From<S> for Box<dyn ServiceManager + 'a>
where S: ServiceManager + 'a,

Source§

fn from(service_manager: S) -> Self

Converts to this type from the input type.

Implementors§