pub struct UnaryConn<Req, Resp> { /* private fields */ }client only.Expand description
A unary or client-streaming call: one request (or a stream of requests) in, exactly one response out.
Build it with the chainable with_* setters, then .await it — awaiting
sends the request(s), reads the single response, drains the stream to its
trailers, and enforces the one-response cardinality. Transport-level failures
(connection, non-200 head) surface as the await’s Err; the RPC’s logical
grpc-status is read afterward via status /
into_message, so response metadata stays readable even
on a logical error.
Implementations§
Source§impl<Req, Resp> UnaryConn<Req, Resp>
impl<Req, Resp> UnaryConn<Req, Resp>
Sourcepub fn unary<C>(client: &Client, path: &str, request: Req) -> Self
pub fn unary<C>(client: &Client, path: &str, request: Req) -> Self
A unary call sending the single request.
Sourcepub fn client_streaming<C>(
client: &Client,
path: &str,
requests: impl Stream<Item = Req> + Send + 'static,
) -> Self
pub fn client_streaming<C>( client: &Client, path: &str, requests: impl Stream<Item = Req> + Send + 'static, ) -> Self
A client-streaming call sending each message from requests.
Sourcepub fn with_ascii_metadata(self, key: &str, value: &str) -> Self
pub fn with_ascii_metadata(self, key: &str, value: &str) -> Self
Attach an ASCII request-metadata entry. Chainable; takes effect when the call fires.
Sourcepub fn with_binary_metadata(self, key: &str, value: impl Into<Vec<u8>>) -> Self
pub fn with_binary_metadata(self, key: &str, value: impl Into<Vec<u8>>) -> Self
Attach a binary (-bin) request-metadata entry. Chainable.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set this call’s deadline, timeout from now. Chainable.
Sourcepub fn cancel_handle(&self) -> CancelHandle
pub fn cancel_handle(&self) -> CancelHandle
A handle that cancels this call from elsewhere (including before/while it is awaited).
Sourcepub fn metadata(&self) -> Option<&Headers>
pub fn metadata(&self) -> Option<&Headers>
The response’s initial metadata, once the call has run. None before.
Sourcepub fn trailers(&self) -> Option<&Headers>
pub fn trailers(&self) -> Option<&Headers>
The response’s trailing metadata, once the call has run. None before.
Sourcepub fn message(&self) -> Option<&Resp>
pub fn message(&self) -> Option<&Resp>
The response message, if the call ran and yielded one. None before the
call, and on the error path.
Trait Implementations§
Source§impl<Req, Resp> IntoFuture for UnaryConn<Req, Resp>
impl<Req, Resp> IntoFuture for UnaryConn<Req, Resp>
Source§type Output = Result<UnaryConn<Req, Resp>, Status>
type Output = Result<UnaryConn<Req, Resp>, Status>
Source§type IntoFuture = Pin<Box<dyn Future<Output = <UnaryConn<Req, Resp> as IntoFuture>::Output> + Send>>
type IntoFuture = Pin<Box<dyn Future<Output = <UnaryConn<Req, Resp> as IntoFuture>::Output> + Send>>
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Auto Trait Implementations§
impl<Req, Resp> !RefUnwindSafe for UnaryConn<Req, Resp>
impl<Req, Resp> !Sync for UnaryConn<Req, Resp>
impl<Req, Resp> !Unpin for UnaryConn<Req, Resp>
impl<Req, Resp> !UnsafeUnpin for UnaryConn<Req, Resp>
impl<Req, Resp> !UnwindSafe for UnaryConn<Req, Resp>
impl<Req, Resp> Freeze for UnaryConn<Req, Resp>where
Resp: Freeze,
impl<Req, Resp> Send for UnaryConn<Req, Resp>where
Resp: Send,
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.