Switch CommandRunner to OsStr
This commit is contained in:
parent
b8bac1142c
commit
3b45b0f77c
22 changed files with 220 additions and 148 deletions
|
|
@ -4,13 +4,13 @@ use std::fmt;
|
|||
use command_runner::CommandRunner;
|
||||
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
|
||||
|
||||
pub struct ReloadService<'a> {
|
||||
pub struct ReloadService<'a, C: 'a + CommandRunner> {
|
||||
service: &'a str,
|
||||
command_runner: &'a CommandRunner
|
||||
command_runner: &'a C
|
||||
}
|
||||
|
||||
impl<'a> ReloadService<'a> {
|
||||
pub fn new(service: &'a str, command_runner: &'a CommandRunner) -> Self {
|
||||
impl<'a, C: CommandRunner> ReloadService<'a, C> {
|
||||
pub fn new(service: &'a str, command_runner: &'a C) -> Self {
|
||||
ReloadService {
|
||||
service: service,
|
||||
command_runner: command_runner
|
||||
|
|
@ -18,7 +18,7 @@ impl<'a> ReloadService<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Symbol for ReloadService<'a> {
|
||||
impl<'a, C: CommandRunner> Symbol for ReloadService<'a, C> {
|
||||
fn target_reached(&self) -> Result<bool, Box<Error>> {
|
||||
Ok(true)
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ impl<'a> Symbol for ReloadService<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for ReloadService<'a> {
|
||||
impl<'a, C: CommandRunner> fmt::Display for ReloadService<'a, C> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(),fmt::Error>{
|
||||
write!(f, "Reload service {}", self.service)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,13 +33,13 @@ impl<E: Error> fmt::Display for SystemdUserSessionError<E> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct SystemdUserSession<'a> {
|
||||
pub struct SystemdUserSession<'a, C: 'a + CommandRunner> {
|
||||
user_name: Cow<'a, str>,
|
||||
command_runner: &'a CommandRunner
|
||||
command_runner: &'a C
|
||||
}
|
||||
|
||||
impl<'a> SystemdUserSession<'a> {
|
||||
pub fn new(user_name: Cow<'a, str>, command_runner: &'a CommandRunner) -> Self {
|
||||
impl<'a, C: CommandRunner> SystemdUserSession<'a, C> {
|
||||
pub fn new(user_name: Cow<'a, str>, command_runner: &'a C) -> Self {
|
||||
SystemdUserSession {
|
||||
user_name: user_name,
|
||||
command_runner: command_runner
|
||||
|
|
@ -47,7 +47,7 @@ impl<'a> SystemdUserSession<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Symbol for SystemdUserSession<'a> {
|
||||
impl<'a, C: CommandRunner> Symbol for SystemdUserSession<'a, C> {
|
||||
fn target_reached(&self) -> Result<bool, Box<Error>> {
|
||||
let mut path = PathBuf::from("/var/lib/systemd/linger");
|
||||
path.push(self.user_name.borrow() as &str);
|
||||
|
|
@ -68,7 +68,7 @@ impl<'a> Symbol for SystemdUserSession<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for SystemdUserSession<'a> {
|
||||
impl<'a, C: CommandRunner> fmt::Display for SystemdUserSession<'a, C> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(),fmt::Error>{
|
||||
write!(f, "Systemd user session for {}", self.user_name)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue