Update Rust Edition to 2024 (#7766)

* #7749

Thanks @dknopik and @michaelsproul for your help!
This commit is contained in:
chonghe
2025-08-13 11:04:31 +08:00
committed by GitHub
parent bd6b8b6a65
commit 522bd9e9c6
468 changed files with 3594 additions and 3396 deletions

View File

@@ -20,12 +20,12 @@ pub fn json<T: DeserializeOwned + Send>() -> impl Filter<Extract = (T,), Error =
warp::header::optional::<String>(CONTENT_TYPE_HEADER)
.and(warp::body::bytes())
.and_then(|header: Option<String>, bytes: Bytes| async move {
if let Some(header) = header {
if header == SSZ_CONTENT_TYPE_HEADER {
return Err(reject::unsupported_media_type(
"The request's content-type is not supported".to_string(),
));
}
if let Some(header) = header
&& header == SSZ_CONTENT_TYPE_HEADER
{
return Err(reject::unsupported_media_type(
"The request's content-type is not supported".to_string(),
));
}
Json::decode(bytes)
.map_err(|err| reject::custom_deserialize_error(format!("{:?}", err)))
@@ -33,17 +33,17 @@ pub fn json<T: DeserializeOwned + Send>() -> impl Filter<Extract = (T,), Error =
}
// Add a json_no_body function to handle the case when no body is provided in the HTTP request
pub fn json_no_body<T: DeserializeOwned + Default + Send>(
) -> impl Filter<Extract = (T,), Error = Rejection> + Copy {
pub fn json_no_body<T: DeserializeOwned + Default + Send>()
-> impl Filter<Extract = (T,), Error = Rejection> + Copy {
warp::header::optional::<String>(CONTENT_TYPE_HEADER)
.and(warp::body::bytes())
.and_then(|header: Option<String>, bytes: Bytes| async move {
if let Some(header) = header {
if header == SSZ_CONTENT_TYPE_HEADER {
return Err(reject::unsupported_media_type(
"The request's content-type is not supported".to_string(),
));
}
if let Some(header) = header
&& header == SSZ_CONTENT_TYPE_HEADER
{
return Err(reject::unsupported_media_type(
"The request's content-type is not supported".to_string(),
));
}
// Handle the case when the HTTP request has no body, i.e., without the -d header

View File

@@ -4,8 +4,8 @@ use warp::Filter;
// Custom query filter using `serde_array_query`.
// This allows duplicate keys inside query strings.
pub fn multi_key_query<'de, T: Deserialize<'de>>(
) -> impl warp::Filter<Extract = (Result<T, warp::Rejection>,), Error = std::convert::Infallible> + Copy
pub fn multi_key_query<'de, T: Deserialize<'de>>()
-> impl warp::Filter<Extract = (Result<T, warp::Rejection>,), Error = std::convert::Infallible> + Copy
{
raw_query().then(|query_str: String| async move {
serde_array_query::from_str(&query_str).map_err(|e| custom_bad_request(e.to_string()))

View File

@@ -3,7 +3,7 @@ use std::convert::Infallible;
use std::error::Error;
use std::fmt;
use std::fmt::Debug;
use warp::{http::StatusCode, reject::Reject, reply::Response, Reply};
use warp::{Reply, http::StatusCode, reject::Reject, reply::Response};
#[derive(Debug)]
pub struct ServerSentEventError(pub String);

View File

@@ -1,4 +1,4 @@
use warp::{filters::BoxedFilter, Filter, Rejection};
use warp::{Filter, Rejection, filters::BoxedFilter};
/// Mixin trait for `Filter` providing the unifying-or method.
pub trait UnifyingOrFilter: Filter<Error = Rejection> + Sized + Send + Sync + 'static