diff --git a/Cargo.toml b/Cargo.toml index 7c9a897..4c82032 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,11 +6,11 @@ edition = "2018" build = "src/build.rs" [dependencies] -users = "0.11.0" +users = "0.10.0" regex = "1.0.1" futures = "0.3" async-trait = "0.1" -tokio = { version = "0.3", features = ["rt", "process", "io-util", "macros", "sync"] } +tokio = { version = "0.2", features = ["process", "io-util", "rt-core", "macros", "sync"] } once_cell = "1.4" [dev-dependencies] diff --git a/src/async_utils.rs b/src/async_utils.rs index c656c53..2c1196a 100644 --- a/src/async_utils.rs +++ b/src/async_utils.rs @@ -6,15 +6,11 @@ use std::{ thread, time::Duration, }; -use tokio::runtime::Builder; pub use async_trait::async_trait; pub fn run(future: F) -> F::Output { - Builder::new_current_thread() - .build() - .unwrap() - .block_on(future) + tokio::runtime::Runtime::new().unwrap().block_on(future) } pub use tokio::try_join; diff --git a/src/builder.rs b/src/builder.rs index 811c3f1..481096d 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -719,7 +719,9 @@ impl ImplementationBuilder> for DefaultBuilder { impl ImplementationBuilder> for DefaultBuilder { type Prerequisites = (); - fn prerequisites(_: &PostgresqlDatabase) -> Self::Prerequisites {} + fn prerequisites(_: &PostgresqlDatabase) -> Self::Prerequisites { + () + } type Implementation = (PostgreSQLDatabaseSymbol<'static, String, String, StdCommandRunner>,); fn create( diff --git a/src/command_runner.rs b/src/command_runner.rs index 0a64621..b69e7ee 100644 --- a/src/command_runner.rs +++ b/src/command_runner.rs @@ -72,7 +72,6 @@ impl CommandRunner for StdCommandRunner { .expect("Failed to write to stdin"); let res = child.wait_with_output().await; //println!("{:?}", res); - #[allow(clippy::let_and_return)] res } } diff --git a/src/loggers.rs b/src/loggers.rs index dcbd0e1..e5c8573 100644 --- a/src/loggers.rs +++ b/src/loggers.rs @@ -80,7 +80,7 @@ pub struct FilteringLogger<'a, L> { } impl<'a, L> FilteringLogger<'a, L> { - pub const fn new(logger: &'a L, max_level: Level) -> Self { + pub fn new(logger: &'a L, max_level: Level) -> Self { Self { logger, max_level } } } @@ -104,7 +104,6 @@ pub struct StoringLogger { } impl StoringLogger { - #[must_use] pub fn new() -> Self { Self::default() } diff --git a/src/setup/mod.rs b/src/setup/mod.rs index a187a88..cca4db8 100644 --- a/src/setup/mod.rs +++ b/src/setup/mod.rs @@ -7,6 +7,5 @@ pub use symbol_runner::{ SymbolRunner, }; mod runnable; -#[allow(clippy::module_inception)] mod setup; pub use setup::SetupFacade as Setup; diff --git a/src/setup/runnable.rs b/src/setup/runnable.rs index 4e3e087..add3f49 100644 --- a/src/setup/runnable.rs +++ b/src/setup/runnable.rs @@ -16,7 +16,6 @@ pub trait Runnable { } #[async_trait(?Send)] -#[allow(clippy::use_self)] impl Runnable for S where Self: Symbol + Debug, diff --git a/src/setup/setup.rs b/src/setup/setup.rs index 472d52e..842152b 100644 --- a/src/setup/setup.rs +++ b/src/setup/setup.rs @@ -242,9 +242,7 @@ mod test { fn from_artifact(_from: ()) -> Self { Self } - #[allow(clippy::unused_unit)] fn into_artifact(self) -> () { - #[allow(clippy::unused_unit)] () } } diff --git a/src/storage.rs b/src/storage.rs index aa4ce9d..a963414 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -14,7 +14,6 @@ pub trait Storage { pub struct SimpleStorage(PathBuf); impl SimpleStorage { - #[must_use] pub const fn new(base: PathBuf) -> Self { Self(base) } diff --git a/src/symbols/dir.rs b/src/symbols/dir.rs index 1a60af2..f9fdacc 100644 --- a/src/symbols/dir.rs +++ b/src/symbols/dir.rs @@ -11,7 +11,7 @@ pub struct Dir

{ } impl

Dir

{ - pub const fn new(path: P) -> Self { + pub fn new(path: P) -> Self { Self { path } } } diff --git a/src/symbols/file.rs b/src/symbols/file.rs index a3763c1..edff275 100644 --- a/src/symbols/file.rs +++ b/src/symbols/file.rs @@ -12,7 +12,7 @@ pub struct File { } impl File { - pub const fn new(path: D, content: C) -> Self { + pub fn new(path: D, content: C) -> Self { Self { path, content } } } diff --git a/src/symbols/git/submodules.rs b/src/symbols/git/submodules.rs index 5413b8d..e35eabf 100644 --- a/src/symbols/git/submodules.rs +++ b/src/symbols/git/submodules.rs @@ -13,7 +13,7 @@ pub struct GitSubmodules<'a, P, C> { } impl<'a, P, C> GitSubmodules<'a, P, C> { - pub const fn new(target: P, command_runner: &'a C) -> Self { + pub fn new(target: P, command_runner: &'a C) -> Self { Self { target, command_runner, diff --git a/src/symbols/mariadb/dump.rs b/src/symbols/mariadb/dump.rs index 1b503fa..8276532 100644 --- a/src/symbols/mariadb/dump.rs +++ b/src/symbols/mariadb/dump.rs @@ -34,8 +34,8 @@ impl<'a, N, C: CommandRunner, S> Dump<'a, N, C, S> { impl, C: CommandRunner, S: Storage> Symbol for Dump<'_, N, C, S> { async fn target_reached(&self) -> Result> { let dump_date = self.storage.recent_date()?; - let output = self.run_sql(&format!("select UNIX_TIMESTAMP(MAX(UPDATE_TIME)) from information_schema.tables WHERE table_schema = '{}'", self.db_name.as_ref())).await?; - let modified_date = output.trim_end(); + let _modified_date = self.run_sql(&format!("select UNIX_TIMESTAMP(MAX(UPDATE_TIME)) from information_schema.tables WHERE table_schema = '{}'", self.db_name.as_ref())).await?; + let modified_date = _modified_date.trim_end(); Ok(modified_date != "NULL" && u64::from_str(modified_date)? <= dump_date) } diff --git a/src/symbols/systemd/user_session.rs b/src/symbols/systemd/user_session.rs index 1f41d46..5de3342 100644 --- a/src/symbols/systemd/user_session.rs +++ b/src/symbols/systemd/user_session.rs @@ -11,7 +11,7 @@ pub struct UserSession<'a, U, C> { } impl<'a, U, C> UserSession<'a, U, C> { - pub const fn new(user_name: U, command_runner: &'a C) -> Self { + pub fn new(user_name: U, command_runner: &'a C) -> Self { Self { user_name, command_runner, diff --git a/src/symbols/tls/csr.rs b/src/symbols/tls/csr.rs index 4af3683..3b35681 100644 --- a/src/symbols/tls/csr.rs +++ b/src/symbols/tls/csr.rs @@ -14,7 +14,7 @@ pub struct Csr { } impl Csr { - pub const fn new(command_runner: C, domain: D, key_path: K, csr_path: P) -> Self { + pub fn new(command_runner: C, domain: D, key_path: K, csr_path: P) -> Self { Self { command_runner, domain, diff --git a/src/symbols/tls/key.rs b/src/symbols/tls/key.rs index 720d7ab..c5287c0 100644 --- a/src/symbols/tls/key.rs +++ b/src/symbols/tls/key.rs @@ -8,17 +8,19 @@ use std::path::Path; pub struct Key { file_path: P, command_runner: C, - bytes: u32, } impl Key { - pub const fn new(command_runner: C, file_path: P) -> Self { + pub fn new(command_runner: C, file_path: P) -> Self { Self { file_path, command_runner, - bytes: 4096, } } + + fn get_bytes(&self) -> u32 { + 4096 + } } #[async_trait(?Send)] @@ -55,7 +57,7 @@ impl> Symbol for Key { "genrsa", "-out", self.file_path.as_ref(), - self.bytes.to_string(), + self.get_bytes().to_string(), ], ) .await diff --git a/src/symbols/user.rs b/src/symbols/user.rs index db784a7..3c67809 100644 --- a/src/symbols/user.rs +++ b/src/symbols/user.rs @@ -15,7 +15,7 @@ pub struct User { } impl User { - pub const fn new(user_name: U, command_runner: C) -> Self { + pub fn new(user_name: U, command_runner: C) -> Self { Self { user_name, command_runner, diff --git a/src/templates/nginx/server.rs b/src/templates/nginx/server.rs index 9f04bbd..fe7aa60 100644 --- a/src/templates/nginx/server.rs +++ b/src/templates/nginx/server.rs @@ -1,7 +1,6 @@ use std::fmt::Display; use std::path::Path; -#[must_use] pub fn default_server>(challenges_snippet_path: P) -> String { format!( "server {{ @@ -13,7 +12,6 @@ pub fn default_server>(challenges_snippet_path: P) -> String { ) } -#[must_use] pub fn server_config, K: AsRef, T: Display, S: AsRef>( domain: D, cert_path: C, @@ -55,7 +53,6 @@ server {{ ) } -#[must_use] pub fn php_snippet, STATIC: AsRef>( index: &'static str, socket_path: SOCKET, @@ -74,7 +71,6 @@ pub fn php_snippet, STATIC: AsRef>( ) } -#[must_use] pub fn redir_snippet(target: &str) -> String { format!( "location / {{ @@ -89,7 +85,6 @@ pub trait SocketSpec { } impl> SocketSpec for T { - #[must_use] fn to_nginx(&self) -> String { format!("unix:{}:", self.as_ref().to_str().unwrap()) } @@ -99,20 +94,17 @@ impl> SocketSpec for T { pub struct LocalTcpSocket(usize); impl LocalTcpSocket { - #[must_use] pub const fn new(x: usize) -> Self { Self(x) } } impl SocketSpec for LocalTcpSocket { - #[must_use] fn to_nginx(&self) -> String { format!("localhost:{}", self.0) } } -#[must_use] pub fn proxy_snippet>( socket_path: &S, static_path: STATIC, @@ -133,7 +125,6 @@ pub fn proxy_snippet>( ) } -#[must_use] pub fn static_snippet>(static_path: S) -> String { format!( "root {}; @@ -143,7 +134,6 @@ pub fn static_snippet>(static_path: S) -> String { ) } -#[must_use] pub fn dokuwiki_snippet() -> String { " location ~ /(data/|conf/|bin/|inc/|install.php) { deny all; } @@ -159,7 +149,6 @@ pub fn dokuwiki_snippet() -> String { }".into() } -#[must_use] pub fn nextcloud_snippet() -> String { " client_max_body_size 500M;