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