Unverified Commit b5d54142 authored by Niklas Adolfsson's avatar Niklas Adolfsson Committed by GitHub
Browse files

fix clippy warnings (#887)

parent 45c94a27
Pipeline #218876 passed with stages
in 52 minutes and 53 seconds
...@@ -507,15 +507,11 @@ async fn handle_backend_messages<S: TransportSenderT, R: TransportReceiverT>( ...@@ -507,15 +507,11 @@ async fn handle_backend_messages<S: TransportSenderT, R: TransportReceiverT>(
} }
// Batch response. // Batch response.
else if let Ok(batch) = serde_json::from_slice::<Vec<Response<_>>>(raw) { else if let Ok(batch) = serde_json::from_slice::<Vec<Response<_>>>(raw) {
if let Err(e) = process_batch_response(manager, batch) { process_batch_response(manager, batch)?;
return Err(e);
}
} }
// Error response // Error response
else if let Ok(err) = serde_json::from_slice::<ErrorResponse>(raw) { else if let Ok(err) = serde_json::from_slice::<ErrorResponse>(raw) {
if let Err(e) = process_error_response(manager, err) { process_error_response(manager, err)?;
return Err(e);
}
} }
// Unparsable response // Unparsable response
else { else {
......
...@@ -290,20 +290,20 @@ impl RpcDescription { ...@@ -290,20 +290,20 @@ impl RpcDescription {
is_sub = true; is_sub = true;
if is_method { if is_method {
return Err(syn::Error::new_spanned( return Err(syn::Error::new_spanned(
&method, method,
"Element cannot be both subscription and method at the same time", "Element cannot be both subscription and method at the same time",
)); ));
} }
if !matches!(method.sig.output, syn::ReturnType::Default) { if !matches!(method.sig.output, syn::ReturnType::Default) {
return Err(syn::Error::new_spanned( return Err(syn::Error::new_spanned(
&method, method,
"Subscription methods must not return anything; the error must send via subscription via either `SubscriptionSink::reject` or `SubscriptionSink::close`", "Subscription methods must not return anything; the error must send via subscription via either `SubscriptionSink::reject` or `SubscriptionSink::close`",
)); ));
} }
if method.sig.asyncness.is_some() { if method.sig.asyncness.is_some() {
return Err(syn::Error::new_spanned(&method, "Subscription methods must not be `async`")); return Err(syn::Error::new_spanned(method, "Subscription methods must not be `async`"));
} }
let sub_data = RpcSubscription::from_item(attr.clone(), method.clone())?; let sub_data = RpcSubscription::from_item(attr.clone(), method.clone())?;
...@@ -312,12 +312,12 @@ impl RpcDescription { ...@@ -312,12 +312,12 @@ impl RpcDescription {
if !is_method && !is_sub { if !is_method && !is_sub {
return Err(syn::Error::new_spanned( return Err(syn::Error::new_spanned(
&method, method,
"Methods must have either 'method' or 'subscription' attribute", "Methods must have either 'method' or 'subscription' attribute",
)); ));
} }
} else { } else {
return Err(syn::Error::new_spanned(&entry, "Only methods allowed in RPC traits")); return Err(syn::Error::new_spanned(entry, "Only methods allowed in RPC traits"));
} }
} }
......
...@@ -26,16 +26,11 @@ pub(crate) fn content_type_is_json(request: &hyper::Request<hyper::Body>) -> boo ...@@ -26,16 +26,11 @@ pub(crate) fn content_type_is_json(request: &hyper::Request<hyper::Body>) -> boo
/// Returns true if the `content_type` header indicates a valid JSON message. /// Returns true if the `content_type` header indicates a valid JSON message.
pub(crate) fn is_json(content_type: Option<&hyper::header::HeaderValue>) -> bool { pub(crate) fn is_json(content_type: Option<&hyper::header::HeaderValue>) -> bool {
match content_type.and_then(|val| val.to_str().ok()) { content_type.and_then(|val| val.to_str().ok()).map_or(false, |content| {
Some(content) content.eq_ignore_ascii_case("application/json")
if content.eq_ignore_ascii_case("application/json") || content.eq_ignore_ascii_case("application/json; charset=utf-8")
|| content.eq_ignore_ascii_case("application/json; charset=utf-8") || content.eq_ignore_ascii_case("application/json;charset=utf-8")
|| content.eq_ignore_ascii_case("application/json;charset=utf-8") => })
{
true
}
_ => false,
}
} }
pub(crate) async fn reject_connection(socket: tokio::net::TcpStream) { pub(crate) async fn reject_connection(socket: tokio::net::TcpStream) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment