Browse Source

Update to edition 2018

master
Adrian Heine 5 years ago
parent
commit
602c7f7ebe
  1. 1
      Cargo.toml
  2. 2
      src/command_runner.rs
  3. 30
      src/factory.rs
  4. 3
      src/lib.rs
  5. 4
      src/loggers.rs
  6. 4
      src/repository.rs
  7. 35
      src/schema.rs
  8. 8
      src/symbols/acme/account_key.rs
  9. 8
      src/symbols/acme/cert.rs
  10. 8
      src/symbols/acme/chain.rs
  11. 14
      src/symbols/acme/user.rs
  12. 6
      src/symbols/cron.rs
  13. 6
      src/symbols/dir.rs
  14. 32
      src/symbols/factory.rs
  15. 6
      src/symbols/file.rs
  16. 8
      src/symbols/git/checkout.rs
  17. 6
      src/symbols/git/submodules.rs
  18. 14
      src/symbols/hook.rs
  19. 6
      src/symbols/list.rs
  20. 6
      src/symbols/mariadb/database.rs
  21. 8
      src/symbols/mariadb/database_dump.rs
  22. 8
      src/symbols/mariadb/user.rs
  23. 4
      src/symbols/mod.rs
  24. 12
      src/symbols/nginx/server.rs
  25. 4
      src/symbols/noop.rs
  26. 6
      src/symbols/npm.rs
  27. 8
      src/symbols/owner.rs
  28. 6
      src/symbols/postgresql/database.rs
  29. 8
      src/symbols/postgresql/database_dump.rs
  30. 10
      src/symbols/stored_directory.rs
  31. 8
      src/symbols/systemd/reload.rs
  32. 12
      src/symbols/systemd/user_service.rs
  33. 8
      src/symbols/systemd/user_session.rs
  34. 10
      src/symbols/tls/csr.rs
  35. 8
      src/symbols/tls/key.rs
  36. 8
      src/symbols/tls/self_signed_cert.rs
  37. 26
      src/symbols/user.rs
  38. 8
      src/symbols/wordpress/plugin.rs
  39. 8
      src/symbols/wordpress/translation.rs
  40. 3
      tests/file.rs
  41. 4
      tests/storage.rs

1
Cargo.toml

@ -2,6 +2,7 @@
name = "schematics"
version = "0.1.0"
authors = ["Adrian Heine <mail@adrianheine.de>"]
edition = "2018"
[dependencies]
users = "0.7.0"

2
src/command_runner.rs

@ -150,7 +150,7 @@ impl<'a, U: AsRef<str>, C: CommandRunner> CommandRunner for SetuidCommandRunner<
#[derive(Debug)]
pub struct SuCommandRunner<'a, C>
where
C: 'a + CommandRunner,
C: CommandRunner,
{
command_runner: &'a C,
user_name: &'a str,

30
src/factory.rs

@ -1,18 +1,20 @@
use regex::Regex;
use command_runner::CommandRunner;
use loggers::StdErrLogger;
use repository::SymbolRepository;
use resources::Resource;
use schema::{NonRepeatingSymbolRunner, ReportingSymbolRunner, RequirementsResolvingSymbolRunner};
use symbols::dir::Dir;
use symbols::list::List;
use symbols::owner::Owner;
use symbols::systemd::user_session::SystemdUserSession;
use symbols::tls::{TlsCsr, TlsKey};
use symbols::user::SystemUserAdder;
use symbols::user::{User, UserAdder};
use symbols::{Symbol, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::loggers::StdErrLogger;
use crate::repository::SymbolRepository;
use crate::resources::Resource;
use crate::schema::{
NonRepeatingSymbolRunner, ReportingSymbolRunner, RequirementsResolvingSymbolRunner,
};
use crate::symbols::dir::Dir;
use crate::symbols::list::List;
use crate::symbols::owner::Owner;
use crate::symbols::systemd::user_session::SystemdUserSession;
use crate::symbols::tls::{TlsCsr, TlsKey};
use crate::symbols::user::SystemUserAdder;
use crate::symbols::user::{User, UserAdder};
use crate::symbols::{Symbol, SymbolRunner};
#[derive(Default)]
pub struct Factory {}
@ -40,7 +42,7 @@ impl Factory {
}
}
pub struct DefaultSymbolRepository<'a, A: 'a + UserAdder, C: 'a + CommandRunner> {
pub struct DefaultSymbolRepository<'a, A: 'a + UserAdder, C: CommandRunner> {
user_adder: A,
command_runner: &'a C,

3
src/lib.rs

@ -19,9 +19,6 @@ missing_debug_implementations
*/
#![allow(box_pointers)]
extern crate regex;
extern crate users;
#[macro_use]
mod for_each_tuple;

4
src/loggers.rs

@ -2,8 +2,8 @@ use std::io::stderr;
use std::io::Write;
pub trait Logger {
fn write(&mut self, &str);
fn debug(&mut self, &str);
fn write(&mut self, msg: &str);
fn debug(&mut self, msg: &str);
}
pub struct StdErrLogger;

4
src/repository.rs

@ -1,7 +1,7 @@
use std::collections::HashMap;
use resources::Resource;
use symbols::Symbol;
use crate::resources::Resource;
use crate::symbols::Symbol;
pub trait SymbolRepository<'a> {
fn get_symbol(&'a self, resource: &Resource) -> Option<Box<dyn Symbol + 'a>>;

35
src/schema.rs

@ -2,9 +2,9 @@ use std::cell::RefCell;
use std::error::Error;
use std::fmt;
use loggers::Logger;
use repository::SymbolRepository;
use symbols::{Symbol, SymbolRunner};
use crate::loggers::Logger;
use crate::repository::SymbolRepository;
use crate::symbols::{Symbol, SymbolRunner};
#[derive(Debug)]
pub enum SymbolRunError {
@ -28,7 +28,7 @@ impl Error for SymbolRunError {
}
impl fmt::Display for SymbolRunError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
SymbolRunError::Symbol(ref e) => write!(f, "{}", e),
SymbolRunError::ExecuteDidNotReach(_) => write!(f, "{}", self.description()),
@ -98,7 +98,7 @@ impl<L: Logger> SymbolRunner for DrySymbolRunner<L> {
}
}
pub struct ReportingSymbolRunner<'a, R: 'a + SymbolRunner, L: Logger>(&'a R, RefCell<L>);
pub struct ReportingSymbolRunner<'a, R: SymbolRunner, L: Logger>(&'a R, RefCell<L>);
impl<'a, R, L> ReportingSymbolRunner<'a, R, L>
where
@ -131,7 +131,7 @@ where
}
}
use resources::Resource;
use crate::resources::Resource;
use std::collections::HashSet;
pub struct NonRepeatingSymbolRunner<R: SymbolRunner> {
@ -171,12 +171,11 @@ impl<R: SymbolRunner> SymbolRunner for NonRepeatingSymbolRunner<R> {
}
use std::marker::PhantomData;
pub struct RequirementsResolvingSymbolRunner<
'a,
's,
R: 'a + SymbolRunner,
G: 'a + SymbolRepository<'s>,
>(R, &'a G, PhantomData<Box<dyn Symbol + 's>>);
pub struct RequirementsResolvingSymbolRunner<'a, 's, R: 'a + SymbolRunner, G: SymbolRepository<'s>>(
R,
&'a G,
PhantomData<Box<dyn Symbol + 's>>,
);
impl<'s, 'a: 's, R, G> RequirementsResolvingSymbolRunner<'a, 's, R, G>
where
@ -211,10 +210,10 @@ mod test {
use std::error::Error;
use std::fmt;
use loggers::Logger;
use schema::InitializingSymbolRunner;
use schema::SymbolRunner;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction};
use crate::loggers::Logger;
use crate::schema::InitializingSymbolRunner;
use crate::schema::SymbolRunner;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction};
#[derive(Debug, PartialEq, Clone)]
enum DummySymbolError {
@ -228,7 +227,7 @@ mod test {
}
impl fmt::Display for DummySymbolError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Dummy symbol error")
}
}
@ -259,7 +258,7 @@ mod test {
}
impl<'a> fmt::Display for DummySymbol<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Dummy symbol")
}
}

8
src/symbols/acme/account_key.rs

@ -2,9 +2,9 @@ use std::error::Error;
use std::fmt;
use std::path::Path;
use command_runner::CommandRunner;
use resources::Resource;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::resources::Resource;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct AcmeAccountKey<'a, P: AsRef<Path>, C: CommandRunner> {
path: P,
@ -25,7 +25,7 @@ impl<'a, P: AsRef<Path>, C: CommandRunner> AcmeAccountKey<'a, P, C> {
}
impl<'a, P: AsRef<Path>, C: CommandRunner> fmt::Display for AcmeAccountKey<'a, P, C> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "AcmeAccountKey {}", self.path.as_ref().display())
}
}

8
src/symbols/acme/cert.rs

@ -4,9 +4,9 @@ use std::fs::File as FsFile;
use std::io::Write;
use std::path::PathBuf;
use command_runner::CommandRunner;
use resources::Resource;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::resources::Resource;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct AcmeCert<'a, D: AsRef<str>, C: CommandRunner> {
domain: D,
@ -31,7 +31,7 @@ impl<'a, D: AsRef<str>, C: CommandRunner> AcmeCert<'a, D, C> {
}
impl<'a, D: AsRef<str>, C: CommandRunner> fmt::Display for AcmeCert<'a, D, C> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "AcmeCert {}", self.domain.as_ref())
}
}

8
src/symbols/acme/chain.rs

@ -4,9 +4,9 @@ use std::fs::File as FsFile;
use std::io::Write;
use std::path::PathBuf;
use command_runner::CommandRunner;
use resources::Resource;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::resources::Resource;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct AcmeCertChain<'a, D: AsRef<str>, C: CommandRunner> {
domain: D,
@ -31,7 +31,7 @@ impl<'a, D: AsRef<str>, C: CommandRunner> AcmeCertChain<'a, D, C> {
}
impl<'a, D: AsRef<str>, C: CommandRunner> fmt::Display for AcmeCertChain<'a, D, C> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "AcmeCertChain {}", self.domain.as_ref())
}
}

14
src/symbols/acme/user.rs

@ -1,12 +1,12 @@
use std::path::{Path, PathBuf};
use command_runner::CommandRunner;
use symbols::acme::AcmeAccountKey;
use symbols::dir::Dir;
use symbols::file::File;
use symbols::list::List;
use symbols::owner::Owner;
use symbols::Symbol;
use crate::command_runner::CommandRunner;
use crate::symbols::acme::AcmeAccountKey;
use crate::symbols::dir::Dir;
use crate::symbols::file::File;
use crate::symbols::list::List;
use crate::symbols::owner::Owner;
use crate::symbols::Symbol;
pub fn new<'a, R: CommandRunner, C: 'a + AsRef<str>, U: 'a + AsRef<str> + Clone, H: AsRef<Path>>(
command_runner: &'a R,

6
src/symbols/cron.rs

@ -1,9 +1,9 @@
use std::error::Error;
use std::fmt;
use command_runner::CommandRunner;
use crate::command_runner::CommandRunner;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct Cron<'r, C: AsRef<str>, U: AsRef<str>, R: CommandRunner> {
user: U,
@ -54,7 +54,7 @@ impl<'r, C: AsRef<str>, U: AsRef<str>, R: CommandRunner> Symbol for Cron<'r, C,
}
impl<'r, C: AsRef<str>, U: AsRef<str>, R: CommandRunner> fmt::Display for Cron<'r, C, U, R> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "Cron {}", self.user.as_ref())
}
}

6
src/symbols/dir.rs

@ -4,8 +4,8 @@ use std::fs;
use std::io;
use std::path::Path;
use resources::Resource;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::resources::Resource;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct Dir<D: AsRef<Path>> {
path: D,
@ -64,7 +64,7 @@ impl<D: AsRef<Path>> Symbol for Dir<D> {
}
impl<D: AsRef<Path>> fmt::Display for Dir<D> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "Dir {}", self.path.as_ref().display())
}
}

32
src/symbols/factory.rs

@ -2,22 +2,22 @@ use std::borrow::Cow;
use std::path::Path;
use std::path::PathBuf;
use command_runner::{CommandRunner, SetuidCommandRunner};
use storage::{SimpleStorage, Storage};
use symbols::acme::{newAcmeUser, AcmeCert, AcmeCertChain};
use symbols::cron::Cron;
use symbols::file::File;
use symbols::git::checkout::GitCheckout;
use symbols::hook::Hook;
use symbols::list::List;
use symbols::mariadb::{DatabaseDump, MariaDBDatabase, MariaDBUser};
use symbols::nginx::server::{server_config, NginxServer};
use symbols::owner::Owner;
use symbols::stored_directory::{StorageDirection, StoredDirectory};
use symbols::systemd::reload::ReloadService;
use symbols::systemd::user_service::UserService;
use symbols::tls::SelfSignedTlsCert;
use symbols::{Symbol, SymbolRunner};
use crate::command_runner::{CommandRunner, SetuidCommandRunner};
use crate::storage::{SimpleStorage, Storage};
use crate::symbols::acme::{newAcmeUser, AcmeCert, AcmeCertChain};
use crate::symbols::cron::Cron;
use crate::symbols::file::File;
use crate::symbols::git::checkout::GitCheckout;
use crate::symbols::hook::Hook;
use crate::symbols::list::List;
use crate::symbols::mariadb::{DatabaseDump, MariaDBDatabase, MariaDBUser};
use crate::symbols::nginx::server::{server_config, NginxServer};
use crate::symbols::owner::Owner;
use crate::symbols::stored_directory::{StorageDirection, StoredDirectory};
use crate::symbols::systemd::reload::ReloadService;
use crate::symbols::systemd::user_service::UserService;
use crate::symbols::tls::SelfSignedTlsCert;
use crate::symbols::{Symbol, SymbolRunner};
pub trait Policy {
fn user_name_for_host(&self, host_name: &'static str) -> String {

6
src/symbols/file.rs

@ -6,8 +6,8 @@ use std::io::{Read, Write};
use std::path::Path;
use resources::Resource;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::resources::Resource;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct File<C: AsRef<str>, D: AsRef<Path>> {
path: D,
@ -66,7 +66,7 @@ impl<C: AsRef<str>, D: AsRef<Path>> Symbol for File<C, D> {
}
impl<C: AsRef<str>, D: AsRef<Path>> fmt::Display for File<C, D> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "File {}", self.path.as_ref().display())
}
}

8
src/symbols/git/checkout.rs

@ -5,9 +5,9 @@ use std::fs::metadata;
use std::io;
use std::path::Path;
use command_runner::CommandRunner;
use resources::Resource;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::resources::Resource;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct GitCheckout<'a, C: CommandRunner, T: AsRef<Path>> {
target: T,
@ -28,7 +28,7 @@ impl<'a, C: CommandRunner, T: AsRef<Path>> GitCheckout<'a, C, T> {
}
impl<'a, C: CommandRunner, T: AsRef<Path>> fmt::Display for GitCheckout<'a, C, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"Checkout {} (branch {}) into {}",

6
src/symbols/git/submodules.rs

@ -3,8 +3,8 @@ use std::ffi::OsStr;
use std::fmt;
use std::path::Path;
use command_runner::CommandRunner;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct GitSubmodules<'a, P: AsRef<Path>, C: CommandRunner> {
target: P,
@ -21,7 +21,7 @@ impl<'a, P: AsRef<Path>, C: CommandRunner> GitSubmodules<'a, P, C> {
}
impl<'a, P: AsRef<Path>, C: CommandRunner> fmt::Display for GitSubmodules<'a, P, C> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Submodules for {}", self.target.as_ref().display())
}
}

14
src/symbols/hook.rs

@ -1,8 +1,8 @@
use std::error::Error;
use std::fmt;
use resources::Resource;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::resources::Resource;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct Hook<A, B>
where
@ -83,7 +83,7 @@ where
A: Symbol,
B: Symbol,
{
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "Hook {} and then {}", self.a, self.b)
}
}
@ -93,8 +93,8 @@ mod test {
use std::error::Error;
use std::fmt;
use symbols::hook::Hook;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::symbols::hook::Hook;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
struct ErrSymbol(String);
impl Symbol for ErrSymbol {
@ -116,7 +116,7 @@ mod test {
}
}
impl fmt::Display for ErrSymbol {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "")
}
}
@ -141,7 +141,7 @@ mod test {
}
}
impl fmt::Display for OkSymbol {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "")
}
}

6
src/symbols/list.rs

@ -1,8 +1,8 @@
use std::error::Error;
use std::fmt;
use resources::Resource;
use symbols::{Action, Symbol, SymbolRunner};
use crate::resources::Resource;
use crate::symbols::{Action, Symbol, SymbolRunner};
pub struct List<'a> {
symbols: Vec<Box<dyn Symbol + 'a>>,
@ -128,7 +128,7 @@ impl<'a> Action for ListAction<'a> {
}
impl<'a> fmt::Display for List<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "List [ ")?;
for symbol in &self.symbols {
write!(f, "{} ", symbol)?;

6
src/symbols/mariadb/database.rs

@ -2,8 +2,8 @@ use std::error::Error;
use std::fmt;
use std::path::Path;
use command_runner::CommandRunner;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct MariaDBDatabase<'a, D: AsRef<str>, S: AsRef<Path>, C: CommandRunner> {
db_name: D,
@ -31,7 +31,7 @@ impl<'a, D: AsRef<str>, S: AsRef<Path>, C: CommandRunner> MariaDBDatabase<'a, D,
impl<'a, D: AsRef<str>, S: AsRef<Path>, C: CommandRunner> fmt::Display
for MariaDBDatabase<'a, D, S, C>
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "MariaDB Database {}", self.db_name.as_ref())
}
}

8
src/symbols/mariadb/database_dump.rs

@ -2,9 +2,9 @@ use std::error::Error;
use std::fmt;
use std::str::FromStr;
use command_runner::CommandRunner;
use storage::Storage;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::storage::Storage;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct DatabaseDump<'a, N: AsRef<str>, C: CommandRunner, S: Storage> {
db_name: N,
@ -30,7 +30,7 @@ impl<'a, N: AsRef<str>, C: CommandRunner, S: Storage> DatabaseDump<'a, N, C, S>
}
impl<'a, N: AsRef<str>, C: CommandRunner, S: Storage> fmt::Display for DatabaseDump<'a, N, C, S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Dump MariaDB Database {}", self.db_name.as_ref())
}
}

8
src/symbols/mariadb/user.rs

@ -1,9 +1,9 @@
use std::error::Error;
use std::fmt;
use command_runner::CommandRunner;
use resources::Resource;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::resources::Resource;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct MariaDBUser<'a, U: AsRef<str>, C: CommandRunner> {
user_name: U,
@ -27,7 +27,7 @@ impl<'a, U: AsRef<str>, C: CommandRunner> MariaDBUser<'a, U, C> {
}
impl<'a, U: AsRef<str>, C: CommandRunner> fmt::Display for MariaDBUser<'a, U, C> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "MariaDB User {}", self.user_name.as_ref())
}
}

4
src/symbols/mod.rs

@ -1,4 +1,4 @@
use resources::Resource;
use crate::resources::Resource;
use std::error::Error;
use std::fmt::Display;
@ -33,7 +33,7 @@ pub trait Symbol: Display {
}
// SymbolAction
pub struct SymbolAction<'a, S: Symbol + 'a> {
pub struct SymbolAction<'a, S: Symbol> {
runner: &'a dyn SymbolRunner,
symbol: &'a S,
}

12
src/symbols/nginx/server.rs

@ -3,10 +3,10 @@ use std::fmt;
use std::io;
use std::path::{Path, PathBuf};
use command_runner::CommandRunner;
use resources::Resource;
use symbols::file::File as FileSymbol;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::resources::Resource;
use crate::symbols::file::File as FileSymbol;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
#[derive(Debug)]
pub enum NginxServerError<E: Error> {
@ -36,7 +36,7 @@ impl<E: Error> Error for NginxServerError<E> {
}
impl<E: Error> fmt::Display for NginxServerError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "{}", self.description())
}
}
@ -242,7 +242,7 @@ impl<'a, C: CommandRunner, T: AsRef<str>, P: AsRef<Path>> Symbol for NginxServer
impl<'a, C: CommandRunner, T: AsRef<str>, P: AsRef<Path>> fmt::Display
for NginxServer<'a, C, T, P>
{
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "Nginx server config")
}
}

4
src/symbols/noop.rs

@ -1,7 +1,7 @@
use std::error::Error;
use std::fmt::{self, Display};
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct NoopSymbol;
@ -25,7 +25,7 @@ impl Symbol for NoopSymbol {
}
impl Display for NoopSymbol {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "Noop")
}
}

6
src/symbols/npm.rs

@ -2,8 +2,8 @@ use std::error::Error;
use std::fmt;
use std::path::Path;
use command_runner::CommandRunner;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct NpmInstall<'a, T: AsRef<Path>, C: CommandRunner> {
target: T,
@ -20,7 +20,7 @@ impl<'a, T: AsRef<Path>, C: CommandRunner> NpmInstall<'a, T, C> {
}
impl<'a, T: AsRef<Path>, C: CommandRunner> fmt::Display for NpmInstall<'a, T, C> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"npm install in {}",

8
src/symbols/owner.rs

@ -7,9 +7,9 @@ use std::path::Path;
use users::get_user_by_name;
use command_runner::CommandRunner;
use resources::Resource;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::resources::Resource;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct Owner<'a, C: CommandRunner, D: AsRef<Path>, U: AsRef<str>> {
path: D,
@ -61,7 +61,7 @@ impl<'a, C: CommandRunner, D: AsRef<Path>, U: AsRef<str>> Symbol for Owner<'a, C
}
impl<'a, C: CommandRunner, D: AsRef<Path>, U: AsRef<str>> fmt::Display for Owner<'a, C, D, U> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(
f,
"Owner {} for {}",

6
src/symbols/postgresql/database.rs

@ -1,8 +1,8 @@
use std::error::Error;
use std::fmt;
use command_runner::CommandRunner;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct PostgreSQLDatabase<'a, N: AsRef<str>, S: AsRef<str>, C: CommandRunner> {
name: N,
@ -31,7 +31,7 @@ impl<'a, N: AsRef<str>, S: AsRef<str>, C: CommandRunner> PostgreSQLDatabase<'a,
impl<'a, N: AsRef<str>, S: AsRef<str>, C: CommandRunner> fmt::Display
for PostgreSQLDatabase<'a, N, S, C>
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "PostgreSQL Database {}", self.name.as_ref())
}
}

8
src/symbols/postgresql/database_dump.rs

@ -2,9 +2,9 @@ use std::error::Error;
use std::fmt;
use std::str::FromStr;
use command_runner::CommandRunner;
use storage::Storage;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::storage::Storage;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct DatabaseDump<'a, N: AsRef<str>, C: CommandRunner, S: Storage> {
db_name: N,
@ -30,7 +30,7 @@ impl<'a, N: AsRef<str>, C: CommandRunner, S: Storage> DatabaseDump<'a, N, C, S>
}
impl<'a, N: AsRef<str>, C: CommandRunner, S: Storage> fmt::Display for DatabaseDump<'a, N, C, S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Dump MariaDB Database {}", self.db_name.as_ref())
}
}

10
src/symbols/stored_directory.rs

@ -5,10 +5,10 @@ use std::io;
use std::path::Path;
use std::str::FromStr;
use command_runner::CommandRunner;
use resources::Resource;
use storage::Storage;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::resources::Resource;
use crate::storage::Storage;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
#[derive(Debug, PartialEq)]
pub enum StorageDirection {
@ -37,7 +37,7 @@ impl<'a, P: AsRef<Path>, S: Storage, C: CommandRunner> StoredDirectory<'a, P, S,
impl<'a, P: AsRef<Path>, S: Storage, C: CommandRunner> fmt::Display
for StoredDirectory<'a, P, S, C>
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"Stored directory {} ({:?})",

8
src/symbols/systemd/reload.rs

@ -1,10 +1,10 @@
use std::error::Error;
use std::fmt;
use command_runner::CommandRunner;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct ReloadService<'a, C: 'a + CommandRunner> {
pub struct ReloadService<'a, C: CommandRunner> {
service: &'a str,
command_runner: &'a C,
}
@ -42,7 +42,7 @@ impl<'a, C: CommandRunner> Symbol for ReloadService<'a, C> {
}
impl<'a, C: CommandRunner> fmt::Display for ReloadService<'a, 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)
}
}

12
src/symbols/systemd/user_service.rs

@ -9,10 +9,10 @@ use std::process::Output;
use std::thread::sleep;
use std::time::Duration;
use command_runner::{CommandRunner, SetuidCommandRunner};
use resources::Resource;
use symbols::file::File as FileSymbol;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::{CommandRunner, SetuidCommandRunner};
use crate::resources::Resource;
use crate::symbols::file::File as FileSymbol;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
#[derive(Debug)]
pub enum UserServiceError<E: Error> {
@ -44,7 +44,7 @@ impl<E: Error> Error for UserServiceError<E> {
}
impl<E: Error> fmt::Display for UserServiceError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "{}", self.description())?;
if let UserServiceError::ActivationFailed(Ok(ref log)) = self {
write!(f, ": {:?}", log)?;
@ -222,7 +222,7 @@ impl<'a, C: AsRef<str>, R: CommandRunner> Symbol for UserService<'a, C, R> {
}
impl<'a, C: AsRef<str>, R: CommandRunner> fmt::Display for UserService<'a, C, R> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "Systemd user service unit for {}", self.service_name)
}
}

8
src/symbols/systemd/user_session.rs

@ -2,8 +2,8 @@ use std::error::Error;
use std::fmt;
use std::path::PathBuf;
use command_runner::CommandRunner;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
#[derive(Debug)]
pub enum SystemdUserSessionError<E: Error> {
@ -27,7 +27,7 @@ impl<E: Error> Error for SystemdUserSessionError<E> {
}
impl<E: Error> fmt::Display for SystemdUserSessionError<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "{}", self.description())
}
}
@ -73,7 +73,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> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "Systemd user session for {}", self.user_name.as_ref())
}
}

10
src/symbols/tls/csr.rs

@ -4,11 +4,11 @@ use std::ffi::OsStr;
use std::fmt;
use std::path::PathBuf;
use command_runner::CommandRunner;
use resources::Resource;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::resources::Resource;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct TlsCsr<'a, C: 'a + CommandRunner> {
pub struct TlsCsr<'a, C: CommandRunner> {
domain: Cow<'a, str>,
command_runner: &'a C,
}
@ -31,7 +31,7 @@ impl<'a, C: CommandRunner> TlsCsr<'a, C> {
}
impl<'a, C: CommandRunner> fmt::Display for TlsCsr<'a, C> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "TlsCsr {}", self.domain)
}
}

8
src/symbols/tls/key.rs

@ -4,10 +4,10 @@ use std::ffi::OsStr;
use std::fmt;
use std::path::PathBuf;
use command_runner::CommandRunner;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct TlsKey<'a, C: 'a + CommandRunner> {
pub struct TlsKey<'a, C: CommandRunner> {
domain: Cow<'a, str>,
command_runner: &'a C,
}
@ -32,7 +32,7 @@ impl<'a, C: CommandRunner> TlsKey<'a, C> {
}
impl<'a, C: CommandRunner> fmt::Display for TlsKey<'a, C> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "TlsKey {}", self.domain)
}
}

8
src/symbols/tls/self_signed_cert.rs

@ -2,9 +2,9 @@ use std::error::Error;
use std::fmt;
use std::path::PathBuf;
use command_runner::CommandRunner;
use resources::Resource;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::resources::Resource;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct SelfSignedTlsCert<'a, D: AsRef<str>, C: CommandRunner> {
domain: D,
@ -29,7 +29,7 @@ impl<'a, D: AsRef<str>, C: CommandRunner> SelfSignedTlsCert<'a, D, C> {
}
impl<'a, D: AsRef<str>, C: CommandRunner> fmt::Display for SelfSignedTlsCert<'a, D, C> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "SelfSignedTlsCert {}", self.domain.as_ref())
}
}

26
src/symbols/user.rs

@ -2,9 +2,9 @@ use std::borrow::Cow;
use std::error::Error;
use std::fmt;
use command_runner::CommandRunner;
use resources::Resource;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::resources::Resource;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
#[derive(Debug)]
pub enum UserAdderError {
@ -30,7 +30,7 @@ impl Error for UserAdderError {
}
impl fmt::Display for UserAdderError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.cause() {
Some(e) => write!(f, "{} (cause: {})", self.description(), e),
None => write!(f, "{}", self.description()),
@ -61,7 +61,7 @@ impl Error for UserError {
}
impl fmt::Display for UserError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.cause() {
Some(e) => write!(f, "{} (cause: {})", self.description(), e),
None => write!(f, "{}", self.description()),
@ -86,7 +86,7 @@ impl<'a, C: CommandRunner, A: 'a + UserAdder> User<'a, C, A> {
}
impl<'a, C: CommandRunner, A: 'a + UserAdder> fmt::Display for User<'a, C, A> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "User {}", self.user_name)
}
}
@ -126,7 +126,7 @@ impl<'a, C: CommandRunner, A: 'a + UserAdder> Symbol for User<'a, C, A> {
}
}
pub struct SystemUserAdder<'a, C: 'a + CommandRunner> {
pub struct SystemUserAdder<'a, C: CommandRunner> {
command_runner: &'a C,
}
@ -171,11 +171,11 @@ mod test {
use std::error::Error;
use std::fmt;
use command_runner::StdCommandRunner;
use symbols::user::User;
use symbols::user::UserAdder;
use symbols::user::UserAdderError;
use symbols::Symbol;
use crate::command_runner::StdCommandRunner;
use crate::symbols::user::User;
use crate::symbols::user::UserAdder;
use crate::symbols::user::UserAdderError;
use crate::symbols::Symbol;
#[derive(Debug, PartialEq)]
struct DummyError;
@ -186,7 +186,7 @@ mod test {
}
impl fmt::Display for DummyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "DummyError")
}
}

8
src/symbols/wordpress/plugin.rs

@ -6,9 +6,9 @@ use std::io;
use std::io::{BufRead, BufReader};
use std::path::{Path, PathBuf};
use command_runner::CommandRunner;
use resources::Resource;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::resources::Resource;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct WordpressPlugin<'a, P: AsRef<Path>, N: AsRef<str>, R: CommandRunner> {
base: P,
@ -122,7 +122,7 @@ impl<'a, P: AsRef<Path>, N: AsRef<str>, R: CommandRunner> Symbol for WordpressPl
impl<'a, P: AsRef<Path>, N: AsRef<str>, R: CommandRunner> fmt::Display
for WordpressPlugin<'a, P, N, R>
{
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "WordpressPlugin {}", self.name.as_ref())
}
}

8
src/symbols/wordpress/translation.rs

@ -9,9 +9,9 @@ use std::io::{BufRead, BufReader};
use std::path::Path;
use std::path::PathBuf;
use command_runner::CommandRunner;
use resources::Resource;
use symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
use crate::command_runner::CommandRunner;
use crate::resources::Resource;
use crate::symbols::{Action, OwnedSymbolAction, Symbol, SymbolAction, SymbolRunner};
pub struct WordpressTranslation<'a, C: AsRef<str>, D: AsRef<Path>, R: CommandRunner> {
path: D,
@ -139,7 +139,7 @@ impl<'a, C: AsRef<str>, D: AsRef<Path>, R: CommandRunner> Symbol
impl<'a, C: AsRef<str>, D: AsRef<Path>, R: CommandRunner> fmt::Display
for WordpressTranslation<'a, C, D, R>
{
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "WordpressTranslation {}", self.path.as_ref().display())
}
}

3
tests/file.rs

@ -1,6 +1,3 @@
extern crate schematics;
extern crate tempdir;
use schematics::symbols::file::File as FileSymbol;
use schematics::symbols::Symbol;
use std::fs::File;

4
tests/storage.rs

@ -1,7 +1,3 @@
extern crate regex;
extern crate schematics;
extern crate tempdir;
use regex::Regex;
use schematics::storage::{SimpleStorage, Storage};
use std::fs::{create_dir, File};

Loading…
Cancel
Save