This commit is contained in:
Adrian Heine 2019-10-08 23:31:03 +02:00
parent 64bdf403d4
commit e060ce5a68
35 changed files with 142 additions and 236 deletions

View file

@ -18,7 +18,7 @@ impl<'a, C: CommandRunner> ReloadService<'a, C> {
}
}
impl<'a, C: CommandRunner> Symbol for ReloadService<'a, C> {
impl<C: CommandRunner> Symbol for ReloadService<'_, C> {
fn target_reached(&self) -> Result<bool, Box<dyn Error>> {
Ok(true)
}
@ -41,7 +41,7 @@ impl<'a, C: CommandRunner> Symbol for ReloadService<'a, C> {
}
}
impl<'a, C: CommandRunner> fmt::Display for ReloadService<'a, C> {
impl<C: CommandRunner> fmt::Display for ReloadService<'_, C> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "Reload service {}", self.service)
}

View file

@ -29,14 +29,14 @@ impl From<io::Error> for UserServiceError<io::Error> {
impl<E: Error> Error for UserServiceError<E> {
fn description(&self) -> &str {
match self {
UserServiceError::ExecError(ref e) => e.description(),
UserServiceError::GenericError => "Generic error",
UserServiceError::ActivationFailed(_) => "Activation of service failed",
Self::ExecError(ref e) => e.description(),
Self::GenericError => "Generic error",
Self::ActivationFailed(_) => "Activation of service failed",
}
}
fn cause(&self) -> Option<&dyn Error> {
match self {
UserServiceError::ExecError(ref e) => Some(e),
Self::ExecError(ref e) => Some(e),
_ => None,
}
}
@ -126,9 +126,7 @@ WantedBy=default.target
}
}
impl<'a, S: AsRef<Path>, U: AsRef<str>, C: AsRef<str>, R: CommandRunner>
UserService<'a, S, U, C, R>
{
impl<S: AsRef<Path>, U: AsRef<str>, C: AsRef<str>, R: CommandRunner> UserService<'_, S, U, C, R> {
fn systemctl_wait_for_dbus(&self, args: &[&OsStr]) -> Result<String, Box<dyn Error>> {
let mut tries = 5;
loop {
@ -176,8 +174,8 @@ impl<'a, S: AsRef<Path>, U: AsRef<str>, C: AsRef<str>, R: CommandRunner>
}
}
impl<'a, S: AsRef<Path>, U: AsRef<str>, C: AsRef<str>, R: CommandRunner> Symbol
for UserService<'a, S, U, C, R>
impl<S: AsRef<Path>, U: AsRef<str>, C: AsRef<str>, R: CommandRunner> Symbol
for UserService<'_, S, U, C, R>
{
fn target_reached(&self) -> Result<bool, Box<dyn Error>> {
if !(self.config.target_reached()?) {
@ -226,8 +224,8 @@ impl<'a, S: AsRef<Path>, U: AsRef<str>, C: AsRef<str>, R: CommandRunner> Symbol
}
}
impl<'a, S: AsRef<Path>, U: AsRef<str>, C: AsRef<str>, R: CommandRunner> fmt::Display
for UserService<'a, S, U, C, R>
impl<S: AsRef<Path>, U: AsRef<str>, C: AsRef<str>, R: CommandRunner> fmt::Display
for UserService<'_, S, U, C, R>
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "Systemd user service unit for {}", self.service_name)

View file

@ -14,13 +14,13 @@ pub enum SystemdUserSessionError<E: Error> {
impl<E: Error> Error for SystemdUserSessionError<E> {
fn description(&self) -> &str {
match self {
SystemdUserSessionError::ExecError(ref e) => e.description(),
SystemdUserSessionError::GenericError => "Generic error",
Self::ExecError(ref e) => e.description(),
Self::GenericError => "Generic error",
}
}
fn cause(&self) -> Option<&dyn Error> {
match self {
SystemdUserSessionError::ExecError(ref e) => Some(e),
Self::ExecError(ref e) => Some(e),
_ => None,
}
}
@ -46,7 +46,7 @@ impl<'a, U: AsRef<str>, C: CommandRunner> SystemdUserSession<'a, U, C> {
}
}
impl<'a, U: AsRef<str>, C: CommandRunner> Symbol for SystemdUserSession<'a, U, C> {
impl<U: AsRef<str>, C: CommandRunner> Symbol for SystemdUserSession<'_, U, C> {
fn target_reached(&self) -> Result<bool, Box<dyn Error>> {
let mut path = PathBuf::from("/var/lib/systemd/linger");
path.push(self.user_name.as_ref());
@ -72,7 +72,7 @@ impl<'a, U: AsRef<str>, C: CommandRunner> Symbol for SystemdUserSession<'a, U, C
}
}
impl<'a, U: AsRef<str>, C: CommandRunner> fmt::Display for SystemdUserSession<'a, U, C> {
impl<U: AsRef<str>, C: CommandRunner> fmt::Display for SystemdUserSession<'_, U, C> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "Systemd user session for {}", self.user_name.as_ref())
}