Browse Source

Format and clippy

master
Adrian Heine 5 years ago
parent
commit
bc4a898c0a
  1. 3
      src/lib.rs
  2. 2
      src/resources/mod.rs
  3. 2
      src/schema.rs
  4. 2
      src/storage.rs
  5. 12
      src/symbols/acme/user.rs
  6. 2
      src/symbols/dir.rs
  7. 1
      src/symbols/factory.rs
  8. 2
      src/symbols/file.rs
  9. 2
      src/symbols/hook.rs
  10. 10
      src/symbols/nginx/server.rs
  11. 1
      src/symbols/owner.rs
  12. 5
      src/symbols/systemd/user_service.rs

3
src/lib.rs

@ -7,7 +7,8 @@
unused_extern_crates, unused_extern_crates,
unused_import_braces, unused_import_braces,
unused_qualifications, unused_qualifications,
variant_size_differences
variant_size_differences,
clippy::use_self
)] )]
#![warn(unused_results)] #![warn(unused_results)]
/* /*

2
src/resources/mod.rs

@ -3,7 +3,7 @@ pub struct Resource(pub String, pub String);
impl<'a> Resource { impl<'a> Resource {
pub fn new<A: Into<String>, B: Into<String>>(rtype: A, value: B) -> Self { pub fn new<A: Into<String>, B: Into<String>>(rtype: A, value: B) -> Self {
Resource(rtype.into(), value.into())
Self(rtype.into(), value.into())
} }
pub fn get_type(&self) -> &str { pub fn get_type(&self) -> &str {

2
src/schema.rs

@ -144,7 +144,7 @@ where
R: SymbolRunner, R: SymbolRunner,
{ {
pub fn new(symbol_runner: R) -> Self { pub fn new(symbol_runner: R) -> Self {
NonRepeatingSymbolRunner {
Self {
upstream: symbol_runner, upstream: symbol_runner,
done: RefCell::new(HashSet::new()), done: RefCell::new(HashSet::new()),
} }

2
src/storage.rs

@ -14,7 +14,7 @@ pub struct SimpleStorage(String, String);
impl SimpleStorage { impl SimpleStorage {
pub fn new(base: String, filename: String) -> Self { pub fn new(base: String, filename: String) -> Self {
SimpleStorage(base, filename)
Self(base, filename)
} }
fn get_path(&self, date: Option<u64>) -> String { fn get_path(&self, date: Option<u64>) -> String {

12
src/symbols/acme/user.rs

@ -18,17 +18,9 @@ pub fn new<'a, R: CommandRunner, C: 'a + AsRef<str>, U: 'a + AsRef<str> + Clone,
let account_key_file = path("account.key"); let account_key_file = path("account.key");
List::from(( List::from((
AcmeAccountKey::new(account_key_file.clone(), command_runner), AcmeAccountKey::new(account_key_file.clone(), command_runner),
Owner::new(
account_key_file,
user_name.clone(),
command_runner,
),
Owner::new(account_key_file, user_name.clone(), command_runner),
Dir::new(path("challenges")), Dir::new(path("challenges")),
Owner::new(
path("challenges"),
user_name.clone(),
command_runner,
),
Owner::new(path("challenges"), user_name.clone(), command_runner),
Dir::new("/etc/ssl/local_certs"), Dir::new("/etc/ssl/local_certs"),
Owner::new("/etc/ssl/local_certs", user_name, command_runner), Owner::new("/etc/ssl/local_certs", user_name, command_runner),
File::new(path("lets_encrypt_x3_cross_signed.pem"), cert), File::new(path("lets_encrypt_x3_cross_signed.pem"), cert),

2
src/symbols/dir.rs

@ -13,7 +13,7 @@ pub struct Dir<D: AsRef<Path>> {
impl<D: AsRef<Path>> Dir<D> { impl<D: AsRef<Path>> Dir<D> {
pub fn new(path: D) -> Self { pub fn new(path: D) -> Self {
Dir { path }
Self { path }
} }
} }

1
src/symbols/factory.rs

@ -1,5 +1,4 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::path::Path; use std::path::Path;
use std::path::PathBuf; use std::path::PathBuf;

2
src/symbols/file.rs

@ -16,7 +16,7 @@ pub struct File<C: AsRef<str>, D: AsRef<Path>> {
impl<C: AsRef<str>, D: AsRef<Path>> File<C, D> { impl<C: AsRef<str>, D: AsRef<Path>> File<C, D> {
pub fn new(path: D, content: C) -> Self { pub fn new(path: D, content: C) -> Self {
File { path, content }
Self { path, content }
} }
} }

2
src/symbols/hook.rs

@ -20,7 +20,7 @@ where
B: Symbol, B: Symbol,
{ {
pub fn new(a: A, b: B) -> Self { pub fn new(a: A, b: B) -> Self {
Hook { a, b }
Self { a, b }
} }
} }

10
src/symbols/nginx/server.rs

@ -15,7 +15,7 @@ pub enum NginxServerError<E: Error> {
} }
impl From<io::Error> for NginxServerError<io::Error> { impl From<io::Error> for NginxServerError<io::Error> {
fn from(err: io::Error) -> NginxServerError<io::Error> {
fn from(err: io::Error) -> Self {
NginxServerError::ExecError(err) NginxServerError::ExecError(err)
} }
} }
@ -23,8 +23,8 @@ impl From<io::Error> for NginxServerError<io::Error> {
impl<E: Error> Error for NginxServerError<E> { impl<E: Error> Error for NginxServerError<E> {
fn description(&self) -> &str { fn description(&self) -> &str {
match self { match self {
NginxServerError::ExecError(ref e) => e.description(),
NginxServerError::GenericError => "Generic error",
Self::ExecError(ref e) => e.description(),
Self::GenericError => "Generic error",
} }
} }
fn cause(&self) -> Option<&dyn Error> { fn cause(&self) -> Option<&dyn Error> {
@ -75,7 +75,7 @@ server {{
) )
} }
pub fn php_server_config_snippet<'a, SOCKET: AsRef<Path>, STATIC: AsRef<Path>>(
pub fn php_server_config_snippet<SOCKET: AsRef<Path>, STATIC: AsRef<Path>>(
socket_path: SOCKET, socket_path: SOCKET,
static_path: STATIC, static_path: STATIC,
) -> String { ) -> String {
@ -109,7 +109,7 @@ pub struct LocalTcpSocket(usize);
impl LocalTcpSocket { impl LocalTcpSocket {
pub fn new(x: usize) -> Self { pub fn new(x: usize) -> Self {
LocalTcpSocket(x)
Self(x)
} }
} }

1
src/symbols/owner.rs

@ -1,4 +1,3 @@
use std::error::Error; use std::error::Error;
use std::fmt; use std::fmt;

5
src/symbols/systemd/user_service.rs

@ -3,7 +3,6 @@ use std::error::Error;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::fmt; use std::fmt;
use std::io; use std::io;
use std::path::Path; use std::path::Path;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Output; use std::process::Output;
@ -23,8 +22,8 @@ pub enum UserServiceError<E: Error> {
} }
impl From<io::Error> for UserServiceError<io::Error> { impl From<io::Error> for UserServiceError<io::Error> {
fn from(err: io::Error) -> UserServiceError<io::Error> {
UserServiceError::ExecError(err)
fn from(err: io::Error) -> Self {
Self::ExecError(err)
} }
} }

Loading…
Cancel
Save