Struct tonic::client::Grpc [−][src]
pub struct Grpc<T> { /* fields omitted */ }
A gRPC client dispatcher.
This will wrap some inner GrpcService
and will encode/decode
messages via the provided codec.
Each request method takes a Request
, a PathAndQuery
, and a
Codec
. The request contains the message to send via the
Codec::encoder
. The path determines the fully qualified path
that will be append to the outgoing uri. The path must follow
the conventions explained in the gRPC protocol definition under Path →
. An
example of this path could look like /greeter.Greeter/SayHello
.
Implementations
impl<T> Grpc<T>
[src]
impl<T> Grpc<T>
[src]pub fn new(inner: T) -> Self
[src]
Creates a new gRPC client with the provided GrpcService
.
pub fn with_interceptor(inner: T, interceptor: impl Into<Interceptor>) -> Self
[src]
Creates a new gRPC client with the provided GrpcService
and will apply
the provided interceptor on each request.
pub async fn ready(&mut self) -> Result<(), T::Error> where
T: GrpcService<BoxBody>,
[src]
T: GrpcService<BoxBody>,
Check if the inner GrpcService
is able to accept a new request.
This will call GrpcService::poll_ready
until it returns ready or
an error. If this returns ready the inner GrpcService
is ready to
accept one more request.
pub async fn unary<M1, M2, C>(
&mut self,
request: Request<M1>,
path: PathAndQuery,
codec: C
) -> Result<Response<M2>, Status> where
T: GrpcService<BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
<T::ResponseBody as HttpBody>::Error: Into<Box<dyn Error + Send + Sync>>,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
[src]
&mut self,
request: Request<M1>,
path: PathAndQuery,
codec: C
) -> Result<Response<M2>, Status> where
T: GrpcService<BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
<T::ResponseBody as HttpBody>::Error: Into<Box<dyn Error + Send + Sync>>,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
Send a single unary gRPC request.
pub async fn client_streaming<S, M1, M2, C>(
&mut self,
request: Request<S>,
path: PathAndQuery,
codec: C
) -> Result<Response<M2>, Status> where
T: GrpcService<BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
<T::ResponseBody as HttpBody>::Error: Into<Box<dyn Error + Send + Sync>>,
S: Stream<Item = M1> + Send + Sync + 'static,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
[src]
&mut self,
request: Request<S>,
path: PathAndQuery,
codec: C
) -> Result<Response<M2>, Status> where
T: GrpcService<BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
<T::ResponseBody as HttpBody>::Error: Into<Box<dyn Error + Send + Sync>>,
S: Stream<Item = M1> + Send + Sync + 'static,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
Send a client side streaming gRPC request.
pub async fn server_streaming<M1, M2, C>(
&mut self,
request: Request<M1>,
path: PathAndQuery,
codec: C
) -> Result<Response<Streaming<M2>>, Status> where
T: GrpcService<BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
<T::ResponseBody as HttpBody>::Error: Into<Box<dyn Error + Send + Sync>>,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
[src]
&mut self,
request: Request<M1>,
path: PathAndQuery,
codec: C
) -> Result<Response<Streaming<M2>>, Status> where
T: GrpcService<BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
<T::ResponseBody as HttpBody>::Error: Into<Box<dyn Error + Send + Sync>>,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
Send a server side streaming gRPC request.
pub async fn streaming<S, M1, M2, C>(
&mut self,
request: Request<S>,
path: PathAndQuery,
codec: C
) -> Result<Response<Streaming<M2>>, Status> where
T: GrpcService<BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
<T::ResponseBody as HttpBody>::Error: Into<Box<dyn Error + Send + Sync>>,
S: Stream<Item = M1> + Send + Sync + 'static,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
[src]
&mut self,
request: Request<S>,
path: PathAndQuery,
codec: C
) -> Result<Response<Streaming<M2>>, Status> where
T: GrpcService<BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
<T::ResponseBody as HttpBody>::Error: Into<Box<dyn Error + Send + Sync>>,
S: Stream<Item = M1> + Send + Sync + 'static,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + Sync + 'static,
M2: Send + Sync + 'static,
Send a bi-directional streaming gRPC request.
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Grpc<T>
impl<T> !RefUnwindSafe for Grpc<T>
impl<T> !UnwindSafe for Grpc<T>
impl<T> !UnwindSafe for Grpc<T>
Blanket Implementations
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]pub 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;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
pub 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;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]pub 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;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
pub 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;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
impl<T> WithSubscriber for T
[src]pub 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>,
[src]
Notable traits for WithDispatch<T>
impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
S: Into<Dispatch>,
pub 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;
[src]
Notable traits for WithDispatch<T>
impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;