Struct madsim_tonic::server::Grpc
source · [−]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 async fn unary<S, B>(
&'_ mut self,
service: S,
req: Request<B>
) -> Response<UnsyncBoxBody<Bytes, Status>> where
S: UnaryService<<T as Codec>::Decode, Response = <T as Codec>::Encode>,
B: 'static + Body + Send,
<B as Body>::Error: Into<Box<dyn Error + Send + Sync + 'static, Global>>,
<B as Body>::Error: Send,
pub async fn unary<S, B>(
&'_ mut self,
service: S,
req: Request<B>
) -> Response<UnsyncBoxBody<Bytes, Status>> where
S: UnaryService<<T as Codec>::Decode, Response = <T as Codec>::Encode>,
B: 'static + Body + Send,
<B as Body>::Error: Into<Box<dyn Error + Send + Sync + 'static, Global>>,
<B as Body>::Error: Send,
Handle a single unary gRPC request.
sourcepub async fn server_streaming<S, B>(
&'_ mut self,
service: S,
req: Request<B>
) -> Response<UnsyncBoxBody<Bytes, Status>> where
S: ServerStreamingService<<T as Codec>::Decode, Response = <T as Codec>::Encode>,
B: 'static + Body + Send,
<S as ServerStreamingService<<T as Codec>::Decode>>::ResponseStream: 'static,
<S as ServerStreamingService<<T as Codec>::Decode>>::ResponseStream: Send,
<B as Body>::Error: Into<Box<dyn Error + Send + Sync + 'static, Global>>,
<B as Body>::Error: Send,
pub async fn server_streaming<S, B>(
&'_ mut self,
service: S,
req: Request<B>
) -> Response<UnsyncBoxBody<Bytes, Status>> where
S: ServerStreamingService<<T as Codec>::Decode, Response = <T as Codec>::Encode>,
B: 'static + Body + Send,
<S as ServerStreamingService<<T as Codec>::Decode>>::ResponseStream: 'static,
<S as ServerStreamingService<<T as Codec>::Decode>>::ResponseStream: Send,
<B as Body>::Error: Into<Box<dyn Error + Send + Sync + 'static, Global>>,
<B as Body>::Error: Send,
Handle a server side streaming request.
sourcepub async fn client_streaming<S, B>(
&'_ mut self,
service: S,
req: Request<B>
) -> Response<UnsyncBoxBody<Bytes, Status>> where
S: ClientStreamingService<<T as Codec>::Decode, Response = <T as Codec>::Encode>,
B: 'static + Body + Send,
<B as Body>::Error: 'static,
<B as Body>::Error: Into<Box<dyn Error + Send + Sync + 'static, Global>>,
<B as Body>::Error: Send,
pub async fn client_streaming<S, B>(
&'_ mut self,
service: S,
req: Request<B>
) -> Response<UnsyncBoxBody<Bytes, Status>> where
S: ClientStreamingService<<T as Codec>::Decode, Response = <T as Codec>::Encode>,
B: 'static + Body + Send,
<B as Body>::Error: 'static,
<B as Body>::Error: Into<Box<dyn Error + Send + Sync + 'static, Global>>,
<B as Body>::Error: Send,
Handle a client side streaming gRPC request.
sourcepub async fn streaming<S, B>(
&'_ mut self,
service: S,
req: Request<B>
) -> Response<UnsyncBoxBody<Bytes, Status>> where
S: StreamingService<<T as Codec>::Decode, Response = <T as Codec>::Encode> + Send,
B: 'static + Body + Send,
<S as StreamingService<<T as Codec>::Decode>>::ResponseStream: 'static,
<S as StreamingService<<T as Codec>::Decode>>::ResponseStream: Send,
<B as Body>::Error: Into<Box<dyn Error + Send + Sync + 'static, Global>>,
<B as Body>::Error: Send,
pub async fn streaming<S, B>(
&'_ mut self,
service: S,
req: Request<B>
) -> Response<UnsyncBoxBody<Bytes, Status>> where
S: StreamingService<<T as Codec>::Decode, Response = <T as Codec>::Encode> + Send,
B: 'static + Body + Send,
<S as StreamingService<<T as Codec>::Decode>>::ResponseStream: 'static,
<S as StreamingService<<T as Codec>::Decode>>::ResponseStream: Send,
<B as Body>::Error: Into<Box<dyn Error + Send + Sync + 'static, Global>>,
<B as Body>::Error: 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message T
in a tonic::Request
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
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;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
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;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more