Skip to content

Commit 1c87df9

Browse files
committed
chore(lint): apply clippy recommendations
1 parent 67c50be commit 1c87df9

File tree

9 files changed

+11
-43
lines changed

9 files changed

+11
-43
lines changed

src/addon/cors.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::config::cors::CorsConfig;
1919
/// Access-Control-Request-Method header
2020
///
2121
/// Refer to CORS here: https://www.w3.org/wiki/CORS
22-
#[derive(Clone, Debug, PartialEq, Eq)]
22+
#[derive(Clone, Debug, Default, PartialEq, Eq)]
2323
pub struct Cors {
2424
/// The Access-Control-Allow-Credentials response header tells browsers
2525
/// whether to expose the response to frontend JavaScript code when the
@@ -160,21 +160,6 @@ impl Cors {
160160
}
161161
}
162162

163-
impl Default for Cors {
164-
fn default() -> Self {
165-
Cors {
166-
allow_origin: None,
167-
allow_methods: None,
168-
allow_headers: None,
169-
allow_credentials: false,
170-
max_age: None,
171-
expose_headers: None,
172-
request_headers: None,
173-
request_method: None,
174-
}
175-
}
176-
}
177-
178163
/// CorsConfig Builder
179164
pub struct CorsBuilder {
180165
config: Cors,

src/addon/file_server/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'a> FileServer {
149149
let entries = read_dir(path).context("Unable to read directory")?;
150150
let mut directory_entries: Vec<DirectoryEntry> = Vec::new();
151151

152-
for entry in entries.into_iter() {
152+
for entry in entries {
153153
let entry = entry.context("Unable to read entry")?;
154154
let metadata = entry.metadata()?;
155155
let created_at = if let Ok(time) = metadata.created() {

src/config/compression.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
use serde::Deserialize;
22

3-
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
3+
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq)]
44
pub struct CompressionConfig {
55
pub gzip: bool,
66
}
7-
8-
impl Default for CompressionConfig {
9-
fn default() -> Self {
10-
CompressionConfig { gzip: false }
11-
}
12-
}

src/config/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl ConfigFile {
3737
Ok(config) => Ok(config),
3838
Err(err) => Err(Error::msg(format!(
3939
"Failed to parse config from file. {}",
40-
err.to_string()
40+
err
4141
))),
4242
}
4343
}

src/config/tls.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use super::util::tls::{load_cert, load_private_key, PrivateKeyAlgorithm};
1010
pub struct TlsConfig {
1111
cert: Vec<Certificate>,
1212
key: PrivateKey,
13+
#[allow(dead_code)]
1314
key_algorithm: PrivateKeyAlgorithm,
1415
}
1516

src/config/util/tls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn load_cert(path: &Path) -> Result<Vec<Certificate>> {
4040
.fill_buf()
4141
.context("Failed to read cerficate bytes.")?;
4242

43-
ensure!(bytes.len() == 0, "The provided certificate is empty");
43+
ensure!(bytes.is_empty(), "The provided certificate is empty");
4444

4545
let mut reader = Reader::init(bytes);
4646

src/server/https.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl Https {
2727
.with_safe_defaults()
2828
.with_no_client_auth()
2929
.with_single_cert(certs, private_key)
30-
.map_err(|err| anyhow::Error::new(err))?;
30+
.map_err(anyhow::Error::new)?;
3131

3232
Ok(Arc::new(config))
3333
}

src/server/middleware/mod.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub type MiddlewareAfter = Box<
4141
+ Sync,
4242
>;
4343

44+
#[derive(Default)]
4445
pub struct Middleware {
4546
before: Vec<MiddlewareBefore>,
4647
after: Vec<MiddlewareAfter>,
@@ -94,15 +95,6 @@ impl Middleware {
9495
}
9596
}
9697

97-
impl Default for Middleware {
98-
fn default() -> Self {
99-
Middleware {
100-
before: Vec::new(),
101-
after: Vec::new(),
102-
}
103-
}
104-
}
105-
10698
impl TryFrom<Arc<Config>> for Middleware {
10799
type Error = Error;
108100

src/server/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,11 @@ impl Server {
7777
server.with_graceful_shutdown(crate::utils::signal::shutdown_signal());
7878

7979
if self.config.verbose() {
80-
println!("Serving HTTP: http://{}", address.to_string());
80+
println!("Serving HTTP: http://{}", address);
8181

8282
if self.config.address().ip() == Ipv4Addr::from_str("0.0.0.0").unwrap() {
8383
if let Ok(ip) = local_ip_address::local_ip() {
84-
println!(
85-
"Local Network IP: http://{}:{}",
86-
ip.to_string(),
87-
self.config.port()
88-
);
84+
println!("Local Network IP: http://{}:{}", ip, self.config.port());
8985
}
9086
}
9187
}
@@ -106,7 +102,7 @@ impl Server {
106102
let server = https_server_builder.make_server(address).await.unwrap();
107103

108104
if self.config.verbose() {
109-
println!("Serving HTTPS: {}", address.to_string());
105+
println!("Serving HTTPS: {}", address);
110106
}
111107

112108
if let Err(e) = server

0 commit comments

Comments
 (0)