Skip to main content

ControlFactory

Trait ControlFactory 

Source
pub trait ControlFactory:
    Debug
    + Send
    + Sync {
    // Required method
    fn control(
        &self,
        mode: StartMode,
    ) -> Result<Box<dyn ServiceControl>, ServiceError>;

    // Provided methods
    fn installed_definition(&self, _path: &Path) -> Option<String> { ... }
    fn unattended_login(&self) -> Option<UnattendedLogin> { ... }
}
Expand description

Chooses the control for a start mode.

The indirection is what makes ServiceOperations testable: production hands it HostControls, every test in this file hands it RecordingControls, and neither knows the difference.

Required Methods§

Source

fn control( &self, mode: StartMode, ) -> Result<Box<dyn ServiceControl>, ServiceError>

The control for one start-mode domain.

§Errors

ServiceError::Control when this host has no manager for that domain.

Provided Methods§

Source

fn installed_definition(&self, _path: &Path) -> Option<String>

The text of an installed definition file, for drift detection. None when there is none to read. The default reads nothing, so a double never reports the real host’s unit as its own.

Source

fn unattended_login(&self) -> Option<UnattendedLogin>

Whether this Mac signs somebody in after a restart, and whether FileVault holds it at the unlock screen. None where the platform has no such probe; the default probes nothing, for the same reason as Self::installed_definition.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§