pub struct RpcClient<Request, Response>{ /* private fields */ }
Expand description
A client for sending RPCs to a protosockets rpc server.
It handles sending messages to the server and associating the responses. Messages are sent and received in any order, asynchronously, and support cancellation. To cancel an RPC, drop the response future.
Implementations§
Source§impl<Request, Response> RpcClient<Request, Response>
impl<Request, Response> RpcClient<Request, Response>
Sourcepub fn is_alive(&self) -> bool
pub fn is_alive(&self) -> bool
Checking this before using the client does not guarantee that the client is still alive when you send
your message. It may be useful for connection pool implementations - for example, bb8::ManageConnection’s
is_valid and has_broken could be bound to this function to help the pool cycle out broken connections.
Sourcepub async fn send_streaming(
&self,
request: Request,
) -> Result<StreamingCompletion<Response, Request>>
pub async fn send_streaming( &self, request: Request, ) -> Result<StreamingCompletion<Response, Request>>
Send a server-streaming rpc to the server.
This function only sends the request. You must consume the completion stream to get the response.
Sourcepub async fn send_unary(
&self,
request: Request,
) -> Result<UnaryCompletion<Response, Request>>
pub async fn send_unary( &self, request: Request, ) -> Result<UnaryCompletion<Response, Request>>
Send a unary rpc to the server.
This function only sends the request. You must await the completion to get the response.