Trait service_manager::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<()>;
}
Expand description
Interface for a service manager
Required Methods§
sourcefn available(&self) -> Result<bool>
fn available(&self) -> Result<bool>
Determines if the service manager exists (e.g. is launchd
available on the system?) and
can be used
sourcefn install(&self, ctx: ServiceInstallCtx) -> Result<()>
fn install(&self, ctx: ServiceInstallCtx) -> Result<()>
Installs a new service using the manager
sourcefn uninstall(&self, ctx: ServiceUninstallCtx) -> Result<()>
fn uninstall(&self, ctx: ServiceUninstallCtx) -> Result<()>
Uninstalls an existing service using the manager
sourcefn start(&self, ctx: ServiceStartCtx) -> Result<()>
fn start(&self, ctx: ServiceStartCtx) -> Result<()>
Starts a service using the manager
sourcefn stop(&self, ctx: ServiceStopCtx) -> Result<()>
fn stop(&self, ctx: ServiceStopCtx) -> Result<()>
Stops a running service using the manager
sourcefn level(&self) -> ServiceLevel
fn level(&self) -> ServiceLevel
Returns the current target level for the manager
sourcefn set_level(&mut self, level: ServiceLevel) -> Result<()>
fn set_level(&mut self, level: ServiceLevel) -> Result<()>
Sets the target level for the manager
Implementations§
source§impl dyn ServiceManager
impl dyn ServiceManager
sourcepub fn target_or_native(
kind: impl Into<Option<ServiceManagerKind>>
) -> Result<Box<dyn ServiceManager>>
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
sourcepub fn target(kind: ServiceManagerKind) -> Box<dyn ServiceManager>
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
sourcepub fn native() -> Result<Box<dyn ServiceManager>>
pub fn native() -> Result<Box<dyn ServiceManager>>
Attempts to select a native service manager for the current operating system
- For MacOS, this will use
LaunchdServiceManager
- For Windows, this will use
ScServiceManager
- For BSD variants, this will use
RcdServiceManager
- For Linux variants, this will use either
SystemdServiceManager
orOpenRcServiceManager