pub trait ServiceControl: Debug {
// Required methods
fn manager(&self) -> DefinitionKind;
fn install(
&self,
plan: &InstallPlan,
) -> Result<ServiceDefinition, ServiceError>;
fn uninstall(
&self,
identity: &ServiceIdentity,
) -> Result<bool, ServiceError>;
fn query(
&self,
identity: &ServiceIdentity,
) -> Result<Option<Registration>, ServiceError>;
fn start(&self, identity: &ServiceIdentity) -> Result<(), ServiceError>;
fn stop(&self, identity: &ServiceIdentity) -> Result<bool, ServiceError>;
}Expand description
One platform’s service manager, for one start-mode domain.
Every method takes the identity rather than storing it, so one control can answer about the product’s registration and about a test fixture’s without either being able to reach the other by accident.
Required Methods§
Sourcefn manager(&self) -> DefinitionKind
fn manager(&self) -> DefinitionKind
Which manager this is.
Sourcefn install(&self, plan: &InstallPlan) -> Result<ServiceDefinition, ServiceError>
fn install(&self, plan: &InstallPlan) -> Result<ServiceDefinition, ServiceError>
Registers the plan, returning the definition that was applied.
§Errors
Sourcefn uninstall(&self, identity: &ServiceIdentity) -> Result<bool, ServiceError>
fn uninstall(&self, identity: &ServiceIdentity) -> Result<bool, ServiceError>
Deregisters. Returns whether there was a registration to remove.
Removes the registration and nothing else. No implementation of this
method may delete a directory, a database, a secret, or a cache;
05-infrastructure.md item 5 is a property of every backend, not a
check somewhere above them.
§Errors
Sourcefn query(
&self,
identity: &ServiceIdentity,
) -> Result<Option<Registration>, ServiceError>
fn query( &self, identity: &ServiceIdentity, ) -> Result<Option<Registration>, ServiceError>
Sourcefn start(&self, identity: &ServiceIdentity) -> Result<(), ServiceError>
fn start(&self, identity: &ServiceIdentity) -> Result<(), ServiceError>
Starts it now, without waiting for the next boot or logon.
§Errors
ServiceError::Control, ServiceError::NeedsElevation, or
ServiceError::NotInstalled.
Sourcefn stop(&self, identity: &ServiceIdentity) -> Result<bool, ServiceError>
fn stop(&self, identity: &ServiceIdentity) -> Result<bool, ServiceError>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".