Skip to content

Commit

Permalink
feat(web): Implement Debug for ResponseFuture
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Nov 26, 2024
1 parent 3c0a00d commit 88de266
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion tonic-web/src/client.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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<F> {
Expand All @@ -98,3 +98,9 @@ where
Poll::Ready(res.map(|r| r.map(GrpcWebCall::client_response)))
}
}

impl<F> fmt::Debug for ResponseFuture<F> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ResponseFuture").finish()
}
}
7 changes: 6 additions & 1 deletion tonic-web/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F> {
Expand Down Expand Up @@ -179,6 +178,12 @@ impl<S: NamedService> NamedService for GrpcWebService<S> {
const NAME: &'static str = S::NAME;
}

impl<F> fmt::Debug for ResponseFuture<F> {
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) {
Expand Down

0 comments on commit 88de266

Please sign in to comment.