feat: some clippy warnings
Diff
Makefile | 5 +++++
src/core/cache.rs | 6 +++---
src/core/rejection.rs | 7 +++++--
3 files changed, 13 insertions(+), 5 deletions(-)
@@ -34,6 +34,11 @@ dev:
@cargo make --makefile Makefile.toml watch
.PHONY: dev
lint:
@rustc -vV
@cargo clippy --all-features -- -D warnings
.PHONY: lint
build:
@rustc -vV
@cargo build --release --target $(PKG_TARGET)
@@ -8,11 +8,11 @@ const CACHE_EXT_ONE_YEAR: [&str; 30] = [
pub fn control_headers(res: warp::fs::File) -> warp::reply::WithHeader<warp::fs::File> {
let mut max_age = 60 * 60 * 24 as u64;
let mut max_age = 60 * 60 * 24_u64;
if let Some(ext) = res.path().extension() {
if let Some(ext) = ext.to_str() {
if CACHE_EXT_ONE_HOUR.iter().any(|n| *n == ext) {
if CACHE_EXT_ONE_HOUR.iter().any(|x| *x == ext) {
max_age = 60 * 60;
} else if CACHE_EXT_ONE_YEAR.iter().any(|x| *x == ext) {
max_age = 60 * 60 * 24 * 365;
@@ -34,5 +34,5 @@ pub fn control_headers(res: warp::fs::File) -> warp::reply::WithHeader<warp::fs:
fn duration(n: u64) -> u32 {
std::cmp::min(n.clone(), u32::MAX as u64) as u32
std::cmp::min(n, u32::MAX as u64) as u32
}
@@ -7,9 +7,12 @@ use warp::{Rejection, Reply};
pub async fn handle_rejection(err: Rejection) -> Result<impl Reply, Infallible> {
let code = if err.is_not_found() {
StatusCode::NOT_FOUND
} else if let Some(_) = err.find::<warp::filters::body::BodyDeserializeError>() {
} else if err
.find::<warp::filters::body::BodyDeserializeError>()
.is_some()
{
StatusCode::BAD_REQUEST
} else if let Some(_) = err.find::<warp::reject::MethodNotAllowed>() {
} else if err.find::<warp::reject::MethodNotAllowed>().is_some() {
StatusCode::METHOD_NOT_ALLOWED
} else {
StatusCode::INTERNAL_SERVER_ERROR