Cleaned up cargo clippy warnings (#13011)

* Cleaned up cargo clippy warnings

* Re-add clippy allow statements; don't lowercase variable names
This commit is contained in:
thrykol 2022-08-10 20:29:08 -06:00 committed by GitHub
parent 91e8fcbd38
commit e58b8b14c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 11 deletions

View File

@ -21,7 +21,7 @@ fn into_base_path(input: impl TryInto<Uri, Error=hyper::http::uri::InvalidUri>,
} }
} }
let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?; let host = uri.host().ok_or(ClientInitError::MissingHost)?;
let port = uri.port_u16().map(|x| format!(":{}", x)).unwrap_or_default(); let port = uri.port_u16().map(|x| format!(":{}", x)).unwrap_or_default();
Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/'))) Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/')))
} }
@ -160,7 +160,7 @@ impl<C> Client<DropContextService<HyperClient, C>, C> where
"https" => { "https" => {
let connector = connector.https() let connector = connector.https()
.build() .build()
.map_err(|e| ClientInitError::SslError(e))?; .map_err(ClientInitError::SslError)?;
HyperClient::Https(hyper::client::Client::builder().build(connector)) HyperClient::Https(hyper::client::Client::builder().build(connector))
}, },
_ => { _ => {
@ -212,7 +212,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C
let https_connector = Connector::builder() let https_connector = Connector::builder()
.https() .https()
.build() .build()
.map_err(|e| ClientInitError::SslError(e))?; .map_err(ClientInitError::SslError)?;
Self::try_new_with_connector(base_path, Some("https"), https_connector) Self::try_new_with_connector(base_path, Some("https"), https_connector)
} }
@ -233,7 +233,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C
.https() .https()
.pin_server_certificate(ca_certificate) .pin_server_certificate(ca_certificate)
.build() .build()
.map_err(|e| ClientInitError::SslError(e))?; .map_err(ClientInitError::SslError)?;
Self::try_new_with_connector(base_path, Some("https"), https_connector) Self::try_new_with_connector(base_path, Some("https"), https_connector)
} }
@ -261,7 +261,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C
.pin_server_certificate(ca_certificate) .pin_server_certificate(ca_certificate)
.client_authentication(client_key, client_certificate) .client_authentication(client_key, client_certificate)
.build() .build()
.map_err(|e| ClientInitError::SslError(e))?; .map_err(ClientInitError::SslError)?;
Self::try_new_with_connector(base_path, Some("https"), https_connector) Self::try_new_with_connector(base_path, Some("https"), https_connector)
} }
} }

View File

@ -298,7 +298,7 @@
{{/bodyParam}} {{/bodyParam}}
{{/x-consumes-multipart}} {{/x-consumes-multipart}}
{{/vendorExtensions}} {{/vendorExtensions}}
let header = HeaderValue::from_str(Has::<XSpanIdString>::get(context).0.clone().to_string().as_str()); let header = HeaderValue::from_str(Has::<XSpanIdString>::get(context).0.as_str());
request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header {
Ok(h) => h, Ok(h) => h,
Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e)))
@ -382,7 +382,7 @@
{{/isMap}} {{/isMap}}
{{/headerParams}} {{/headerParams}}
let mut response = client_service.call((request, context.clone())) let response = client_service.call((request, context.clone()))
.map_err(|e| ApiError(format!("No response received: {}", e))).await?; .map_err(|e| ApiError(format!("No response received: {}", e))).await?;
match response.status().as_u16() { match response.status().as_u16() {
@ -415,8 +415,8 @@
}; };
{{/headers}} {{/headers}}
let body = response.into_body();
{{#dataType}} {{#dataType}}
let body = response.into_body();
let body = body let body = body
.into_raw() .into_raw()
.map_err(|e| ApiError(format!("Failed to read response: {}", e))).await?; .map_err(|e| ApiError(format!("Failed to read response: {}", e))).await?;

View File

@ -1,4 +1,5 @@
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
#![allow(unused_imports)]
use async_trait::async_trait; use async_trait::async_trait;
use futures::Stream; use futures::Stream;
@ -9,9 +10,9 @@ use serde::{Serialize, Deserialize};
type ServiceError = Box<dyn Error + Send + Sync + 'static>; type ServiceError = Box<dyn Error + Send + Sync + 'static>;
pub const BASE_PATH: &'static str = "{{{basePathWithoutHost}}}"; pub const BASE_PATH: &str = "{{{basePathWithoutHost}}}";
{{#appVersion}} {{#appVersion}}
pub const API_VERSION: &'static str = "{{{.}}}"; pub const API_VERSION: &str = "{{{.}}}";
{{/appVersion}} {{/appVersion}}
{{#apiInfo}} {{#apiInfo}}
@ -82,7 +83,7 @@ pub trait ApiNoContext<C: Send + Sync> {
pub trait ContextWrapperExt<C: Send + Sync> where Self: Sized pub trait ContextWrapperExt<C: Send + Sync> where Self: Sized
{ {
/// Binds this API to a context. /// Binds this API to a context.
fn with_context(self: Self, context: C) -> ContextWrapper<Self, C>; fn with_context(self, context: C) -> ContextWrapper<Self, C>;
} }
impl<T: Api<C> + Send + Sync, C: Clone + Send + Sync> ContextWrapperExt<C> for T { impl<T: Api<C> + Send + Sync, C: Clone + Send + Sync> ContextWrapperExt<C> for T {