Module libp2p_swarm::handler
source · Expand description
Once a connection to a remote peer is established, a ConnectionHandler
negotiates
and handles one or more specific protocols on the connection.
Protocols are negotiated and used on individual substreams of the connection. Thus a
ConnectionHandler
defines the inbound and outbound upgrades to apply when creating a new
inbound or outbound substream, respectively, and is notified by a Swarm
when
these upgrades have been successfully applied, including the final output of the upgrade. A
ConnectionHandler
can then continue communicating with the peer over the substream using the
negotiated protocol(s).
Two ConnectionHandler
s can be composed with ConnectionHandler::select()
in order to build a new handler supporting the combined set of protocols,
with methods being dispatched to the appropriate handler according to the
used protocol(s) determined by the associated types of the handlers.
Note: A
ConnectionHandler
handles one or more protocols in the context of a single connection with a remote. In order to handle a protocol that requires knowledge of the network as a whole, see theNetworkBehaviour
trait.
Modules
ConnectionHandler
implementation that combines multiple other ConnectionHandler
s
indexed by some key.Structs
ConnectionEvent
variant that informs the handler about a change in the address of the remote.ConnectionHandler
that combines two protocols into one.ConnectionEvent
variant that informs the handler
that upgrading an outbound substream to the given protocol has failed.ConnectionEvent
variant that informs the handler about
the output of a successful upgrade on a new inbound substream.ConnectionEvent
variant that informs the handler about successful upgrade on a new outbound stream.IntoConnectionHandler
that combines two protocols into one.ConnectionEvent
variant that informs the handler
that upgrading an inbound substream to the given protocol has failed.ConnectionHandler
that opens a new substream for each request.OneShotHandler
ConnectionHandler
that returns a pending upgrade.OutboundUpgradeSend
, InboundUpgradeSend
, or
both, and implements OutboundUpgrade
and/or
InboundUpgrade
.ConnectionHandler
.Enums
on_connection_event
.Traits
InboundUpgrade
and Send + 'static
.ConnectionHandler
.OutboundUpgrade
and Send + 'static
.UpgradeInfo
and Send + 'static
.