Skip to main content

ServiceControl

Trait ServiceControl 

Source
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§

Source

fn manager(&self) -> DefinitionKind

Which manager this is.

Source

fn install(&self, plan: &InstallPlan) -> Result<ServiceDefinition, ServiceError>

Registers the plan, returning the definition that was applied.

§Errors

ServiceError::Control or ServiceError::NeedsElevation.

Source

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

ServiceError::Control or ServiceError::NeedsElevation.

Source

fn query( &self, identity: &ServiceIdentity, ) -> Result<Option<Registration>, ServiceError>

What the manager knows about this registration, if anything.

§Errors

ServiceError::Control.

Source

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.

Source

fn stop(&self, identity: &ServiceIdentity) -> Result<bool, ServiceError>

Stops it. Returns whether it was running.

§Errors

As ServiceControl::start.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§