diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/args.rs | 8 | ||||
-rw-r--r-- | src/auth.rs | 6 | ||||
-rw-r--r-- | src/config.rs | 4 | ||||
-rw-r--r-- | src/listing.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 12 | ||||
-rw-r--r-- | src/renderer.rs | 22 |
6 files changed, 27 insertions, 27 deletions
diff --git a/src/args.rs b/src/args.rs index 4ba5f24..243eecf 100644 --- a/src/args.rs +++ b/src/args.rs @@ -239,7 +239,7 @@ fn parse_auth(src: &str) -> Result<auth::RequiredAuth, ContextualError> { /// Custom header parser (allow multiple headers input) pub fn parse_header(src: &str) -> Result<HeaderMap, httparse::Error> { let mut headers = [httparse::EMPTY_HEADER; 1]; - let header = format!("{}\n", src); + let header = format!("{src}\n"); httparse::parse_headers(header.as_bytes(), &mut headers)?; let mut header_map = HeaderMap::new(); @@ -269,8 +269,8 @@ mod tests { let password = match encrypt { "plain" => Plain(password.to_owned()), - "sha256" => Sha256(hex::decode(password.to_owned()).unwrap()), - "sha512" => Sha512(hex::decode(password.to_owned()).unwrap()), + "sha256" => Sha256(hex::decode(password).unwrap()), + "sha512" => Sha512(hex::decode(password).unwrap()), _ => panic!("Unknown encryption type"), }; @@ -314,6 +314,6 @@ mod tests { )] fn parse_auth_invalid(auth_string: &str, err_msg: &str) { let err = parse_auth(auth_string).unwrap_err(); - assert_eq!(format!("{}", err), err_msg.to_owned()); + assert_eq!(format!("{err}"), err_msg.to_owned()); } } diff --git a/src/auth.rs b/src/auth.rs index c7d0b78..92157c9 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -114,7 +114,7 @@ mod tests { fn test_get_hash(password: &str, hash_method: &str, hash: &str) { let hash_func = get_hash_func(hash_method); let expected = hex::decode(hash).expect("Provided hash is not a valid hex code"); - let received = hash_func(&password.to_owned()); + let received = hash_func(password); assert_eq!(received, expected); } @@ -124,8 +124,8 @@ mod tests { let password = match encrypt { "plain" => Plain(password.to_owned()), - "sha256" => Sha256(get_hash::<sha2::Sha256>(&password.to_owned())), - "sha512" => Sha512(get_hash::<sha2::Sha512>(&password.to_owned())), + "sha256" => Sha256(get_hash::<sha2::Sha256>(password)), + "sha512" => Sha512(get_hash::<sha2::Sha512>(password)), _ => panic!("Unknown encryption type"), }; diff --git a/src/config.rs b/src/config.rs index 9223dec..d3f125f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -190,10 +190,10 @@ impl MiniserveConfig { { let cert_file = &mut BufReader::new( File::open(&tls_cert) - .context(format!("Couldn't access TLS certificate {:?}", tls_cert))?, + .context(format!("Couldn't access TLS certificate {tls_cert:?}"))?, ); let key_file = &mut BufReader::new( - File::open(&tls_key).context(format!("Couldn't access TLS key {:?}", tls_key))?, + File::open(&tls_key).context(format!("Couldn't access TLS key {tls_key:?}"))?, ); let cert_chain = pemfile::certs(cert_file).context("Reading cert file")?; let key = pemfile::read_all(key_file) diff --git a/src/listing.rs b/src/listing.rs index bca531a..ba4789a 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -368,7 +368,7 @@ pub fn directory_listing( .append_header(("Content-Transfer-Encoding", "binary")) .append_header(( "Content-Disposition", - format!("attachment; filename={:?}", file_name), + format!("attachment; filename={file_name:?}"), )) .body(actix_web::body::BodyStream::new(rx)), )) diff --git a/src/main.rs b/src/main.rs index e2d34e9..cf02025 100644 --- a/src/main.rs +++ b/src/main.rs @@ -123,7 +123,7 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> { .flush() .map_err(|e| ContextualError::IoError("Failed to write data".to_string(), e))?; for c in "3… 2… 1… \n".chars() { - print!("{}", c); + print!("{c}"); io::stdout() .flush() .map_err(|e| ContextualError::IoError("Failed to write data".to_string(), e))?; @@ -161,8 +161,8 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> { IpAddr::V6(_) => format!("[{}]:{}", addr, miniserve_config.port), }) .map(|addr| match miniserve_config.tls_rustls_config { - Some(_) => format!("https://{}", addr), - None => format!("http://{}", addr), + Some(_) => format!("https://{addr}"), + None => format!("http://{addr}"), }) .map(|url| format!("{}{}", url, miniserve_config.route_prefix)) .collect::<Vec<_>>() @@ -202,7 +202,7 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> { let srv = socket_addresses.iter().try_fold(srv, |srv, addr| { let listener = create_tcp_listener(*addr).map_err(|e| { - ContextualError::IoError(format!("Failed to bind server to {}", addr), e) + ContextualError::IoError(format!("Failed to bind server to {addr}"), e) })?; #[cfg(feature = "tls")] @@ -214,7 +214,7 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> { #[cfg(not(feature = "tls"))] let srv = srv.listen(listener); - srv.map_err(|e| ContextualError::IoError(format!("Failed to bind server to {}", addr), e)) + srv.map_err(|e| ContextualError::IoError(format!("Failed to bind server to {addr}"), e)) })?; let srv = srv.shutdown_timeout(0).run(); @@ -297,7 +297,7 @@ fn configure_app(app: &mut web::ServiceConfig, conf: &MiniserveConfig) { // Note: --spa requires --index in clap. if conf.spa { files = files.default_handler( - NamedFile::open(&conf.path.join(index_file)) + NamedFile::open(conf.path.join(index_file)) .expect("Can't open SPA index file."), ); } diff --git a/src/renderer.rs b/src/renderer.rs index 5ba69a2..0937be4 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -47,7 +47,7 @@ pub fn page( || conf .allowed_upload_dir .iter() - .any(|x| encoded_dir.starts_with(&format!("/{}", x))); + .any(|x| encoded_dir.starts_with(&format!("/{x}"))); html! { (DOCTYPE) @@ -286,7 +286,7 @@ fn wget_footer(title_path: &str, current_user: Option<&CurrentUser>) -> Markup { html! { div.downloadDirectory { p { "Download folder:" } - div.cmd { (format!("wget -r -c -nH -np --cut-dirs={} -R \"index.html*\"{} \"http://{}/?raw=true\"", count, user_params, title_path)) } + div.cmd { (format!("wget -r -c -nH -np --cut-dirs={count} -R \"index.html*\"{user_params} \"http://{title_path}/?raw=true\"")) } } } } @@ -298,7 +298,7 @@ fn build_upload_action( sort_method: Option<SortingMethod>, sort_order: Option<SortingOrder>, ) -> String { - let mut upload_action = format!("{}?path={}", upload_route, encoded_dir); + let mut upload_action = format!("{upload_route}?path={encoded_dir}"); if let Some(sorting_method) = sort_method { upload_action = format!("{}&sort={}", upload_action, &sorting_method); } @@ -311,7 +311,7 @@ fn build_upload_action( /// Build the action of the mkdir form fn build_mkdir_action(mkdir_route: &str, encoded_dir: &str) -> String { - format!("{}?path={}", mkdir_route, encoded_dir) + format!("{mkdir_route}?path={encoded_dir}") } const THEME_PICKER_CHOICES: &[(&str, &str)] = &[ @@ -345,7 +345,7 @@ fn qr_spoiler(show_qrcode: bool, content: impl AsRef<str>) -> Markup { div.qrcode #qrcode title=(PreEscaped(content.as_ref())) { @match qr_code_svg(content, consts::SVG_QR_MARGIN) { Ok(svg) => (PreEscaped(svg)), - Err(err) => (format!("QR generation error: {:?}", err)), + Err(err) => (format!("QR generation error: {err:?}")), } } } @@ -391,7 +391,7 @@ fn archive_button( sort_order: Option<SortingOrder>, ) -> Markup { let link = if sort_method.is_none() && sort_order.is_none() { - format!("?download={}", archive_method) + format!("?download={archive_method}") } else { format!( "{}&download={}", @@ -414,7 +414,7 @@ fn make_link_with_trailing_slash(link: &str) -> String { if link.ends_with('/') { link.to_string() } else { - format!("{}/", link) + format!("{link}/") } } @@ -452,8 +452,8 @@ fn build_link( sort_method: Option<SortingMethod>, sort_order: Option<SortingOrder>, ) -> Markup { - let mut link = format!("?sort={}&order=asc", name); - let mut help = format!("Sort by {} in ascending order", name); + let mut link = format!("?sort={name}&order=asc"); + let mut help = format!("Sort by {name} in ascending order"); let mut chevron = chevron_up(); let mut class = ""; @@ -462,8 +462,8 @@ fn build_link( class = "active"; if let Some(order) = sort_order { if order.to_string() == "asc" { - link = format!("?sort={}&order=desc", name); - help = format!("Sort by {} in descending order", name); + link = format!("?sort={name}&order=desc"); + help = format!("Sort by {name} in descending order"); chevron = chevron_down(); } } |