use crate::command_runner::CommandRunner; use crate::symbols::Symbol; use async_trait::async_trait; use std::borrow::Borrow; use std::error::Error; use std::marker::PhantomData; #[derive(Debug)] pub struct ReloadService<_C, C, S> { service: S, command_runner: C, phantom: PhantomData<_C>, } impl<_C, C, S> ReloadService<_C, C, S> { pub fn new(command_runner: C, service: S) -> Self { Self { service, command_runner, phantom: PhantomData::default(), } } } #[async_trait(?Send)] impl, _C: CommandRunner, C: Borrow<_C>> Symbol for ReloadService<_C, C, S> { async fn target_reached(&self) -> Result> { Ok(true) } async fn execute(&self) -> Result<(), Box> { self .command_runner .borrow() .run_successfully( "systemctl", args!["reload-or-restart", self.service.as_ref()], ) .await } }