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>(
}
// Batch response.
else if let Ok(batch) = serde_json::from_slice::<Vec<Response<_>>>(raw) {
if let Err(e) = process_batch_response(manager, batch) {
return Err(e);
}
process_batch_response(manager, batch)?;
}
// Error response
else if let Ok(err) = serde_json::from_slice::<ErrorResponse>(raw) {
if let Err(e) = process_error_response(manager, err) {
return Err(e);
}
process_error_response(manager, err)?;
}
// Unparsable response
else {
......
......@@ -290,20 +290,20 @@ impl RpcDescription {
is_sub = true;
if is_method {
return Err(syn::Error::new_spanned(
&method,
method,
"Element cannot be both subscription and method at the same time",
));
}
if !matches!(method.sig.output, syn::ReturnType::Default) {
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`",
));
}
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())?;
......@@ -312,12 +312,12 @@ impl RpcDescription {
if !is_method && !is_sub {
return Err(syn::Error::new_spanned(
&method,
method,
"Methods must have either 'method' or 'subscription' attribute",
));
}
} 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
/// Returns true if the `content_type` header indicates a valid JSON message.
pub(crate) fn is_json(content_type: Option<&hyper::header::HeaderValue>) -> bool {
match content_type.and_then(|val| val.to_str().ok()) {
Some(content)
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") =>
{
true
}
_ => false,
}
content_type.and_then(|val| val.to_str().ok()).map_or(false, |content| {
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")
})
}
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