pub struct Channel<'a, Req, Resp> { /* private fields */ }Expand description
Bidirectional channel: read decoded requests, write framed responses, over the upgraded transport.
Handed to a BidiResponder. Turn-taking by
construction — both recv and send take
&mut self, so the underlying &mut Upgrade is never aliased. For producers
that need to run concurrently with the request loop, spawn a task on the
runtime.
The response initial metadata was committed before the upgrade (by the
prologue), so there is no way to mutate it here. The trailing metadata,
emitted after the loop alongside grpc-status, is still open: write it
through response_trailers_mut (the bag was
seeded with whatever the prologue set).
Implementations§
Source§impl<'a, Req, Resp> Channel<'a, Req, Resp>
impl<'a, Req, Resp> Channel<'a, Req, Resp>
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 once
the loop ends. Seeded with whatever the prologue set; write to it to add
trailing metadata (including grpc-status-details-bin error details)
from inside the loop.
Auto Trait Implementations§
impl<'a, Req, Resp> Freeze for Channel<'a, Req, Resp>
impl<'a, Req, Resp> !RefUnwindSafe for Channel<'a, Req, Resp>
impl<'a, Req, Resp> Send for Channel<'a, Req, Resp>
impl<'a, Req, Resp> Sync for Channel<'a, Req, Resp>
impl<'a, Req, Resp> Unpin for Channel<'a, Req, Resp>
impl<'a, Req, Resp> UnsafeUnpin for Channel<'a, Req, Resp>
impl<'a, Req, Resp> !UnwindSafe for Channel<'a, 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
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
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
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>,
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.