pub struct Grpc<T> { /* private fields */ }
Expand description
A gRPC Server handler.
This will wrap some inner Codec
and provide utilities to handle
inbound unary, client side streaming, server side streaming, and
bi-directional streaming.
Each request handler method accepts some service that implements the
corresponding service trait and a http request that contains some body that
implements some Body
.
Implementations
sourceimpl<T> Grpc<T>where
T: Codec,
impl<T> Grpc<T>where
T: Codec,
sourcepub fn accept_gzip(self) -> Self
pub fn accept_gzip(self) -> Self
Enable accepting gzip
compressed requests.
If a request with an unsupported encoding is received the server will respond with
Code::UnUnimplemented
.
Example
The most common way of using this is through a server generated by tonic-build:
#[tonic::async_trait]
impl Example for Svc {
// ...
}
let service = ExampleServer::new(Svc).accept_gzip();
sourcepub fn send_gzip(self) -> Self
pub fn send_gzip(self) -> Self
Enable sending gzip
compressed responses.
Requires the client to also support receiving compressed responses.
Example
The most common way of using this is through a server generated by tonic-build:
#[tonic::async_trait]
impl Example for Svc {
// ...
}
let service = ExampleServer::new(Svc).send_gzip();
sourcepub async fn unary<S, B>(
&mut self,
service: S,
req: Request<B>
) -> Response<BoxBody>where
S: UnaryService<T::Decode, Response = T::Encode>,
B: Body + Send + 'static,
B::Error: Into<Box<dyn Error + Send + Sync>> + Send,
pub async fn unary<S, B>(
&mut self,
service: S,
req: Request<B>
) -> Response<BoxBody>where
S: UnaryService<T::Decode, Response = T::Encode>,
B: Body + Send + 'static,
B::Error: Into<Box<dyn Error + Send + Sync>> + Send,
Handle a single unary gRPC request.
sourcepub async fn server_streaming<S, B>(
&mut self,
service: S,
req: Request<B>
) -> Response<BoxBody>where
S: ServerStreamingService<T::Decode, Response = T::Encode>,
S::ResponseStream: Send + 'static,
B: Body + Send + 'static,
B::Error: Into<Box<dyn Error + Send + Sync>> + Send,
pub async fn server_streaming<S, B>(
&mut self,
service: S,
req: Request<B>
) -> Response<BoxBody>where
S: ServerStreamingService<T::Decode, Response = T::Encode>,
S::ResponseStream: Send + 'static,
B: Body + Send + 'static,
B::Error: Into<Box<dyn Error + Send + Sync>> + Send,
Handle a server side streaming request.
sourcepub async fn client_streaming<S, B>(
&mut self,
service: S,
req: Request<B>
) -> Response<BoxBody>where
S: ClientStreamingService<T::Decode, Response = T::Encode>,
B: Body + Send + 'static,
B::Error: Into<Box<dyn Error + Send + Sync>> + Send + 'static,
pub async fn client_streaming<S, B>(
&mut self,
service: S,
req: Request<B>
) -> Response<BoxBody>where
S: ClientStreamingService<T::Decode, Response = T::Encode>,
B: Body + Send + 'static,
B::Error: Into<Box<dyn Error + Send + Sync>> + Send + 'static,
Handle a client side streaming gRPC request.
sourcepub async fn streaming<S, B>(
&mut self,
service: S,
req: Request<B>
) -> Response<BoxBody>where
S: StreamingService<T::Decode, Response = T::Encode> + Send,
S::ResponseStream: Send + 'static,
B: Body + Send + 'static,
B::Error: Into<Box<dyn Error + Send + Sync>> + Send,
pub async fn streaming<S, B>(
&mut self,
service: S,
req: Request<B>
) -> Response<BoxBody>where
S: StreamingService<T::Decode, Response = T::Encode> + Send,
S::ResponseStream: Send + 'static,
B: Body + Send + 'static,
B::Error: Into<Box<dyn Error + Send + Sync>> + Send,
Handle a bi-directional streaming gRPC request.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for Grpc<T>where
T: RefUnwindSafe,
impl<T> Send for Grpc<T>where
T: Send,
impl<T> Sync for Grpc<T>where
T: Sync,
impl<T> Unpin for Grpc<T>where
T: Unpin,
impl<T> UnwindSafe for Grpc<T>where
T: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;