Module handler
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§
- either
- multi
- A
ConnectionHandler
implementation that combines multiple otherConnectionHandler
s indexed by some key.
Structs§
- Address
Change ConnectionEvent
variant that informs the handler about a change in the address of the remote.- Connection
Handler Select - Implementation of
ConnectionHandler
that combines two protocols into one. - Dial
Upgrade Error ConnectionEvent
variant that informs the handler that upgrading an outbound substream to the given protocol has failed.- Fully
Negotiated Inbound ConnectionEvent
variant that informs the handler about the output of a successful upgrade on a new inbound substream.- Fully
Negotiated Outbound ConnectionEvent
variant that informs the handler about successful upgrade on a new outbound stream.- Listen
Upgrade Error ConnectionEvent
variant that informs the handler that upgrading an inbound substream to the given protocol has failed.- MapIn
Event - Wrapper around a protocol handler that turns the input event into something else.
- MapOut
Event - Wrapper around a protocol handler that turns the output event into something else.
- OneShot
Handler - A
ConnectionHandler
that opens a new substream for each request. - OneShot
Handler Config - Configuration parameters for the
OneShotHandler
- Pending
Connection Handler - Implementation of
ConnectionHandler
that returns a pending upgrade. - Protocols
Added - An
Iterator
over all protocols that have been added. - Protocols
Removed - An
Iterator
over all protocols that have been removed. - Send
Wrapper - Wraps around a type that implements
OutboundUpgradeSend
,InboundUpgradeSend
, or - Substream
Protocol - Configuration of inbound or outbound substream protocol(s)
for a
ConnectionHandler
.
Enums§
- Connection
Event - Enumeration with the list of the possible stream events
to pass to
on_connection_event
. - Connection
Handler Event - Event produced by a handler.
- Protocol
Support - Protocols
Change ConnectionEvent
variant that informs the handler about a change in the protocols supported on the connection.- Stream
Upgrade Error - Error that can happen on an outbound substream opening attempt.
Traits§
- Connection
Handler - A handler for a set of protocols used on a connection with a remote.
- Inbound
Upgrade Send - Implemented automatically on all types that implement
InboundUpgrade
andSend + 'static
. - Outbound
Upgrade Send - Implemented automatically on all types that implement
OutboundUpgrade
andSend + 'static
. - Upgrade
Info Send - Implemented automatically on all types that implement
UpgradeInfo
andSend + 'static
.