diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/client/mod.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/client/mod.rs index 89f725444164..bd02a236767c 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/client/mod.rs @@ -60,7 +60,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(); Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/'))) } @@ -199,7 +199,7 @@ impl<C> Client<DropContextService<HyperClient, C>, C> where "https" => { let connector = connector.https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; HyperClient::Https(hyper::client::Client::builder().build(connector)) }, _ => { @@ -251,7 +251,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C let https_connector = Connector::builder() .https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -272,7 +272,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C .https() .pin_server_certificate(ca_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -300,7 +300,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C .pin_server_certificate(ca_certificate) .client_authentication(client_key, client_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } } @@ -494,18 +494,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 201 => { - let body = response.into_body(); Ok( MultipartRelatedRequestPostResponse::OK ) @@ -647,18 +646,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", multipart_header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 201 => { - let body = response.into_body(); Ok( MultipartRequestPostResponse::OK ) @@ -774,18 +772,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( MultipleIdenticalMimeTypesPostResponse::OK ) diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs index 95e56d34a363..8d8eb9a4ba39 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs @@ -1,4 +1,5 @@ #![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 futures::Stream; @@ -9,8 +10,8 @@ use serde::{Serialize, Deserialize}; type ServiceError = Box<dyn Error + Send + Sync + 'static>; -pub const BASE_PATH: &'static str = ""; -pub const API_VERSION: &'static str = "1.0.7"; +pub const BASE_PATH: &str = ""; +pub const API_VERSION: &str = "1.0.7"; #[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum MultipartRelatedRequestPostResponse { @@ -95,7 +96,7 @@ pub trait ApiNoContext<C: Send + Sync> { pub trait ContextWrapperExt<C: Send + Sync> where Self: Sized { /// 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 { diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/client/mod.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/client/mod.rs index bc32420a2d99..b8bcf7763395 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/client/mod.rs @@ -53,7 +53,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(); Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/'))) } @@ -192,7 +192,7 @@ impl<C> Client<DropContextService<HyperClient, C>, C> where "https" => { let connector = connector.https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; HyperClient::Https(hyper::client::Client::builder().build(connector)) }, _ => { @@ -244,7 +244,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C let https_connector = Connector::builder() .https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -265,7 +265,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C .https() .pin_server_certificate(ca_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -293,7 +293,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C .pin_server_certificate(ca_certificate) .client_authentication(client_key, client_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } } @@ -425,18 +425,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( OpGetResponse::OK ) diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs index 100c47adacd1..398896f52072 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs @@ -1,4 +1,5 @@ #![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 futures::Stream; @@ -9,8 +10,8 @@ use serde::{Serialize, Deserialize}; type ServiceError = Box<dyn Error + Send + Sync + 'static>; -pub const BASE_PATH: &'static str = ""; -pub const API_VERSION: &'static str = "0.0.1"; +pub const BASE_PATH: &str = ""; +pub const API_VERSION: &str = "0.0.1"; #[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum OpGetResponse { @@ -51,7 +52,7 @@ pub trait ApiNoContext<C: Send + Sync> { pub trait ContextWrapperExt<C: Send + Sync> where Self: Sized { /// 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 { diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs index 3e21905952a8..76a64ab229bc 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs @@ -80,7 +80,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(); Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/'))) } @@ -219,7 +219,7 @@ impl<C> Client<DropContextService<HyperClient, C>, C> where "https" => { let connector = connector.https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; HyperClient::Https(hyper::client::Client::builder().build(connector)) }, _ => { @@ -271,7 +271,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C let https_connector = Connector::builder() .https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -292,7 +292,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C .https() .pin_server_certificate(ca_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -320,7 +320,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C .pin_server_certificate(ca_certificate) .client_authentication(client_key, client_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } } @@ -445,13 +445,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -553,18 +553,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 204 => { - let body = response.into_body(); Ok( CallbackWithHeaderPostResponse::OK ) @@ -627,18 +626,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( ComplexQueryParamGetResponse::Success ) @@ -698,18 +696,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( EnumInPathPathParamGetResponse::Success ) @@ -775,18 +772,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( JsonComplexQueryParamGetResponse::Success ) @@ -845,7 +841,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -862,12 +858,11 @@ impl<S, C> Api<C> for Client<S, C> where }, }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( MandatoryRequestHeaderGetResponse::Success ) @@ -925,13 +920,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -1002,13 +997,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -1158,7 +1153,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -1181,12 +1176,11 @@ impl<S, C> Api<C> for Client<S, C> where } } - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( MultipleAuthSchemeGetResponse::CheckThatLimitingToMultipleRequiredAuthSchemesWorks ) @@ -1244,13 +1238,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -1321,18 +1315,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 204 => { - let body = response.into_body(); Ok( OverrideServerGetResponse::Success ) @@ -1405,13 +1398,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -1482,7 +1475,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -1505,12 +1498,11 @@ impl<S, C> Api<C> for Client<S, C> where } } - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( ReadonlyAuthSchemeGetResponse::CheckThatLimitingToASingleRequiredAuthSchemeWorks ) @@ -1571,18 +1563,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 204 => { - let body = response.into_body(); Ok( RegisterCallbackPostResponse::OK ) @@ -1649,18 +1640,17 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( RequiredOctetStreamPutResponse::OK ) @@ -1718,13 +1708,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -1823,7 +1813,6 @@ impl<S, C> Api<C> for Client<S, C> where None => None, }; - let body = response.into_body(); Ok( ResponsesWithHeadersGetResponse::PreconditionFailed { @@ -1885,13 +1874,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -2004,18 +1993,17 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( UntypedPropertyGetResponse::CheckThatUntypedPropertiesWorks ) @@ -2073,13 +2061,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -2163,24 +2151,22 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 201 => { - let body = response.into_body(); Ok( XmlExtraPostResponse::OK ) } 400 => { - let body = response.into_body(); Ok( XmlExtraPostResponse::BadRequest ) @@ -2251,13 +2237,13 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -2277,7 +2263,6 @@ impl<S, C> Api<C> for Client<S, C> where ) } 400 => { - let body = response.into_body(); Ok( XmlOtherPostResponse::BadRequest ) @@ -2348,24 +2333,22 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 201 => { - let body = response.into_body(); Ok( XmlOtherPutResponse::OK ) } 400 => { - let body = response.into_body(); Ok( XmlOtherPutResponse::BadRequest ) @@ -2436,24 +2419,22 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 201 => { - let body = response.into_body(); Ok( XmlPostResponse::OK ) } 400 => { - let body = response.into_body(); Ok( XmlPostResponse::BadRequest ) @@ -2526,24 +2507,22 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 201 => { - let body = response.into_body(); Ok( XmlPutResponse::OK ) } 400 => { - let body = response.into_body(); Ok( XmlPutResponse::BadRequest ) @@ -2611,18 +2590,17 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( CreateRepoResponse::Success ) @@ -2682,13 +2660,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs index 61da16cebad3..87ddda8a3146 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs @@ -1,4 +1,5 @@ #![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 futures::Stream; @@ -9,8 +10,8 @@ use serde::{Serialize, Deserialize}; type ServiceError = Box<dyn Error + Send + Sync + 'static>; -pub const BASE_PATH: &'static str = ""; -pub const API_VERSION: &'static str = "1.0.7"; +pub const BASE_PATH: &str = ""; +pub const API_VERSION: &str = "1.0.7"; #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] @@ -545,7 +546,7 @@ pub trait ApiNoContext<C: Send + Sync> { pub trait ContextWrapperExt<C: Send + Sync> where Self: Sized { /// 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 { diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/server/callbacks.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/server/callbacks.rs index 8353cb185eb3..38dd27fa7ae3 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/server/callbacks.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/server/callbacks.rs @@ -264,7 +264,7 @@ impl<S, C> CallbackApi<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -286,12 +286,11 @@ impl<S, C> CallbackApi<C> for Client<S, C> where None => {} } - 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?; match response.status().as_u16() { 204 => { - let body = response.into_body(); Ok( CallbackCallbackWithHeaderPostResponse::OK ) @@ -350,18 +349,17 @@ impl<S, C> CallbackApi<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 204 => { - let body = response.into_body(); Ok( CallbackCallbackPostResponse::OK ) diff --git a/samples/server/petstore/rust-server/output/ops-v3/src/client/mod.rs b/samples/server/petstore/rust-server/output/ops-v3/src/client/mod.rs index 4d2375e6345f..f3dbc73c9892 100644 --- a/samples/server/petstore/rust-server/output/ops-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/ops-v3/src/client/mod.rs @@ -89,7 +89,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(); Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/'))) } @@ -228,7 +228,7 @@ impl<C> Client<DropContextService<HyperClient, C>, C> where "https" => { let connector = connector.https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; HyperClient::Https(hyper::client::Client::builder().build(connector)) }, _ => { @@ -280,7 +280,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C let https_connector = Connector::builder() .https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -301,7 +301,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C .https() .pin_server_certificate(ca_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -329,7 +329,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C .pin_server_certificate(ca_certificate) .client_authentication(client_key, client_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } } @@ -449,18 +449,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op10GetResponse::OK ) @@ -518,18 +517,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op11GetResponse::OK ) @@ -587,18 +585,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op12GetResponse::OK ) @@ -656,18 +653,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op13GetResponse::OK ) @@ -725,18 +721,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op14GetResponse::OK ) @@ -794,18 +789,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op15GetResponse::OK ) @@ -863,18 +857,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op16GetResponse::OK ) @@ -932,18 +925,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op17GetResponse::OK ) @@ -1001,18 +993,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op18GetResponse::OK ) @@ -1070,18 +1061,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op19GetResponse::OK ) @@ -1139,18 +1129,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op1GetResponse::OK ) @@ -1208,18 +1197,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op20GetResponse::OK ) @@ -1277,18 +1265,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op21GetResponse::OK ) @@ -1346,18 +1333,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op22GetResponse::OK ) @@ -1415,18 +1401,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op23GetResponse::OK ) @@ -1484,18 +1469,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op24GetResponse::OK ) @@ -1553,18 +1537,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op25GetResponse::OK ) @@ -1622,18 +1605,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op26GetResponse::OK ) @@ -1691,18 +1673,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op27GetResponse::OK ) @@ -1760,18 +1741,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op28GetResponse::OK ) @@ -1829,18 +1809,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op29GetResponse::OK ) @@ -1898,18 +1877,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op2GetResponse::OK ) @@ -1967,18 +1945,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op30GetResponse::OK ) @@ -2036,18 +2013,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op31GetResponse::OK ) @@ -2105,18 +2081,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op32GetResponse::OK ) @@ -2174,18 +2149,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op33GetResponse::OK ) @@ -2243,18 +2217,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op34GetResponse::OK ) @@ -2312,18 +2285,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op35GetResponse::OK ) @@ -2381,18 +2353,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op36GetResponse::OK ) @@ -2450,18 +2421,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op37GetResponse::OK ) @@ -2519,18 +2489,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op3GetResponse::OK ) @@ -2588,18 +2557,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op4GetResponse::OK ) @@ -2657,18 +2625,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op5GetResponse::OK ) @@ -2726,18 +2693,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op6GetResponse::OK ) @@ -2795,18 +2761,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op7GetResponse::OK ) @@ -2864,18 +2829,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op8GetResponse::OK ) @@ -2933,18 +2897,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Op9GetResponse::OK ) diff --git a/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs b/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs index 52793ae078d9..2c47196b1dd2 100644 --- a/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs @@ -1,4 +1,5 @@ #![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 futures::Stream; @@ -9,8 +10,8 @@ use serde::{Serialize, Deserialize}; type ServiceError = Box<dyn Error + Send + Sync + 'static>; -pub const BASE_PATH: &'static str = ""; -pub const API_VERSION: &'static str = "0.0.1"; +pub const BASE_PATH: &str = ""; +pub const API_VERSION: &str = "0.0.1"; #[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op10GetResponse { @@ -553,7 +554,7 @@ pub trait ApiNoContext<C: Send + Sync> { pub trait ContextWrapperExt<C: Send + Sync> where Self: Sized { /// 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 { diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs index 9fc14cf319e5..a4b4158b4ff7 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs @@ -90,7 +90,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(); Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/'))) } @@ -229,7 +229,7 @@ impl<C> Client<DropContextService<HyperClient, C>, C> where "https" => { let connector = connector.https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; HyperClient::Https(hyper::client::Client::builder().build(connector)) }, _ => { @@ -281,7 +281,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C let https_connector = Connector::builder() .https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -302,7 +302,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C .https() .pin_server_certificate(ca_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -330,7 +330,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C .pin_server_certificate(ca_certificate) .client_authentication(client_key, client_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } } @@ -462,13 +462,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -539,18 +539,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( Call123exampleResponse::Success ) @@ -621,13 +620,13 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -711,13 +710,13 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -801,13 +800,13 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -891,13 +890,13 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -968,18 +967,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( FakeResponseWithNumericalDescriptionResponse::Status200 ) @@ -1039,18 +1037,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( HyphenParamResponse::Success ) @@ -1120,18 +1117,17 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( TestBodyWithQueryParamsResponse::Success ) @@ -1198,13 +1194,13 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -1313,7 +1309,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); *request.body_mut() = Body::from(body.into_bytes()); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -1336,18 +1332,16 @@ impl<S, C> Api<C> for Client<S, C> where } } - 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?; match response.status().as_u16() { 400 => { - let body = response.into_body(); Ok( TestEndpointParametersResponse::InvalidUsernameSupplied ) } 404 => { - let body = response.into_body(); Ok( TestEndpointParametersResponse::UserNotFound ) @@ -1439,7 +1433,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); *request.body_mut() = Body::from(body.into_bytes()); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -1476,18 +1470,16 @@ impl<S, C> Api<C> for Client<S, C> where None => {} } - 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?; match response.status().as_u16() { 400 => { - let body = response.into_body(); Ok( TestEnumParametersResponse::InvalidRequest ) } 404 => { - let body = response.into_body(); Ok( TestEnumParametersResponse::NotFound ) @@ -1554,18 +1546,17 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( TestInlineAdditionalPropertiesResponse::SuccessfulOperation ) @@ -1637,18 +1628,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); *request.body_mut() = Body::from(body.into_bytes()); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( TestJsonFormDataResponse::SuccessfulOperation ) @@ -1723,7 +1713,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -1736,7 +1726,7 @@ impl<S, C> Api<C> for Client<S, C> where } } - 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?; match response.status().as_u16() { @@ -1817,7 +1807,7 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -1840,12 +1830,11 @@ impl<S, C> Api<C> for Client<S, C> where } } - 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?; match response.status().as_u16() { 405 => { - let body = response.into_body(); Ok( AddPetResponse::InvalidInput ) @@ -1906,7 +1895,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -1945,12 +1934,11 @@ impl<S, C> Api<C> for Client<S, C> where None => {} } - 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?; match response.status().as_u16() { 400 => { - let body = response.into_body(); Ok( DeletePetResponse::InvalidPetValue ) @@ -2011,7 +1999,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -2034,7 +2022,7 @@ impl<S, C> Api<C> for Client<S, C> where } } - 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?; match response.status().as_u16() { @@ -2054,7 +2042,6 @@ impl<S, C> Api<C> for Client<S, C> where ) } 400 => { - let body = response.into_body(); Ok( FindPetsByStatusResponse::InvalidStatusValue ) @@ -2115,7 +2102,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -2138,7 +2125,7 @@ impl<S, C> Api<C> for Client<S, C> where } } - 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?; match response.status().as_u16() { @@ -2158,7 +2145,6 @@ impl<S, C> Api<C> for Client<S, C> where ) } 400 => { - let body = response.into_body(); Ok( FindPetsByTagsResponse::InvalidTagValue ) @@ -2218,7 +2204,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -2231,7 +2217,7 @@ impl<S, C> Api<C> for Client<S, C> where } } - 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?; match response.status().as_u16() { @@ -2251,13 +2237,11 @@ impl<S, C> Api<C> for Client<S, C> where ) } 400 => { - let body = response.into_body(); Ok( GetPetByIdResponse::InvalidIDSupplied ) } 404 => { - let body = response.into_body(); Ok( GetPetByIdResponse::PetNotFound ) @@ -2324,7 +2308,7 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -2347,24 +2331,21 @@ impl<S, C> Api<C> for Client<S, C> where } } - 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?; match response.status().as_u16() { 400 => { - let body = response.into_body(); Ok( UpdatePetResponse::InvalidIDSupplied ) } 404 => { - let body = response.into_body(); Ok( UpdatePetResponse::PetNotFound ) } 405 => { - let body = response.into_body(); Ok( UpdatePetResponse::ValidationException ) @@ -2438,7 +2419,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); *request.body_mut() = Body::from(body.into_bytes()); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -2461,12 +2442,11 @@ impl<S, C> Api<C> for Client<S, C> where } } - 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?; match response.status().as_u16() { 405 => { - let body = response.into_body(); Ok( UpdatePetWithFormResponse::InvalidInput ) @@ -2583,7 +2563,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", multipart_header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -2606,7 +2586,7 @@ impl<S, C> Api<C> for Client<S, C> where } } - 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?; match response.status().as_u16() { @@ -2679,24 +2659,22 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 400 => { - let body = response.into_body(); Ok( DeleteOrderResponse::InvalidIDSupplied ) } 404 => { - let body = response.into_body(); Ok( DeleteOrderResponse::OrderNotFound ) @@ -2754,7 +2732,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -2767,7 +2745,7 @@ impl<S, C> Api<C> for Client<S, C> where } } - 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?; match response.status().as_u16() { @@ -2840,13 +2818,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -2866,13 +2844,11 @@ impl<S, C> Api<C> for Client<S, C> where ) } 400 => { - let body = response.into_body(); Ok( GetOrderByIdResponse::InvalidIDSupplied ) } 404 => { - let body = response.into_body(); Ok( GetOrderByIdResponse::OrderNotFound ) @@ -2941,13 +2917,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -2967,7 +2943,6 @@ impl<S, C> Api<C> for Client<S, C> where ) } 400 => { - let body = response.into_body(); Ok( PlaceOrderResponse::InvalidOrder ) @@ -3035,18 +3010,17 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 0 => { - let body = response.into_body(); Ok( CreateUserResponse::SuccessfulOperation ) @@ -3113,18 +3087,17 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 0 => { - let body = response.into_body(); Ok( CreateUsersWithArrayInputResponse::SuccessfulOperation ) @@ -3191,18 +3164,17 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 0 => { - let body = response.into_body(); Ok( CreateUsersWithListInputResponse::SuccessfulOperation ) @@ -3262,24 +3234,22 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 400 => { - let body = response.into_body(); Ok( DeleteUserResponse::InvalidUsernameSupplied ) } 404 => { - let body = response.into_body(); Ok( DeleteUserResponse::UserNotFound ) @@ -3339,13 +3309,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -3365,13 +3335,11 @@ impl<S, C> Api<C> for Client<S, C> where ) } 400 => { - let body = response.into_body(); Ok( GetUserByNameResponse::InvalidUsernameSupplied ) } 404 => { - let body = response.into_body(); Ok( GetUserByNameResponse::UserNotFound ) @@ -3435,13 +3403,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -3495,7 +3463,6 @@ impl<S, C> Api<C> for Client<S, C> where ) } 400 => { - let body = response.into_body(); Ok( LoginUserResponse::InvalidUsername ) @@ -3553,18 +3520,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 0 => { - let body = response.into_body(); Ok( LogoutUserResponse::SuccessfulOperation ) @@ -3635,24 +3601,22 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 400 => { - let body = response.into_body(); Ok( UpdateUserResponse::InvalidUserSupplied ) } 404 => { - let body = response.into_body(); Ok( UpdateUserResponse::UserNotFound ) diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs index c0364fee2a9b..f011e13ecb2a 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs @@ -1,4 +1,5 @@ #![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 futures::Stream; @@ -9,8 +10,8 @@ use serde::{Serialize, Deserialize}; type ServiceError = Box<dyn Error + Send + Sync + 'static>; -pub const BASE_PATH: &'static str = "/v2"; -pub const API_VERSION: &'static str = "1.0.0"; +pub const BASE_PATH: &str = "/v2"; +pub const API_VERSION: &str = "1.0.0"; #[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum TestSpecialTagsResponse { @@ -788,7 +789,7 @@ pub trait ApiNoContext<C: Send + Sync> { pub trait ContextWrapperExt<C: Send + Sync> where Self: Sized { /// 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 { diff --git a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/client/mod.rs b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/client/mod.rs index e9927156e559..854dd41f33fa 100644 --- a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/client/mod.rs @@ -53,7 +53,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(); Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/'))) } @@ -192,7 +192,7 @@ impl<C> Client<DropContextService<HyperClient, C>, C> where "https" => { let connector = connector.https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; HyperClient::Https(hyper::client::Client::builder().build(connector)) }, _ => { @@ -244,7 +244,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C let https_connector = Connector::builder() .https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -265,7 +265,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C .https() .pin_server_certificate(ca_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -293,7 +293,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C .pin_server_certificate(ca_certificate) .client_authentication(client_key, client_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } } @@ -413,7 +413,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -436,12 +436,11 @@ impl<S, C> Api<C> for Client<S, C> where } } - 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?; match response.status().as_u16() { 201 => { - let body = response.into_body(); Ok( PingGetResponse::OK ) diff --git a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs index 0f93036c82e8..4c5d7e2de9dc 100644 --- a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs +++ b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs @@ -1,4 +1,5 @@ #![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 futures::Stream; @@ -9,8 +10,8 @@ use serde::{Serialize, Deserialize}; type ServiceError = Box<dyn Error + Send + Sync + 'static>; -pub const BASE_PATH: &'static str = ""; -pub const API_VERSION: &'static str = "1.0"; +pub const BASE_PATH: &str = ""; +pub const API_VERSION: &str = "1.0"; #[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum PingGetResponse { @@ -49,7 +50,7 @@ pub trait ApiNoContext<C: Send + Sync> { pub trait ContextWrapperExt<C: Send + Sync> where Self: Sized { /// 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 { diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/client/mod.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/client/mod.rs index 623ea11d1821..dcda90cd4a9d 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/client/mod.rs @@ -61,7 +61,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(); Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/'))) } @@ -200,7 +200,7 @@ impl<C> Client<DropContextService<HyperClient, C>, C> where "https" => { let connector = connector.https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; HyperClient::Https(hyper::client::Client::builder().build(connector)) }, _ => { @@ -252,7 +252,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C let https_connector = Connector::builder() .https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -273,7 +273,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C .https() .pin_server_certificate(ca_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -301,7 +301,7 @@ impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C .pin_server_certificate(ca_certificate) .client_authentication(client_key, client_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } } @@ -421,13 +421,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -498,18 +498,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( DummyGetResponse::Success ) @@ -576,18 +575,17 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 200 => { - let body = response.into_body(); Ok( DummyPutResponse::Success ) @@ -645,13 +643,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -722,13 +720,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -806,13 +804,13 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -890,18 +888,17 @@ impl<S, C> Api<C> for Client<S, C> where Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 204 => { - let body = response.into_body(); Ok( PostYamlResponse::OK ) @@ -959,13 +956,13 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { @@ -1047,18 +1044,17 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create header: {} - {}", header, e))) }); - 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 { Ok(h) => h, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); - 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?; match response.status().as_u16() { 204 => { - let body = response.into_body(); Ok( SoloObjectPostResponse::OK ) diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs index 26fd27856470..eb37814cb8f5 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs @@ -1,4 +1,5 @@ #![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 futures::Stream; @@ -9,8 +10,8 @@ use serde::{Serialize, Deserialize}; type ServiceError = Box<dyn Error + Send + Sync + 'static>; -pub const BASE_PATH: &'static str = ""; -pub const API_VERSION: &'static str = "2.3.4"; +pub const BASE_PATH: &str = ""; +pub const API_VERSION: &str = "2.3.4"; #[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum AllOfGetResponse { @@ -184,7 +185,7 @@ pub trait ApiNoContext<C: Send + Sync> { pub trait ContextWrapperExt<C: Send + Sync> where Self: Sized { /// 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 {