Skip to content

Commit

Permalink
chore: Simplify debug implementation (#2070)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Nov 27, 2024
1 parent bf54cef commit a7030a7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 42 deletions.
47 changes: 20 additions & 27 deletions tonic/src/client/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,32 +443,25 @@ impl<T: Clone> Clone for Grpc<T> {

impl<T: fmt::Debug> fmt::Debug for Grpc<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut f = f.debug_struct("Grpc");

f.field("inner", &self.inner);

f.field("origin", &self.config.origin);

f.field(
"compression_encoding",
&self.config.send_compression_encodings,
);

f.field(
"accept_compression_encodings",
&self.config.accept_compression_encodings,
);

f.field(
"max_decoding_message_size",
&self.config.max_decoding_message_size,
);

f.field(
"max_encoding_message_size",
&self.config.max_encoding_message_size,
);

f.finish()
f.debug_struct("Grpc")
.field("inner", &self.inner)
.field("origin", &self.config.origin)
.field(
"compression_encoding",
&self.config.send_compression_encodings,
)
.field(
"accept_compression_encodings",
&self.config.accept_compression_encodings,
)
.field(
"max_decoding_message_size",
&self.config.max_decoding_message_size,
)
.field(
"max_encoding_message_size",
&self.config.max_encoding_message_size,
)
.finish()
}
}
26 changes: 11 additions & 15 deletions tonic/src/server/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,21 +472,17 @@ where

impl<T: fmt::Debug> fmt::Debug for Grpc<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut f = f.debug_struct("Grpc");

f.field("codec", &self.codec);

f.field(
"accept_compression_encodings",
&self.accept_compression_encodings,
);

f.field(
"send_compression_encodings",
&self.send_compression_encodings,
);

f.finish()
f.debug_struct("Grpc")
.field("codec", &self.codec)
.field(
"accept_compression_encodings",
&self.accept_compression_encodings,
)
.field(
"send_compression_encodings",
&self.send_compression_encodings,
)
.finish()
}
}

Expand Down

0 comments on commit a7030a7

Please sign in to comment.