From 88de26611c64a889a6b8c6abb6574f468729f1a0 Mon Sep 17 00:00:00 2001 From: tottoto Date: Tue, 26 Nov 2024 22:48:43 +0900 Subject: [PATCH] feat(web): Implement Debug for ResponseFuture --- tonic-web/src/client.rs | 8 +++++++- tonic-web/src/service.rs | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tonic-web/src/client.rs b/tonic-web/src/client.rs index 69d367fd2..98a4032e0 100644 --- a/tonic-web/src/client.rs +++ b/tonic-web/src/client.rs @@ -1,6 +1,7 @@ use http::header::CONTENT_TYPE; use http::{Request, Response, Version}; use pin_project::pin_project; +use std::fmt; use std::future::Future; use std::pin::Pin; use std::task::{ready, Context, Poll}; @@ -78,7 +79,6 @@ where } /// Response future for the [`GrpcWebService`]. -#[allow(missing_debug_implementations)] #[pin_project] #[must_use = "futures do nothing unless polled"] pub struct ResponseFuture { @@ -98,3 +98,9 @@ where Poll::Ready(res.map(|r| r.map(GrpcWebCall::client_response))) } } + +impl fmt::Debug for ResponseFuture { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ResponseFuture").finish() + } +} diff --git a/tonic-web/src/service.rs b/tonic-web/src/service.rs index 54938d7f7..ca2a43d5b 100644 --- a/tonic-web/src/service.rs +++ b/tonic-web/src/service.rs @@ -130,7 +130,6 @@ where } /// Response future for the [`GrpcWebService`]. -#[allow(missing_debug_implementations)] #[pin_project] #[must_use = "futures do nothing unless polled"] pub struct ResponseFuture { @@ -179,6 +178,12 @@ impl NamedService for GrpcWebService { const NAME: &'static str = S::NAME; } +impl fmt::Debug for ResponseFuture { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ResponseFuture").finish() + } +} + impl<'a> RequestKind<'a> { fn new(headers: &'a HeaderMap, method: &'a Method, version: Version) -> Self { if is_grpc_web(headers) {