pub struct GrpcServerConn<C = Prost> { /* private fields */ }server only.Expand description
The control surface for a single gRPC call. Owns the Conn for the
duration of one RPC — value in, value out.
Implementations§
Source§impl<C> GrpcServerConn<C>
impl<C> GrpcServerConn<C>
Sourcepub fn received_headers(&self) -> &Headers
pub fn received_headers(&self) -> &Headers
The request’s initial metadata (received headers), including any custom metadata the client attached.
Sourcepub fn response_headers_mut(&mut self) -> &mut Headers
pub fn response_headers_mut(&mut self) -> &mut Headers
The response’s initial metadata, written straight through to the
Conn. Committed to the wire when the handler returns, before the first
response byte.
Sourcepub fn response_trailers_mut(&mut self) -> &mut Headers
pub fn response_trailers_mut(&mut self) -> &mut Headers
The response’s trailing metadata, emitted alongside grpc-status after
the response body.
Sourcepub fn deadline(&self) -> Option<Instant>
pub fn deadline(&self) -> Option<Instant>
The deadline derived from the request’s grpc-timeout header, if any.
Sourcepub fn requests<Req>(&mut self) -> RequestStream<'_, Req>where
C: Codec<Req>,
Req: 'static,
pub fn requests<Req>(&mut self) -> RequestStream<'_, Req>where
C: Codec<Req>,
Req: 'static,
A typed stream of decoded request messages.
Borrows the connection for the lifetime of the returned stream; read it
to EOF (or drop it) before touching response headers again. The codec’s
decode is selected by the GrpcServerConn’s codec parameter, so the only
thing you supply is the message type:
let mut reqs = conn.requests::<HelloRequest>();
while let Some(req) = reqs.recv().await? { /* … */ }Auto Trait Implementations§
impl<C = Prost> !RefUnwindSafe for GrpcServerConn<C>
impl<C = Prost> !UnwindSafe for GrpcServerConn<C>
impl<C> Freeze for GrpcServerConn<C>
impl<C> Send for GrpcServerConn<C>
impl<C> Sync for GrpcServerConn<C>
impl<C> Unpin for GrpcServerConn<C>
impl<C> UnsafeUnpin for GrpcServerConn<C>
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.