pub struct GrpcClientConn<Req, Resp> { /* private fields */ }client only.Expand description
Implementations§
Source§impl<Req, Resp> GrpcClientConn<Req, Resp>
impl<Req, Resp> GrpcClientConn<Req, Resp>
Sourcepub fn new<C>(
client: &Client,
path: &str,
metadata: Metadata,
timeout: Option<Duration>,
full_duplex: bool,
) -> Self
pub fn new<C>( client: &Client, path: &str, metadata: Metadata, timeout: Option<Duration>, full_duplex: bool, ) -> Self
Open a call over codec C, deriving the content-type and encode/decode
from the Codec impl and the outbound compression from
the client’s configured grpc-encoding. No network I/O happens until
close_send or the first recv.
Sourcepub fn cancel_handle(&self) -> CancelHandle
pub fn cancel_handle(&self) -> CancelHandle
A cancellation handle for this call. Clone it freely; calling
cancel on any clone cancels this RPC.
Sourcepub fn headers(&self) -> Option<&Headers>
pub fn headers(&self) -> Option<&Headers>
The response’s initial metadata, available once the head has arrived
(after the first recv, or after close_send for half-duplex). None
before then.
Sourcepub fn trailers(&self) -> Option<&Headers>
pub fn trailers(&self) -> Option<&Headers>
The response’s trailing metadata, available once the response stream has
ended. None before end-of-stream.
Sourcepub async fn send(&mut self, message: Req) -> Result<(), Status>
pub async fn send(&mut self, message: Req) -> Result<(), Status>
Frame and send one request message.
Before the request has fired (the common case for half-duplex), this accumulates the frame into the request body. Once a full-duplex call is live, it writes the frame on the wire immediately.
Sourcepub async fn close_send(&mut self) -> Result<(), Status>
pub async fn close_send(&mut self) -> Result<(), Status>
Half-close the request side (sends END_STREAM).
For send-then-receive shapes this is what fires the request: the accumulated body is sent with END_STREAM and the response head is awaited. For a live full-duplex call it closes the write half, leaving the read side open.
Auto Trait Implementations§
impl<Req, Resp> !RefUnwindSafe for GrpcClientConn<Req, Resp>
impl<Req, Resp> !Unpin for GrpcClientConn<Req, Resp>
impl<Req, Resp> !UnsafeUnpin for GrpcClientConn<Req, Resp>
impl<Req, Resp> !UnwindSafe for GrpcClientConn<Req, Resp>
impl<Req, Resp> Freeze for GrpcClientConn<Req, Resp>
impl<Req, Resp> Send for GrpcClientConn<Req, Resp>
impl<Req, Resp> Sync for GrpcClientConn<Req, Resp>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Server for Twhere
T: 'static,
impl<T> Server for Twhere
T: 'static,
Source§async fn unary<Req, Resp>(
conn: Conn,
f: impl AsyncFnOnce(&mut GrpcServerConn<Self>, Req) -> Result<Resp, Status>,
) -> Conn
async fn unary<Req, Resp>( conn: Conn, f: impl AsyncFnOnce(&mut GrpcServerConn<Self>, Req) -> Result<Resp, Status>, ) -> Conn
server only.grpc-status trailers.Source§async fn client_streaming<Resp>(
conn: Conn,
f: impl AsyncFnOnce(&mut GrpcServerConn<Self>) -> Result<Resp, Status>,
) -> Conn
async fn client_streaming<Resp>( conn: Conn, f: impl AsyncFnOnce(&mut GrpcServerConn<Self>) -> Result<Resp, Status>, ) -> Conn
server only.GrpcServerConn from which they read
the request stream (conn.requests::<Req>()); emit the single response
frame and grpc-status trailers.Source§async fn server_streaming<Req, Resp, S>(
conn: Conn,
f: impl AsyncFnOnce(&mut GrpcServerConn<Self>, Req) -> Result<S, Status>,
) -> Conn
async fn server_streaming<Req, Resp, S>( conn: Conn, f: impl AsyncFnOnce(&mut GrpcServerConn<Self>, Req) -> Result<S, Status>, ) -> Conn
server only.Stream, then frame each item lazily into the response body
with grpc-status trailers derived from how the stream ended.Source§async fn bidi<Req, Resp, R>(
conn: Conn,
prologue: impl AsyncFnOnce(&mut GrpcServerConn<Self>) -> Result<R, Status>,
) -> Connwhere
Self: Codec<Req> + Codec<Resp>,
Req: Send + 'static,
Resp: Send + 'static,
R: BidiResponder<Req, Resp>,
async fn bidi<Req, Resp, R>(
conn: Conn,
prologue: impl AsyncFnOnce(&mut GrpcServerConn<Self>) -> Result<R, Status>,
) -> Connwhere
Self: Codec<Req> + Codec<Resp>,
Req: Send + 'static,
Resp: Send + 'static,
R: BidiResponder<Req, Resp>,
server only.GrpcServerConn from which they may read early request messages (to decide
response headers) and set initial metadata, then return a
BidiResponder that drives the read-while-write loop after the head is
flushed. Returning Err(Status) rejects before the flush (trailers-only,
no upgrade). See crate::server::bidi for the seam mechanics.