|
@ -4,13 +4,13 @@ use std::fmt; |
|
|
use crate::command_runner::CommandRunner;
|
|
|
use crate::command_runner::CommandRunner;
|
|
|
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
|
|
|
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
|
|
|
|
|
|
|
|
|
pub struct ReloadService<'a, C: CommandRunner> {
|
|
|
|
|
|
service: &'a str,
|
|
|
|
|
|
|
|
|
pub struct ReloadService<'a, S, C: CommandRunner> {
|
|
|
|
|
|
service: S,
|
|
|
command_runner: &'a C,
|
|
|
command_runner: &'a C,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl<'a, C: CommandRunner> ReloadService<'a, C> {
|
|
|
|
|
|
pub fn new(service: &'a str, command_runner: &'a C) -> Self {
|
|
|
|
|
|
|
|
|
impl<'a, S, C: CommandRunner> ReloadService<'a, S, C> {
|
|
|
|
|
|
pub fn new(service: S, command_runner: &'a C) -> Self {
|
|
|
ReloadService {
|
|
|
ReloadService {
|
|
|
service,
|
|
|
service,
|
|
|
command_runner,
|
|
|
command_runner,
|
|
@ -18,7 +18,7 @@ impl<'a, C: CommandRunner> ReloadService<'a, C> { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl<C: CommandRunner> Symbol for ReloadService<'_, C> {
|
|
|
|
|
|
|
|
|
impl<S: AsRef<str>, C: CommandRunner> Symbol for ReloadService<'_, S, C> {
|
|
|
fn target_reached(&self) -> Result<bool, Box<dyn Error>> {
|
|
|
fn target_reached(&self) -> Result<bool, Box<dyn Error>> {
|
|
|
Ok(true)
|
|
|
Ok(true)
|
|
|
}
|
|
|
}
|
|
@ -26,7 +26,7 @@ impl<C: CommandRunner> Symbol for ReloadService<'_, C> { |
|
|
fn execute(&self) -> Result<(), Box<dyn Error>> {
|
|
|
fn execute(&self) -> Result<(), Box<dyn Error>> {
|
|
|
self
|
|
|
self
|
|
|
.command_runner
|
|
|
.command_runner
|
|
|
.run_successfully("systemctl", args!["reload-or-restart", self.service])
|
|
|
|
|
|
|
|
|
.run_successfully("systemctl", args!["reload-or-restart", self.service.as_ref()])
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn as_action<'b>(&'b self, runner: &'b dyn SymbolRunner) -> Box<dyn Action + 'b> {
|
|
|
fn as_action<'b>(&'b self, runner: &'b dyn SymbolRunner) -> Box<dyn Action + 'b> {
|
|
@ -41,8 +41,8 @@ impl<C: CommandRunner> Symbol for ReloadService<'_, C> { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl<C: CommandRunner> fmt::Display for ReloadService<'_, C> {
|
|
|
|
|
|
|
|
|
impl<S: AsRef<str>, C: CommandRunner> fmt::Display for ReloadService<'_, S, C> {
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
|
|
write!(f, "Reload service {}", self.service)
|
|
|
|
|
|
|
|
|
write!(f, "Reload service {}", self.service.as_ref())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|