aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2025-03-07 02:21:16 +0000
committerSven-Hendrik Haase <svenstaro@gmail.com>2025-03-07 02:21:16 +0000
commit1aa49ab2f008099a3de380a7e146a97dedb9873d (patch)
treeeefe8d8261ffa92ff08e0b3d6fc5f9649d502fa9
parentAdd CHANGELOG entry for healthcheck route (diff)
downloadminiserve-1aa49ab2f008099a3de380a7e146a97dedb9873d.tar.gz
miniserve-1aa49ab2f008099a3de380a7e146a97dedb9873d.zip
Upgrade to Rust 2024 edition
-rw-r--r--Cargo.toml3
-rw-r--r--src/auth.rs2
-rw-r--r--src/config.rs4
-rw-r--r--src/errors.rs2
-rw-r--r--src/file_op.rs10
-rw-r--r--src/main.rs15
-rw-r--r--src/webdav_fs.rs2
-rw-r--r--tests/serve_request.rs2
8 files changed, 22 insertions, 18 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 40c2250..1525849 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,8 +8,7 @@ license = "MIT"
readme = "README.md"
keywords = ["serve", "http-server", "static-files", "http", "server"]
categories = ["command-line-utilities", "network-programming", "web-programming::http-server"]
-edition = "2021"
-resolver = "2"
+edition = "2024"
[profile.release]
codegen-units = 1
diff --git a/src/auth.rs b/src/auth.rs
index ef16b0c..fa28c4a 100644
--- a/src/auth.rs
+++ b/src/auth.rs
@@ -1,4 +1,4 @@
-use actix_web::{dev::ServiceRequest, HttpMessage};
+use actix_web::{HttpMessage, dev::ServiceRequest};
use actix_web_httpauth::extractors::basic::BasicAuth;
use sha2::{Digest, Sha256, Sha512};
diff --git a/src/config.rs b/src/config.rs
index 7d491c4..efec515 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -6,13 +6,13 @@ use std::{
};
use actix_web::http::header::HeaderMap;
-use anyhow::{anyhow, Context, Result};
+use anyhow::{Context, Result, anyhow};
#[cfg(feature = "tls")]
use rustls_pemfile as pemfile;
use crate::{
- args::{parse_auth, CliArgs, MediaType},
+ args::{CliArgs, MediaType, parse_auth},
auth::RequiredAuth,
file_utils::sanitize_path,
listing::{SortingMethod, SortingOrder},
diff --git a/src/errors.rs b/src/errors.rs
index b7d75f2..f1e5b2d 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -125,7 +125,7 @@ impl ResponseError for RuntimeError {
pub fn error_page_middleware<S, B>(
req: ServiceRequest,
srv: &S,
-) -> impl Future<Output = actix_web::Result<ServiceResponse>> + 'static
+) -> impl Future<Output = actix_web::Result<ServiceResponse>> + 'static + use<S, B>
where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error>,
B: MessageBody + 'static,
diff --git a/src/file_op.rs b/src/file_op.rs
index afd6449..4319410 100644
--- a/src/file_op.rs
+++ b/src/file_op.rs
@@ -3,7 +3,7 @@
use std::io::ErrorKind;
use std::path::{Component, Path, PathBuf};
-use actix_web::{http::header, web, HttpRequest, HttpResponse};
+use actix_web::{HttpRequest, HttpResponse, http::header, web};
use futures::{StreamExt, TryStreamExt};
use log::{info, warn};
use serde::Deserialize;
@@ -152,7 +152,9 @@ async fn save_file(
if let Some(expected_hash) = file_checksum.as_ref().map(|f| f.get_hash()) {
let actual_hash = hex::encode(hasher.finalize());
if actual_hash != expected_hash {
- warn!("The expected file hash {expected_hash} did not match the calculated hash of {actual_hash}. This can be caused if a file upload was aborted.");
+ warn!(
+ "The expected file hash {expected_hash} did not match the calculated hash of {actual_hash}. This can be caused if a file upload was aborted."
+ );
let _ = tokio::fs::remove_file(&temp_path).await;
return Err(RuntimeError::UploadHashMismatchError);
}
@@ -235,7 +237,7 @@ async fn handle_multipart(
return Err(RuntimeError::ParseError(
"Failed to parse 'mkdir' path".to_string(),
"".to_string(),
- ))
+ ));
}
};
@@ -374,7 +376,7 @@ pub async fn upload_file(
sha => {
return Err(RuntimeError::InvalidHttpRequestError(format!(
"Invalid header value found for 'X-File-Hash-Function'. Supported values are SHA256 or SHA512. Found {sha}.",
- )))
+ )));
}
}
} else {
diff --git a/src/main.rs b/src/main.rs
index 688aed1..0248c7b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -5,18 +5,19 @@ use std::time::Duration;
use actix_files::NamedFile;
use actix_web::{
- dev::{fn_service, ServiceRequest, ServiceResponse},
+ App, HttpRequest, HttpResponse, Responder,
+ dev::{ServiceRequest, ServiceResponse, fn_service},
guard,
- http::{header::ContentType, Method},
- middleware, web, App, HttpRequest, HttpResponse, Responder,
+ http::{Method, header::ContentType},
+ middleware, web,
};
use actix_web_httpauth::middleware::HttpAuthentication;
use anyhow::Result;
-use clap::{crate_version, CommandFactory, Parser};
+use clap::{CommandFactory, Parser, crate_version};
use colored::*;
use dav_server::{
- actix::{DavRequest, DavResponse},
DavConfig, DavHandler, DavMethodSet,
+ actix::{DavRequest, DavResponse},
};
use fast_qr::QRBuilder;
use log::{error, warn};
@@ -134,7 +135,9 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), StartupError> {
return Err(StartupError::NoExplicitPathAndNoTerminal);
}
- warn!("miniserve has been invoked without an explicit path so it will serve the current directory after a short delay.");
+ warn!(
+ "miniserve has been invoked without an explicit path so it will serve the current directory after a short delay."
+ );
warn!(
"Invoke with -h|--help to see options or invoke as `miniserve .` to hide this advice."
);
diff --git a/src/webdav_fs.rs b/src/webdav_fs.rs
index cf434ba..d21a534 100644
--- a/src/webdav_fs.rs
+++ b/src/webdav_fs.rs
@@ -54,7 +54,7 @@ impl DavFileSystem for RestrictedFs {
Box::pin(self.local.read_dir(path, meta).map_ok(|stream| {
let dyn_stream: FsStream<Box<dyn DavDirEntry>> = Box::pin(stream.filter(|entry| {
ready(match entry {
- Ok(ref e) => !e.name().starts_with(b"."),
+ Ok(e) => !e.name().starts_with(b"."),
_ => false,
})
}));
diff --git a/tests/serve_request.rs b/tests/serve_request.rs
index 2910074..6ee6473 100644
--- a/tests/serve_request.rs
+++ b/tests/serve_request.rs
@@ -86,7 +86,7 @@ fn serves_requests_for_special_routes(
#[case] route: &str,
#[case] server: TestServer,
) -> Result<(), Error> {
- let body = reqwest::blocking::get(format!("{}{}", server.url(), route))?.error_for_status()?;
+ reqwest::blocking::get(format!("{}{}", server.url(), route))?.error_for_status()?;
Ok(())
}