Enum libp2p::swarm::ConnectionHandlerEvent
source · pub enum ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> {
OutboundSubstreamRequest {
protocol: SubstreamProtocol<TConnectionUpgrade, TOutboundOpenInfo>,
},
Close(TErr),
ReportRemoteProtocols(ProtocolSupport),
NotifyBehaviour(TCustom),
}
Expand description
Event produced by a handler.
Variants§
OutboundSubstreamRequest
Request a new outbound substream to be opened with the remote.
Fields
protocol: SubstreamProtocol<TConnectionUpgrade, TOutboundOpenInfo>
The protocol(s) to apply on the substream.
Close(TErr)
ToSwarm::CloseConnection
or Swarm::close_connection
. See https://github.com/libp2p/rust-libp2p/issues/3591 for more details.Close the connection for the given reason.
Note this will affect all ConnectionHandler
s handling this
connection, in other words it will close the connection for all
ConnectionHandler
s. To signal that one has no more need for the
connection, while allowing other ConnectionHandler
s to continue using
the connection, return KeepAlive::No
in
ConnectionHandler::connection_keep_alive
.
ReportRemoteProtocols(ProtocolSupport)
We learned something about the protocols supported by the remote.
NotifyBehaviour(TCustom)
Event that is sent to a NetworkBehaviour
.
Implementations§
source§impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
Event produced by a handler.
sourcepub fn map_outbound_open_info<F, I>(
self,
map: F,
) -> ConnectionHandlerEvent<TConnectionUpgrade, I, TCustom, TErr>where
F: FnOnce(TOutboundOpenInfo) -> I,
pub fn map_outbound_open_info<F, I>(
self,
map: F,
) -> ConnectionHandlerEvent<TConnectionUpgrade, I, TCustom, TErr>where
F: FnOnce(TOutboundOpenInfo) -> I,
If this is an OutboundSubstreamRequest
, maps the info
member from a
TOutboundOpenInfo
to something else.
sourcepub fn map_protocol<F, I>(
self,
map: F,
) -> ConnectionHandlerEvent<I, TOutboundOpenInfo, TCustom, TErr>where
F: FnOnce(TConnectionUpgrade) -> I,
pub fn map_protocol<F, I>(
self,
map: F,
) -> ConnectionHandlerEvent<I, TOutboundOpenInfo, TCustom, TErr>where
F: FnOnce(TConnectionUpgrade) -> I,
If this is an OutboundSubstreamRequest
, maps the protocol (TConnectionUpgrade
)
to something else.
sourcepub fn map_custom<F, I>(
self,
map: F,
) -> ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, I, TErr>where
F: FnOnce(TCustom) -> I,
pub fn map_custom<F, I>(
self,
map: F,
) -> ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, I, TErr>where
F: FnOnce(TCustom) -> I,
If this is a Custom
event, maps the content to something else.
sourcepub fn map_close<F, I>(
self,
map: F,
) -> ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, I>where
F: FnOnce(TErr) -> I,
pub fn map_close<F, I>(
self,
map: F,
) -> ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, I>where
F: FnOnce(TErr) -> I,
If this is a Close
event, maps the content to something else.
Trait Implementations§
source§impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> Clone for ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> Clone for ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
source§fn clone(
&self,
) -> ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
fn clone( &self, ) -> ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> Debug for ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> Debug for ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
source§impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> PartialEq for ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> PartialEq for ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
source§fn eq(
&self,
other: &ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>,
) -> bool
fn eq( &self, other: &ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>, ) -> bool
self
and other
values to be equal, and is used
by ==
.impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> Eq for ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> StructuralPartialEq for ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
Auto Trait Implementations§
impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> Freeze for ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> RefUnwindSafe for ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>where
TErr: RefUnwindSafe,
TCustom: RefUnwindSafe,
TConnectionUpgrade: RefUnwindSafe,
TOutboundOpenInfo: RefUnwindSafe,
impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> Send for ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> Sync for ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> Unpin for ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr> UnwindSafe for ConnectionHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>where
TErr: UnwindSafe,
TCustom: UnwindSafe,
TConnectionUpgrade: UnwindSafe,
TOutboundOpenInfo: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§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