chore: Fix clippy lint (#1181)

This commit is contained in:
tottoto
2022-12-13 11:29:29 -05:00
committed by GitHub
parent 3076e8251e
commit 2dd09c02bd
23 changed files with 98 additions and 62 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ impl Greeter for MyGreeter {
println!("Got a request: {:?}", request); println!("Got a request: {:?}", request);
let reply = hello_world::HelloReply { let reply = hello_world::HelloReply {
message: format!("Hello {}!", request.into_inner().name).into(), message: format!("Hello {}!", request.into_inner().name),
}; };
Ok(Response::new(reply)) Ok(Response::new(reply))
+3 -3
View File
@@ -113,7 +113,7 @@ impl fmt::Display for TestAssertion {
macro_rules! test_assert { macro_rules! test_assert {
($description:expr, $assertion:expr) => { ($description:expr, $assertion:expr) => {
if $assertion { if $assertion {
crate::TestAssertion::Passed { $crate::TestAssertion::Passed {
description: $description, description: $description,
} }
} else { } else {
@@ -126,11 +126,11 @@ macro_rules! test_assert {
}; };
($description:expr, $assertion:expr, $why:expr) => { ($description:expr, $assertion:expr, $why:expr) => {
if $assertion { if $assertion {
crate::TestAssertion::Passed { $crate::TestAssertion::Passed {
description: $description, description: $description,
} }
} else { } else {
crate::TestAssertion::Failed { $crate::TestAssertion::Failed {
description: $description, description: $description,
expression: stringify!($assertion), expression: stringify!($assertion),
why: Some($why), why: Some($why),
+1 -1
View File
@@ -13,5 +13,5 @@ prost = "0.11"
tonic = { path = "../../tonic" } tonic = { path = "../../tonic" }
[build-dependencies] [build-dependencies]
prost-build = "0.11" prost-build = "0.11.4"
tonic-build = { path = "../../tonic-build" } tonic-build = { path = "../../tonic-build" }
+1 -1
View File
@@ -1,6 +1,6 @@
fn main() { fn main() {
let mut config = prost_build::Config::default(); let mut config = prost_build::Config::default();
config.disable_comments(&["test.Input1", "test.Output1"]); config.disable_comments(["test.Input1", "test.Output1"]);
tonic_build::configure() tonic_build::configure()
.disable_comments("test.Service1") .disable_comments("test.Service1")
.disable_comments("test.Service1.Rpc1") .disable_comments("test.Service1.Rpc1")
+1 -1
View File
@@ -12,4 +12,4 @@ version = "0.1.0"
bytes = "1.0" bytes = "1.0"
prost = "0.11" prost = "0.11"
[build-dependencies] [build-dependencies]
prost-build = "0.11" prost-build = "0.11.4"
+1 -1
View File
@@ -17,7 +17,7 @@ async fn status_from_server_stream_with_source() {
&self, &self,
_: Request<InputStream>, _: Request<InputStream>,
) -> Result<Response<Self::StreamCallStream>, Status> { ) -> Result<Response<Self::StreamCallStream>, Status> {
let s = Unsync(0 as *mut ()); let s = Unsync(std::ptr::null_mut::<()>());
Ok(Response::new(Box::pin(s) as Self::StreamCallStream)) Ok(Response::new(Box::pin(s) as Self::StreamCallStream))
} }
+1
View File
@@ -1,3 +1,4 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct Animal { pub struct Animal {
#[prost(string, optional, tag = "1")] #[prost(string, optional, tag = "1")]
+1 -1
View File
@@ -16,5 +16,5 @@ prost = "0.11"
tonic = {path = "../../tonic"} tonic = {path = "../../tonic"}
[build-dependencies] [build-dependencies]
prost-build = "0.11" prost-build = "0.11.4"
tonic-build = {path = "../../tonic-build"} tonic-build = {path = "../../tonic-build"}
+1 -1
View File
@@ -17,7 +17,7 @@ version = "0.8.4"
[dependencies] [dependencies]
prettyplease = { version = "0.1" } prettyplease = { version = "0.1" }
proc-macro2 = "1.0" proc-macro2 = "1.0"
prost-build = { version = "0.11.2", optional = true } prost-build = { version = "0.11.4", optional = true }
quote = "1.0" quote = "1.0"
syn = "1.0" syn = "1.0"
@@ -1,8 +1,10 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct HealthCheckRequest { pub struct HealthCheckRequest {
#[prost(string, tag = "1")] #[prost(string, tag = "1")]
pub service: ::prost::alloc::string::String, pub service: ::prost::alloc::string::String,
} }
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct HealthCheckResponse { pub struct HealthCheckResponse {
#[prost(enumeration = "health_check_response::ServingStatus", tag = "1")] #[prost(enumeration = "health_check_response::ServingStatus", tag = "1")]
+1 -1
View File
@@ -36,7 +36,7 @@ pub mod proto {
pub mod server; pub mod server;
/// An enumeration of values representing gRPC service health. /// An enumeration of values representing gRPC service health.
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum ServingStatus { pub enum ServingStatus {
/// Unknown status /// Unknown status
Unknown, Unknown,
+1 -1
View File
@@ -27,6 +27,6 @@ tonic = { version = "0.8", path = "../tonic", default-features = false, features
[dev-dependencies] [dev-dependencies]
tonic = { version = "0.8", path = "../tonic", default-features = false, features = ["transport"] } tonic = { version = "0.8", path = "../tonic", default-features = false, features = ["transport"] }
tonic-build = { version = "0.8", path = "../tonic-build", default-features = false, features = ["prost"] } tonic-build = { version = "0.8", path = "../tonic-build", default-features = false, features = ["prost", "cleanup-markdown"] }
futures = "0.3" futures = "0.3"
futures-util = "0.3" futures-util = "0.3"
@@ -1,4 +1,5 @@
/// The message sent by the client when calling ServerReflectionInfo method. /// The message sent by the client when calling ServerReflectionInfo method.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct ServerReflectionRequest { pub struct ServerReflectionRequest {
#[prost(string, tag = "1")] #[prost(string, tag = "1")]
@@ -16,6 +17,7 @@ pub mod server_reflection_request {
/// To use reflection service, the client should set one of the following /// To use reflection service, the client should set one of the following
/// fields in message_request. The server distinguishes requests by their /// fields in message_request. The server distinguishes requests by their
/// defined field and then handles them using corresponding methods. /// defined field and then handles them using corresponding methods.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)] #[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum MessageRequest { pub enum MessageRequest {
/// Find a proto file by the file name. /// Find a proto file by the file name.
@@ -48,6 +50,7 @@ pub mod server_reflection_request {
} }
/// The type name and extension number sent by the client when requesting /// The type name and extension number sent by the client when requesting
/// file_containing_extension. /// file_containing_extension.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExtensionRequest { pub struct ExtensionRequest {
/// Fully-qualified type name. The format should be <package>.<type> /// Fully-qualified type name. The format should be <package>.<type>
@@ -57,6 +60,7 @@ pub struct ExtensionRequest {
pub extension_number: i32, pub extension_number: i32,
} }
/// The message sent by the server to answer ServerReflectionInfo method. /// The message sent by the server to answer ServerReflectionInfo method.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct ServerReflectionResponse { pub struct ServerReflectionResponse {
#[prost(string, tag = "1")] #[prost(string, tag = "1")]
@@ -74,6 +78,7 @@ pub struct ServerReflectionResponse {
pub mod server_reflection_response { pub mod server_reflection_response {
/// The server sets one of the following fields according to the /// The server sets one of the following fields according to the
/// message_request in the request. /// message_request in the request.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)] #[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum MessageResponse { pub enum MessageResponse {
/// This message is used to answer file_by_filename, file_containing_symbol, /// This message is used to answer file_by_filename, file_containing_symbol,
@@ -98,6 +103,7 @@ pub mod server_reflection_response {
/// Serialized FileDescriptorProto messages sent by the server answering /// Serialized FileDescriptorProto messages sent by the server answering
/// a file_by_filename, file_containing_symbol, or file_containing_extension /// a file_by_filename, file_containing_symbol, or file_containing_extension
/// request. /// request.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct FileDescriptorResponse { pub struct FileDescriptorResponse {
/// Serialized FileDescriptorProto messages. We avoid taking a dependency on /// Serialized FileDescriptorProto messages. We avoid taking a dependency on
@@ -108,6 +114,7 @@ pub struct FileDescriptorResponse {
} }
/// A list of extension numbers sent by the server answering /// A list of extension numbers sent by the server answering
/// all_extension_numbers_of_type request. /// all_extension_numbers_of_type request.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExtensionNumberResponse { pub struct ExtensionNumberResponse {
/// Full name of the base type, including the package name. The format /// Full name of the base type, including the package name. The format
@@ -118,6 +125,7 @@ pub struct ExtensionNumberResponse {
pub extension_number: ::prost::alloc::vec::Vec<i32>, pub extension_number: ::prost::alloc::vec::Vec<i32>,
} }
/// A list of ServiceResponse sent by the server answering list_services request. /// A list of ServiceResponse sent by the server answering list_services request.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListServiceResponse { pub struct ListServiceResponse {
/// The information of each service may be expanded in the future, so we use /// The information of each service may be expanded in the future, so we use
@@ -127,6 +135,7 @@ pub struct ListServiceResponse {
} }
/// The information of a single service used by ListServiceResponse to answer /// The information of a single service used by ListServiceResponse to answer
/// list_services request. /// list_services request.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct ServiceResponse { pub struct ServiceResponse {
/// Full name of a registered service, including its package name. The format /// Full name of a registered service, including its package name. The format
@@ -135,6 +144,7 @@ pub struct ServiceResponse {
pub name: ::prost::alloc::string::String, pub name: ::prost::alloc::string::String,
} }
/// The error code and error message sent by the server when an error occurs. /// The error code and error message sent by the server when an error occurs.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct ErrorResponse { pub struct ErrorResponse {
/// This field uses the error codes defined in grpc::StatusCode. /// This field uses the error codes defined in grpc::StatusCode.
+15
View File
@@ -5,6 +5,7 @@
/// ///
/// You can find out more about this error model and how to work with it in the /// You can find out more about this error model and how to work with it in the
/// [API Design Guide](<https://cloud.google.com/apis/design/errors>). /// [API Design Guide](<https://cloud.google.com/apis/design/errors>).
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct Status { pub struct Status {
/// The status code, which should be an enum value of \\[google.rpc.Code\]\[google.rpc.Code\\]. /// The status code, which should be an enum value of \\[google.rpc.Code\]\[google.rpc.Code\\].
@@ -33,6 +34,7 @@ pub struct Status {
/// the delay between retries based on `retry_delay`, until either a maximum /// the delay between retries based on `retry_delay`, until either a maximum
/// number of retries have been reached or a maximum retry delay cap has been /// number of retries have been reached or a maximum retry delay cap has been
/// reached. /// reached.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct RetryInfo { pub struct RetryInfo {
/// Clients should wait at least this long between retrying the same request. /// Clients should wait at least this long between retrying the same request.
@@ -40,6 +42,7 @@ pub struct RetryInfo {
pub retry_delay: ::core::option::Option<::prost_types::Duration>, pub retry_delay: ::core::option::Option<::prost_types::Duration>,
} }
/// Describes additional debugging info. /// Describes additional debugging info.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct DebugInfo { pub struct DebugInfo {
/// The stack trace entries indicating where the error occurred. /// The stack trace entries indicating where the error occurred.
@@ -60,6 +63,7 @@ pub struct DebugInfo {
/// ///
/// Also see RetryInfo and Help types for other details about handling a /// Also see RetryInfo and Help types for other details about handling a
/// quota failure. /// quota failure.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct QuotaFailure { pub struct QuotaFailure {
/// Describes all quota violations. /// Describes all quota violations.
@@ -70,6 +74,7 @@ pub struct QuotaFailure {
pub mod quota_failure { pub mod quota_failure {
/// A message type used to describe a single quota violation. For example, a /// A message type used to describe a single quota violation. For example, a
/// daily quota or a custom quota that was exceeded. /// daily quota or a custom quota that was exceeded.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct Violation { pub struct Violation {
/// The subject on which the quota check failed. /// The subject on which the quota check failed.
@@ -116,6 +121,7 @@ pub mod quota_failure {
/// } /// }
/// } /// }
/// ``` /// ```
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct ErrorInfo { pub struct ErrorInfo {
/// The reason of the error. This is a constant value that identifies the /// The reason of the error. This is a constant value that identifies the
@@ -151,6 +157,7 @@ pub struct ErrorInfo {
/// For example, if an RPC failed because it required the Terms of Service to be /// For example, if an RPC failed because it required the Terms of Service to be
/// acknowledged, it could list the terms of service violation in the /// acknowledged, it could list the terms of service violation in the
/// PreconditionFailure message. /// PreconditionFailure message.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct PreconditionFailure { pub struct PreconditionFailure {
/// Describes all precondition violations. /// Describes all precondition violations.
@@ -160,6 +167,7 @@ pub struct PreconditionFailure {
/// Nested message and enum types in `PreconditionFailure`. /// Nested message and enum types in `PreconditionFailure`.
pub mod precondition_failure { pub mod precondition_failure {
/// A message type used to describe a single precondition failure. /// A message type used to describe a single precondition failure.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct Violation { pub struct Violation {
/// The type of PreconditionFailure. We recommend using a service-specific /// The type of PreconditionFailure. We recommend using a service-specific
@@ -182,6 +190,7 @@ pub mod precondition_failure {
} }
/// Describes violations in a client request. This error type focuses on the /// Describes violations in a client request. This error type focuses on the
/// syntactic aspects of the request. /// syntactic aspects of the request.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct BadRequest { pub struct BadRequest {
/// Describes all violations in a client request. /// Describes all violations in a client request.
@@ -191,6 +200,7 @@ pub struct BadRequest {
/// Nested message and enum types in `BadRequest`. /// Nested message and enum types in `BadRequest`.
pub mod bad_request { pub mod bad_request {
/// A message type used to describe a single bad request field. /// A message type used to describe a single bad request field.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct FieldViolation { pub struct FieldViolation {
/// A path leading to a field in the request body. The value will be a /// A path leading to a field in the request body. The value will be a
@@ -205,6 +215,7 @@ pub mod bad_request {
} }
/// Contains metadata about the request that clients can attach when filing a bug /// Contains metadata about the request that clients can attach when filing a bug
/// or providing other forms of feedback. /// or providing other forms of feedback.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestInfo { pub struct RequestInfo {
/// An opaque string that should only be interpreted by the service generating /// An opaque string that should only be interpreted by the service generating
@@ -217,6 +228,7 @@ pub struct RequestInfo {
pub serving_data: ::prost::alloc::string::String, pub serving_data: ::prost::alloc::string::String,
} }
/// Describes the resource that is being accessed. /// Describes the resource that is being accessed.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResourceInfo { pub struct ResourceInfo {
/// A name for the type of resource being accessed, e.g. "sql table", /// A name for the type of resource being accessed, e.g. "sql table",
@@ -245,6 +257,7 @@ pub struct ResourceInfo {
/// For example, if a quota check failed with an error indicating the calling /// For example, if a quota check failed with an error indicating the calling
/// project hasn't enabled the accessed service, this can contain a URL pointing /// project hasn't enabled the accessed service, this can contain a URL pointing
/// directly to the right place in the developer console to flip the bit. /// directly to the right place in the developer console to flip the bit.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct Help { pub struct Help {
/// URL(s) pointing to additional information on handling the current error. /// URL(s) pointing to additional information on handling the current error.
@@ -254,6 +267,7 @@ pub struct Help {
/// Nested message and enum types in `Help`. /// Nested message and enum types in `Help`.
pub mod help { pub mod help {
/// Describes a URL link. /// Describes a URL link.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct Link { pub struct Link {
/// Describes what the link offers. /// Describes what the link offers.
@@ -266,6 +280,7 @@ pub mod help {
} }
/// Provides a localized error message that is safe to return to the user /// Provides a localized error message that is safe to return to the user
/// which can be attached to an RPC error. /// which can be attached to an RPC error.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct LocalizedMessage { pub struct LocalizedMessage {
/// The locale used following the specification defined at /// The locale used following the specification defined at
@@ -247,3 +247,9 @@ impl ErrorDetails {
false false
} }
} }
impl Default for ErrorDetails {
fn default() -> Self {
Self::new()
}
}
+12 -16
View File
@@ -20,10 +20,10 @@ trait FromAny {
Self: Sized; Self: Sized;
} }
fn gen_details_bytes(code: Code, message: &String, details: Vec<Any>) -> Bytes { fn gen_details_bytes(code: Code, message: &str, details: Vec<Any>) -> Bytes {
let status = pb::Status { let status = pb::Status {
code: code as i32, code: code as i32,
message: message.clone(), message: message.to_owned(),
details, details,
}; };
@@ -411,7 +411,7 @@ impl StatusExt for tonic::Status {
} }
fn get_error_details(&self) -> ErrorDetails { fn get_error_details(&self) -> ErrorDetails {
self.check_error_details().unwrap_or(ErrorDetails::new()) self.check_error_details().unwrap_or_default()
} }
fn check_error_details_vec(&self) -> Result<Vec<ErrorDetail>, DecodeError> { fn check_error_details_vec(&self) -> Result<Vec<ErrorDetail>, DecodeError> {
@@ -438,19 +438,17 @@ impl StatusExt for tonic::Status {
} }
fn get_error_details_vec(&self) -> Vec<ErrorDetail> { fn get_error_details_vec(&self) -> Vec<ErrorDetail> {
self.check_error_details_vec().unwrap_or(Vec::new()) self.check_error_details_vec().unwrap_or_default()
} }
fn get_details_retry_info(&self) -> Option<RetryInfo> { fn get_details_retry_info(&self) -> Option<RetryInfo> {
let status = pb::Status::decode(self.details()).ok()?; let status = pb::Status::decode(self.details()).ok()?;
for any in status.details.into_iter() { for any in status.details.into_iter() {
match any.type_url.as_str() { if any.type_url.as_str() == RetryInfo::TYPE_URL {
RetryInfo::TYPE_URL => match RetryInfo::from_any(any) { if let Ok(detail) = RetryInfo::from_any(any) {
Ok(detail) => return Some(detail), return Some(detail);
Err(_) => {} }
},
_ => {}
} }
} }
@@ -477,12 +475,10 @@ impl StatusExt for tonic::Status {
let status = pb::Status::decode(self.details()).ok()?; let status = pb::Status::decode(self.details()).ok()?;
for any in status.details.into_iter() { for any in status.details.into_iter() {
match any.type_url.as_str() { if any.type_url.as_str() == BadRequest::TYPE_URL {
BadRequest::TYPE_URL => match BadRequest::from_any(any) { if let Ok(detail) = BadRequest::from_any(any) {
Ok(detail) => return Some(detail), return Some(detail);
Err(_) => {} }
},
_ => {}
} }
} }
@@ -153,7 +153,7 @@ mod tests {
); );
assert!( assert!(
br_details.is_empty() == false, !br_details.is_empty(),
"filled BadRequest returns 'true' from .is_empty()" "filled BadRequest returns 'true' from .is_empty()"
); );
@@ -119,7 +119,7 @@ mod tests {
); );
assert!( assert!(
error_info.is_empty() == false, !error_info.is_empty(),
"filled RetryInfo returns 'false' from .has_retry_delay()" "filled RetryInfo returns 'false' from .has_retry_delay()"
); );
+6
View File
@@ -16,6 +16,12 @@ impl GrpcWebLayer {
} }
} }
impl Default for GrpcWebLayer {
fn default() -> Self {
Self::new()
}
}
impl<S> Layer<S> for GrpcWebLayer impl<S> Layer<S> for GrpcWebLayer
where where
S: Service<http::Request<hyper::Body>, Response = http::Response<BoxBody>>, S: Service<http::Request<hyper::Body>, Response = http::Response<BoxBody>>,
+1 -1
View File
@@ -247,7 +247,7 @@ impl<VE: ValueEncoding> PartialEq<MetadataKey<VE>> for str {
/// ``` /// ```
#[inline] #[inline]
fn eq(&self, other: &MetadataKey<VE>) -> bool { fn eq(&self, other: &MetadataKey<VE>) -> bool {
(*other).inner == *self other.inner == *self
} }
} }
+27 -27
View File
@@ -1362,7 +1362,7 @@ where
match self.inner { match self.inner {
Some(ref mut inner) => inner Some(ref mut inner) => inner
.next() .next()
.map(&MetadataValue::unchecked_from_header_value_ref), .map(MetadataValue::unchecked_from_header_value_ref),
None => None, None => None,
} }
} }
@@ -1383,7 +1383,7 @@ where
match self.inner { match self.inner {
Some(ref mut inner) => inner Some(ref mut inner) => inner
.next_back() .next_back()
.map(&MetadataValue::unchecked_from_header_value_ref), .map(MetadataValue::unchecked_from_header_value_ref),
None => None, None => None,
} }
} }
@@ -1400,7 +1400,7 @@ where
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
self.inner self.inner
.next() .next()
.map(&MetadataValue::unchecked_from_mut_header_value_ref) .map(MetadataValue::unchecked_from_mut_header_value_ref)
} }
} }
@@ -1411,7 +1411,7 @@ where
fn next_back(&mut self) -> Option<Self::Item> { fn next_back(&mut self) -> Option<Self::Item> {
self.inner self.inner
.next_back() .next_back()
.map(&MetadataValue::unchecked_from_mut_header_value_ref) .map(MetadataValue::unchecked_from_mut_header_value_ref)
} }
} }
@@ -1992,7 +1992,7 @@ impl<'a, 'b: 'a, VE: ValueEncoding> IntoIterator for &'b GetAll<'a, VE> {
fn into_iter(self) -> ValueIter<'a, VE> { fn into_iter(self) -> ValueIter<'a, VE> {
ValueIter { ValueIter {
inner: (&self.inner).as_ref().map(|inner| inner.into_iter()), inner: self.inner.as_ref().map(|inner| inner.into_iter()),
phantom: PhantomData, phantom: PhantomData,
} }
} }
@@ -2037,7 +2037,7 @@ mod into_metadata_key {
) -> Option<MetadataValue<VE>> { ) -> Option<MetadataValue<VE>> {
map.headers map.headers
.insert(self.inner, val.inner) .insert(self.inner, val.inner)
.map(&MetadataValue::unchecked_from_header_value) .map(MetadataValue::unchecked_from_header_value)
} }
#[doc(hidden)] #[doc(hidden)]
@@ -2059,7 +2059,7 @@ mod into_metadata_key {
) -> Option<MetadataValue<VE>> { ) -> Option<MetadataValue<VE>> {
map.headers map.headers
.insert(&self.inner, val.inner) .insert(&self.inner, val.inner)
.map(&MetadataValue::unchecked_from_header_value) .map(MetadataValue::unchecked_from_header_value)
} }
#[doc(hidden)] #[doc(hidden)]
#[inline] #[inline]
@@ -2083,7 +2083,7 @@ mod into_metadata_key {
map.headers map.headers
.insert(key.inner, val.inner) .insert(key.inner, val.inner)
.map(&MetadataValue::unchecked_from_header_value) .map(MetadataValue::unchecked_from_header_value)
} }
#[doc(hidden)] #[doc(hidden)]
#[inline] #[inline]
@@ -2141,7 +2141,7 @@ mod as_metadata_key {
fn get(self, map: &MetadataMap) -> Option<&MetadataValue<VE>> { fn get(self, map: &MetadataMap) -> Option<&MetadataValue<VE>> {
map.headers map.headers
.get(self.inner) .get(self.inner)
.map(&MetadataValue::unchecked_from_header_value_ref) .map(MetadataValue::unchecked_from_header_value_ref)
} }
#[doc(hidden)] #[doc(hidden)]
@@ -2149,7 +2149,7 @@ mod as_metadata_key {
fn get_mut(self, map: &mut MetadataMap) -> Option<&mut MetadataValue<VE>> { fn get_mut(self, map: &mut MetadataMap) -> Option<&mut MetadataValue<VE>> {
map.headers map.headers
.get_mut(self.inner) .get_mut(self.inner)
.map(&MetadataValue::unchecked_from_mut_header_value_ref) .map(MetadataValue::unchecked_from_mut_header_value_ref)
} }
#[doc(hidden)] #[doc(hidden)]
@@ -2172,7 +2172,7 @@ mod as_metadata_key {
fn remove(self, map: &mut MetadataMap) -> Option<MetadataValue<VE>> { fn remove(self, map: &mut MetadataMap) -> Option<MetadataValue<VE>> {
map.headers map.headers
.remove(self.inner) .remove(self.inner)
.map(&MetadataValue::unchecked_from_header_value) .map(MetadataValue::unchecked_from_header_value)
} }
} }
@@ -2184,7 +2184,7 @@ mod as_metadata_key {
fn get(self, map: &MetadataMap) -> Option<&MetadataValue<VE>> { fn get(self, map: &MetadataMap) -> Option<&MetadataValue<VE>> {
map.headers map.headers
.get(&self.inner) .get(&self.inner)
.map(&MetadataValue::unchecked_from_header_value_ref) .map(MetadataValue::unchecked_from_header_value_ref)
} }
#[doc(hidden)] #[doc(hidden)]
@@ -2192,7 +2192,7 @@ mod as_metadata_key {
fn get_mut(self, map: &mut MetadataMap) -> Option<&mut MetadataValue<VE>> { fn get_mut(self, map: &mut MetadataMap) -> Option<&mut MetadataValue<VE>> {
map.headers map.headers
.get_mut(&self.inner) .get_mut(&self.inner)
.map(&MetadataValue::unchecked_from_mut_header_value_ref) .map(MetadataValue::unchecked_from_mut_header_value_ref)
} }
#[doc(hidden)] #[doc(hidden)]
@@ -2215,7 +2215,7 @@ mod as_metadata_key {
fn remove(self, map: &mut MetadataMap) -> Option<MetadataValue<VE>> { fn remove(self, map: &mut MetadataMap) -> Option<MetadataValue<VE>> {
map.headers map.headers
.remove(&self.inner) .remove(&self.inner)
.map(&MetadataValue::unchecked_from_header_value) .map(MetadataValue::unchecked_from_header_value)
} }
} }
@@ -2230,7 +2230,7 @@ mod as_metadata_key {
} }
map.headers map.headers
.get(self) .get(self)
.map(&MetadataValue::unchecked_from_header_value_ref) .map(MetadataValue::unchecked_from_header_value_ref)
} }
#[doc(hidden)] #[doc(hidden)]
@@ -2241,7 +2241,7 @@ mod as_metadata_key {
} }
map.headers map.headers
.get_mut(self) .get_mut(self)
.map(&MetadataValue::unchecked_from_mut_header_value_ref) .map(MetadataValue::unchecked_from_mut_header_value_ref)
} }
#[doc(hidden)] #[doc(hidden)]
@@ -2277,7 +2277,7 @@ mod as_metadata_key {
} }
map.headers map.headers
.remove(self) .remove(self)
.map(&MetadataValue::unchecked_from_header_value) .map(MetadataValue::unchecked_from_header_value)
} }
} }
@@ -2292,7 +2292,7 @@ mod as_metadata_key {
} }
map.headers map.headers
.get(self.as_str()) .get(self.as_str())
.map(&MetadataValue::unchecked_from_header_value_ref) .map(MetadataValue::unchecked_from_header_value_ref)
} }
#[doc(hidden)] #[doc(hidden)]
@@ -2303,7 +2303,7 @@ mod as_metadata_key {
} }
map.headers map.headers
.get_mut(self.as_str()) .get_mut(self.as_str())
.map(&MetadataValue::unchecked_from_mut_header_value_ref) .map(MetadataValue::unchecked_from_mut_header_value_ref)
} }
#[doc(hidden)] #[doc(hidden)]
@@ -2338,7 +2338,7 @@ mod as_metadata_key {
} }
map.headers map.headers
.remove(self.as_str()) .remove(self.as_str())
.map(&MetadataValue::unchecked_from_header_value) .map(MetadataValue::unchecked_from_header_value)
} }
} }
@@ -2353,7 +2353,7 @@ mod as_metadata_key {
} }
map.headers map.headers
.get(self.as_str()) .get(self.as_str())
.map(&MetadataValue::unchecked_from_header_value_ref) .map(MetadataValue::unchecked_from_header_value_ref)
} }
#[doc(hidden)] #[doc(hidden)]
@@ -2364,7 +2364,7 @@ mod as_metadata_key {
} }
map.headers map.headers
.get_mut(self.as_str()) .get_mut(self.as_str())
.map(&MetadataValue::unchecked_from_mut_header_value_ref) .map(MetadataValue::unchecked_from_mut_header_value_ref)
} }
#[doc(hidden)] #[doc(hidden)]
@@ -2399,7 +2399,7 @@ mod as_metadata_key {
} }
map.headers map.headers
.remove(self.as_str()) .remove(self.as_str())
.map(&MetadataValue::unchecked_from_header_value) .map(MetadataValue::unchecked_from_header_value)
} }
} }
@@ -2520,7 +2520,7 @@ mod tests {
let mut found_x_word = false; let mut found_x_word = false;
for key_and_value in map.iter() { for key_and_value in map.iter() {
if let KeyAndValueRef::Ascii(ref key, ref _value) = key_and_value { if let KeyAndValueRef::Ascii(key, _value) = key_and_value {
if key.as_str() == "x-word" { if key.as_str() == "x-word" {
found_x_word = true; found_x_word = true;
} else { } else {
@@ -2540,7 +2540,7 @@ mod tests {
let mut found_x_word_bin = false; let mut found_x_word_bin = false;
for key_and_value in map.iter() { for key_and_value in map.iter() {
if let KeyAndValueRef::Binary(ref key, ref _value) = key_and_value { if let KeyAndValueRef::Binary(key, _value) = key_and_value {
if key.as_str() == "x-word-bin" { if key.as_str() == "x-word-bin" {
found_x_word_bin = true; found_x_word_bin = true;
} else { } else {
@@ -2561,7 +2561,7 @@ mod tests {
let mut found_x_word = false; let mut found_x_word = false;
for key_and_value in map.iter_mut() { for key_and_value in map.iter_mut() {
if let KeyAndMutValueRef::Ascii(ref key, ref _value) = key_and_value { if let KeyAndMutValueRef::Ascii(key, _value) = key_and_value {
if key.as_str() == "x-word" { if key.as_str() == "x-word" {
found_x_word = true; found_x_word = true;
} else { } else {
@@ -2581,7 +2581,7 @@ mod tests {
let mut found_x_word_bin = false; let mut found_x_word_bin = false;
for key_and_value in map.iter_mut() { for key_and_value in map.iter_mut() {
if let KeyAndMutValueRef::Binary(ref key, ref _value) = key_and_value { if let KeyAndMutValueRef::Binary(key, _value) = key_and_value {
if key.as_str() == "x-word-bin" { if key.as_str() == "x-word-bin" {
found_x_word_bin = true; found_x_word_bin = true;
} else { } else {
+1 -1
View File
@@ -349,7 +349,7 @@ mod tests {
Ok::<_, hyper::Error>(hyper::Response::new(hyper::Body::empty())) Ok::<_, hyper::Error>(hyper::Response::new(hyper::Body::empty()))
}); });
let svc = InterceptedService::new(svc, |request: crate::Request<()>| Ok(request)); let svc = InterceptedService::new(svc, Ok);
let request = http::Request::builder() let request = http::Request::builder()
.method(http::Method::OPTIONS) .method(http::Method::OPTIONS)
+2 -2
View File
@@ -70,7 +70,7 @@ impl AsyncWrite for BoxedIo {
pub(crate) enum ServerIo<IO> { pub(crate) enum ServerIo<IO> {
Io(IO), Io(IO),
#[cfg(feature = "tls")] #[cfg(feature = "tls")]
TlsIo(TlsStream<IO>), TlsIo(Box<TlsStream<IO>>),
} }
use tower::util::Either; use tower::util::Either;
@@ -89,7 +89,7 @@ impl<IO> ServerIo<IO> {
#[cfg(feature = "tls")] #[cfg(feature = "tls")]
pub(in crate::transport) fn new_tls_io(io: TlsStream<IO>) -> Self { pub(in crate::transport) fn new_tls_io(io: TlsStream<IO>) -> Self {
Self::TlsIo(io) Self::TlsIo(Box::new(io))
} }
#[cfg(feature = "tls")] #[cfg(feature = "tls")]