chore: Fix clippy lints (#881)
This commit is contained in:
@@ -84,6 +84,7 @@ where
|
||||
body.advance(1);
|
||||
|
||||
let len = body.get_u32();
|
||||
#[allow(clippy::let_and_return)]
|
||||
let msg = T::decode(&mut body.split_to(len as usize)).unwrap();
|
||||
|
||||
msg
|
||||
|
||||
@@ -28,19 +28,11 @@ mod util;
|
||||
|
||||
tonic::include_proto!("test");
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Default)]
|
||||
struct Svc {
|
||||
disable_compressing_on_response: bool,
|
||||
}
|
||||
|
||||
impl Default for Svc {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
disable_compressing_on_response: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const UNCOMPRESSED_MIN_BODY_SIZE: usize = 1024;
|
||||
|
||||
impl Svc {
|
||||
|
||||
@@ -15,7 +15,7 @@ pub fn generate<T: Service>(
|
||||
attributes: &Attributes,
|
||||
) -> TokenStream {
|
||||
let service_ident = quote::format_ident!("{}Client", service.name());
|
||||
let client_mod = quote::format_ident!("{}_client", naive_snake_case(&service.name()));
|
||||
let client_mod = quote::format_ident!("{}_client", naive_snake_case(service.name()));
|
||||
let methods = generate_methods(service, emit_package, proto_path, compile_well_known_types);
|
||||
|
||||
let connect = generate_connect(&service_ident);
|
||||
|
||||
@@ -19,7 +19,7 @@ pub fn generate<T: Service>(
|
||||
|
||||
let server_service = quote::format_ident!("{}Server", service.name());
|
||||
let server_trait = quote::format_ident!("{}", service.name());
|
||||
let server_mod = quote::format_ident!("{}_server", naive_snake_case(&service.name()));
|
||||
let server_mod = quote::format_ident!("{}_server", naive_snake_case(service.name()));
|
||||
let generated_trait = generate_trait(
|
||||
service,
|
||||
proto_path,
|
||||
|
||||
@@ -29,7 +29,7 @@ pub mod proto {
|
||||
#![allow(missing_docs)]
|
||||
tonic::include_proto!("grpc.health.v1");
|
||||
|
||||
pub const GRPC_HEALTH_V1_FILE_DESCRIPTOR_SET: &'static [u8] =
|
||||
pub const GRPC_HEALTH_V1_FILE_DESCRIPTOR_SET: &[u8] =
|
||||
tonic::include_file_descriptor_set!("grpc_health_v1");
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
tonic_build::configure()
|
||||
.file_descriptor_set_path(&reflection_descriptor)
|
||||
.type_attribute(
|
||||
"ServerReflectionResponse.message_response",
|
||||
"#[allow(clippy::enum_variant_names)]",
|
||||
)
|
||||
.build_server(true)
|
||||
.build_client(true) // Client is only used for tests
|
||||
.format(true)
|
||||
|
||||
@@ -147,15 +147,15 @@ impl<'b> Builder<'b> {
|
||||
let prefix = &fd.package.clone().unwrap_or_default();
|
||||
|
||||
for msg in &fd.message_type {
|
||||
self.process_message(fd.clone(), &prefix, msg)?;
|
||||
self.process_message(fd.clone(), prefix, msg)?;
|
||||
}
|
||||
|
||||
for en in &fd.enum_type {
|
||||
self.process_enum(fd.clone(), &prefix, en)?;
|
||||
self.process_enum(fd.clone(), prefix, en)?;
|
||||
}
|
||||
|
||||
for service in &fd.service {
|
||||
let service_name = extract_name(&prefix, "service", service.name.as_ref())?;
|
||||
let service_name = extract_name(prefix, "service", service.name.as_ref())?;
|
||||
self.service_names.push(service_name.clone());
|
||||
self.symbols.insert(service_name.clone(), fd.clone());
|
||||
|
||||
|
||||
@@ -1223,7 +1223,7 @@ impl<'a> Iterator for Iter<'a> {
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.inner.next().map(|item| {
|
||||
let (ref name, value) = item;
|
||||
let (name, value) = item;
|
||||
if Ascii::is_valid_key(name.as_str()) {
|
||||
KeyAndValueRef::Ascii(
|
||||
MetadataKey::unchecked_from_header_name_ref(name),
|
||||
@@ -1315,7 +1315,7 @@ impl<'a> Iterator for Values<'a> {
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.inner.next().map(|item| {
|
||||
let (ref name, value) = item;
|
||||
let (name, value) = item;
|
||||
if Ascii::is_valid_key(name.as_str()) {
|
||||
ValueRef::Ascii(MetadataValue::unchecked_from_header_value_ref(value))
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -498,7 +498,7 @@ impl Status {
|
||||
|
||||
if !self.message.is_empty() {
|
||||
let to_write = Bytes::copy_from_slice(
|
||||
Cow::from(percent_encode(&self.message().as_bytes(), ENCODING_SET)).as_bytes(),
|
||||
Cow::from(percent_encode(self.message().as_bytes(), ENCODING_SET)).as_bytes(),
|
||||
);
|
||||
|
||||
header_map.insert(
|
||||
@@ -697,7 +697,7 @@ pub(crate) fn infer_grpc_status(
|
||||
status_code: http::StatusCode,
|
||||
) -> Result<(), Option<Status>> {
|
||||
if let Some(trailers) = trailers {
|
||||
if let Some(status) = Status::from_header_map(&trailers) {
|
||||
if let Some(status) = Status::from_header_map(trailers) {
|
||||
if status.code() == Code::Ok {
|
||||
return Ok(());
|
||||
} else {
|
||||
|
||||
@@ -24,7 +24,7 @@ impl Certificate {
|
||||
|
||||
/// Get a immutable reference to underlying certificate
|
||||
pub fn get_ref(&self) -> &[u8] {
|
||||
&self.pem.as_slice()
|
||||
self.pem.as_slice()
|
||||
}
|
||||
|
||||
/// Get a mutable reference to underlying certificate
|
||||
|
||||
Reference in New Issue
Block a user