Struct libp2p::core::connection::Connection
source · [−]pub struct Connection<TMuxer, THandler> where
TMuxer: StreamMuxer,
THandler: ConnectionHandler<Substream = SubstreamRef<Arc<TMuxer>>>, { /* private fields */ }
Expand description
A multiplexed connection to a peer with an associated ConnectionHandler
.
Implementations
sourceimpl<TMuxer, THandler> Connection<TMuxer, THandler> where
TMuxer: StreamMuxer,
THandler: ConnectionHandler<Substream = SubstreamRef<Arc<TMuxer>>>,
impl<TMuxer, THandler> Connection<TMuxer, THandler> where
TMuxer: StreamMuxer,
THandler: ConnectionHandler<Substream = SubstreamRef<Arc<TMuxer>>>,
sourcepub fn new(muxer: TMuxer, handler: THandler) -> Connection<TMuxer, THandler>
pub fn new(muxer: TMuxer, handler: THandler) -> Connection<TMuxer, THandler>
Builds a new Connection
from the given substream multiplexer
and connection handler.
sourcepub fn handler_mut(&mut self) -> &mut THandler
pub fn handler_mut(&mut self) -> &mut THandler
Returns a mutable reference to the ConnectionHandler
sourcepub fn inject_event(&mut self, event: <THandler as ConnectionHandler>::InEvent)
pub fn inject_event(&mut self, event: <THandler as ConnectionHandler>::InEvent)
Notifies the connection handler of an event.
sourcepub fn close(self) -> Close<TMuxer>ⓘNotable traits for Close<TMuxer>impl<TMuxer> Future for Close<TMuxer> where
TMuxer: StreamMuxer, type Output = Result<(), Error>;
pub fn close(self) -> Close<TMuxer>ⓘNotable traits for Close<TMuxer>impl<TMuxer> Future for Close<TMuxer> where
TMuxer: StreamMuxer, type Output = Result<(), Error>;
TMuxer: StreamMuxer, type Output = Result<(), Error>;
Begins an orderly shutdown of the connection, returning a
Future
that resolves when connection shutdown is complete.
sourcepub fn poll(
self: Pin<&mut Connection<TMuxer, THandler>>,
cx: &mut Context<'_>
) -> Poll<Result<Event<<THandler as ConnectionHandler>::OutEvent>, ConnectionError<<THandler as ConnectionHandler>::Error>>>
pub fn poll(
self: Pin<&mut Connection<TMuxer, THandler>>,
cx: &mut Context<'_>
) -> Poll<Result<Event<<THandler as ConnectionHandler>::OutEvent>, ConnectionError<<THandler as ConnectionHandler>::Error>>>
Polls the connection for events produced by the associated handler as a result of I/O activity on the substream multiplexer.
Trait Implementations
sourceimpl<TMuxer, THandler> Debug for Connection<TMuxer, THandler> where
TMuxer: StreamMuxer,
THandler: ConnectionHandler<Substream = SubstreamRef<Arc<TMuxer>>> + Debug,
impl<TMuxer, THandler> Debug for Connection<TMuxer, THandler> where
TMuxer: StreamMuxer,
THandler: ConnectionHandler<Substream = SubstreamRef<Arc<TMuxer>>> + Debug,
impl<TMuxer, THandler> Unpin for Connection<TMuxer, THandler> where
TMuxer: StreamMuxer,
THandler: ConnectionHandler<Substream = SubstreamRef<Arc<TMuxer>>>,
Auto Trait Implementations
impl<TMuxer, THandler> RefUnwindSafe for Connection<TMuxer, THandler> where
THandler: RefUnwindSafe,
TMuxer: RefUnwindSafe,
<THandler as ConnectionHandler>::OutboundOpenInfo: RefUnwindSafe,
<TMuxer as StreamMuxer>::OutboundSubstream: RefUnwindSafe,
impl<TMuxer, THandler> Send for Connection<TMuxer, THandler> where
THandler: Send,
TMuxer: Send + Sync,
<THandler as ConnectionHandler>::OutboundOpenInfo: Send,
<TMuxer as StreamMuxer>::OutboundSubstream: Send,
impl<TMuxer, THandler> Sync for Connection<TMuxer, THandler> where
THandler: Sync,
TMuxer: Send + Sync,
<THandler as ConnectionHandler>::OutboundOpenInfo: Sync,
<TMuxer as StreamMuxer>::OutboundSubstream: Sync,
impl<TMuxer, THandler> UnwindSafe for Connection<TMuxer, THandler> where
THandler: UnwindSafe,
TMuxer: RefUnwindSafe,
<THandler as ConnectionHandler>::OutboundOpenInfo: UnwindSafe + RefUnwindSafe,
<TMuxer as StreamMuxer>::OutboundSubstream: UnwindSafe + RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more