pub struct DuplexClient<Out: RemoteMessage, In: RemoteMessage> { /* private fields */ }Expand description
A handle to a duplex client session: wraps the send/recv halves
and the spawned task driving the connection. Owns a cancellation
token so callers can deterministically stop the recv/send loop
via DuplexClient::join.
Dropping a DuplexClient does not cancel — that would tear
down sessions whose tx/rx halves the application has handed off
elsewhere (e.g., into a mailbox). Call join for
orderly shutdown.
Implementations§
Source§impl<Out: RemoteMessage, In: RemoteMessage> DuplexClient<Out, In>
impl<Out: RemoteMessage, In: RemoteMessage> DuplexClient<Out, In>
Sourcepub fn tx(&self) -> DuplexTx<Out>
pub fn tx(&self) -> DuplexTx<Out>
Get a new clone of the DuplexTx for sending messages to
the peer.
Sourcepub fn take_rx(&mut self) -> Option<DuplexRx<In>>
pub fn take_rx(&mut self) -> Option<DuplexRx<In>>
Take the DuplexRx out of the client. Returns None on
subsequent calls — the receiver is single-consumer.
Sourcepub fn addr(&self) -> &ChannelAddr
pub fn addr(&self) -> &ChannelAddr
The peer address this client dialed.
Sourcepub async fn join(self)
pub async fn join(self)
Gracefully shut down the duplex client session. Cancels the
recv/send loop’s cancellation token (which the spawned task
observes in its select!s) and awaits the spawned task. On
return, the task has finished its terminal cleanup (final
ack flush on ACCEPTOR_TO_INITIATOR) and dropped its
inbound_tx / outbound receiver halves —
so any in-progress DuplexRx::recv on
the receiver half resolves with ChannelError::Closed.
Trait Implementations§
Source§impl<Out: RemoteMessage, In: RemoteMessage> Debug for DuplexClient<Out, In>
impl<Out: RemoteMessage, In: RemoteMessage> Debug for DuplexClient<Out, In>
Auto Trait Implementations§
impl<Out, In> Freeze for DuplexClient<Out, In>
impl<Out, In> !RefUnwindSafe for DuplexClient<Out, In>
impl<Out, In> Send for DuplexClient<Out, In>
impl<Out, In> Sync for DuplexClient<Out, In>
impl<Out, In> Unpin for DuplexClient<Out, In>
impl<Out, In> UnsafeUnpin for DuplexClient<Out, In>
impl<Out, In> !UnwindSafe for DuplexClient<Out, In>
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<A, M> Handler<IndexedErasedUnbound<M>> for A
impl<A, M> Handler<IndexedErasedUnbound<M>> for A
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].