[−][src]Trait libp2p::swarm::protocols_handler::ProtocolsHandler
A handler for a set of protocols used on a connection with a remote.
This trait should be implemented for a type that maintains the state for the execution of a specific protocol with a remote.
Handling a protocol
Communication with a remote over a set of protocols is initiated in one of two ways:
-
Dialing by initiating a new outbound substream. In order to do so, [
ProtocolsHandler::poll()
] must return an [OutboundSubstreamRequest
], providing an instance of [ProtocolsHandler::OutboundUpgrade
] that is used to negotiate the protocol(s). Upon success, [ProtocolsHandler::inject_fully_negotiated_outbound
] is called with the final output of the upgrade. -
Listening by accepting a new inbound substream. When a new inbound substream is created on a connection, [
ProtocolsHandler::listen_protocol
] is called to obtain an instance of [ProtocolsHandler::InboundUpgrade
] that is used to negotiate the protocol(s). Upon success, [ProtocolsHandler::inject_fully_negotiated_inbound
] is called with the final output of the upgrade.
Connection Keep-Alive
A ProtocolsHandler
can influence the lifetime of the underlying connection
through [ProtocolsHandler::connection_keep_alive
]. That is, the protocol
implemented by the handler can include conditions for terminating the connection.
The lifetime of successfully negotiated substreams is fully controlled by the handler.
Implementors of this trait should keep in mind that the connection can be closed at any time. When a connection is closed gracefully, the substreams used by the handler may still continue reading data until the remote closes its side of the connection.
Associated Types
type InEvent
Custom event that can be received from the outside.
type OutEvent
Custom event that can be produced by the handler and that will be returned to the outside.
type Error: Error
The type of errors returned by [ProtocolsHandler::poll
].
type Substream: AsyncRead + AsyncWrite
The type of substreams on which the protocol(s) are negotiated.
type InboundProtocol: InboundUpgrade<Self::Substream>
The inbound upgrade for the protocol(s) used by the handler.
type OutboundProtocol: OutboundUpgrade<Self::Substream>
The outbound upgrade for the protocol(s) used by the handler.
type OutboundOpenInfo
The type of additional information passed to an OutboundSubstreamRequest
.
Required methods
fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol>
The InboundUpgrade
to apply on inbound substreams to negotiate the
desired protocols.
Note: The returned
InboundUpgrade
should always accept all the generally supported protocols, even if in a specific context a particular one is not supported, (eg. when only allowing one substream at a time for a protocol). This allows a remote to put the list of supported protocols in a cache.
fn inject_fully_negotiated_inbound(
&mut self,
protocol: <Self::InboundProtocol as InboundUpgrade<Self::Substream>>::Output
)
&mut self,
protocol: <Self::InboundProtocol as InboundUpgrade<Self::Substream>>::Output
)
Injects the output of a successful upgrade on a new inbound substream.
fn inject_fully_negotiated_outbound(
&mut self,
protocol: <Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Output,
info: Self::OutboundOpenInfo
)
&mut self,
protocol: <Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Output,
info: Self::OutboundOpenInfo
)
Injects the output of a successful upgrade on a new outbound substream.
The second argument is the information that was previously passed to
[ProtocolsHandlerEvent::OutboundSubstreamRequest
].
fn inject_event(&mut self, event: Self::InEvent)
Injects an event coming from the outside in the handler.
fn inject_dial_upgrade_error(
&mut self,
info: Self::OutboundOpenInfo,
error: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Error>
)
&mut self,
info: Self::OutboundOpenInfo,
error: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Error>
)
Indicates to the handler that upgrading a substream to the given protocol has failed.
fn connection_keep_alive(&self) -> KeepAlive
Returns until when the connection should be kept alive.
This method is called by the Swarm
after each invocation of
[ProtocolsHandler::poll
] to determine if the connection and the associated
ProtocolsHandler
s should be kept alive as far as this handler is concerned
and if so, for how long.
Returning [KeepAlive::No
] indicates that the connection should be
closed and this handler destroyed immediately.
Returning [KeepAlive::Until
] indicates that the connection may be closed
and this handler destroyed after the specified Instant
.
Returning [KeepAlive::Yes
] indicates that the connection should
be kept alive until the next call to this method.
Note: The connection is always closed and the handler destroyed when [
ProtocolsHandler::poll
] returns an error. Furthermore, the connection may be closed for reasons outside of the control of the handler.
fn poll(
&mut self
) -> Result<Async<ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent>>, Self::Error>
&mut self
) -> Result<Async<ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent>>, Self::Error>
Should behave like Stream::poll()
.
Returning an error will close the connection to the remote.
Provided methods
fn map_in_event<TNewIn, TMap>(self, map: TMap) -> MapInEvent<Self, TNewIn, TMap> where
TMap: Fn(&TNewIn) -> Option<&Self::InEvent>,
TMap: Fn(&TNewIn) -> Option<&Self::InEvent>,
Adds a closure that turns the input event into something else.
fn map_out_event<TMap, TNewOut>(self, map: TMap) -> MapOutEvent<Self, TMap> where
TMap: FnMut(Self::OutEvent) -> TNewOut,
TMap: FnMut(Self::OutEvent) -> TNewOut,
Adds a closure that turns the output event into something else.
fn select<TProto2>(
self,
other: TProto2
) -> ProtocolsHandlerSelect<Self, TProto2>
self,
other: TProto2
) -> ProtocolsHandlerSelect<Self, TProto2>
Creates a new ProtocolsHandler
that selects either this handler or
other
by delegating methods calls appropriately.
Note: The largest
KeepAlive
returned by the two handlers takes precedence, i.e. is returned from [ProtocolsHandler::connection_keep_alive
] by the returned handler.
fn into_node_handler_builder(self) -> NodeHandlerWrapperBuilder<Self>
Creates a builder that allows creating a NodeHandler
that handles this protocol
exclusively.
Note: This method should not be redefined in a custom
ProtocolsHandler
.
fn into_node_handler(self) -> NodeHandlerWrapper<Self>
Use into_node_handler_builder instead
Builds an implementation of NodeHandler
that handles this protocol exclusively.
Note: This is a shortcut for
self.into_node_handler_builder().build()
.
Implementors
impl<TInner> ProtocolsHandler for ToggleProtoHandler<TInner> where
TInner: ProtocolsHandler,
[src]
TInner: ProtocolsHandler,
type InEvent = <TInner as ProtocolsHandler>::InEvent
type OutEvent = <TInner as ProtocolsHandler>::OutEvent
type Error = <TInner as ProtocolsHandler>::Error
type Substream = <TInner as ProtocolsHandler>::Substream
type InboundProtocol = EitherUpgrade<<TInner as ProtocolsHandler>::InboundProtocol, DeniedUpgrade>
type OutboundProtocol = <TInner as ProtocolsHandler>::OutboundProtocol
type OutboundOpenInfo = <TInner as ProtocolsHandler>::OutboundOpenInfo
fn listen_protocol(
&self
) -> SubstreamProtocol<<ToggleProtoHandler<TInner> as ProtocolsHandler>::InboundProtocol>
[src]
&self
) -> SubstreamProtocol<<ToggleProtoHandler<TInner> as ProtocolsHandler>::InboundProtocol>
fn inject_fully_negotiated_inbound(
&mut self,
out: <<ToggleProtoHandler<TInner> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<<ToggleProtoHandler<TInner> as ProtocolsHandler>::Substream>>::Output
)
[src]
&mut self,
out: <<ToggleProtoHandler<TInner> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<<ToggleProtoHandler<TInner> as ProtocolsHandler>::Substream>>::Output
)
fn inject_fully_negotiated_outbound(
&mut self,
out: <<ToggleProtoHandler<TInner> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<ToggleProtoHandler<TInner> as ProtocolsHandler>::Substream>>::Output,
info: <ToggleProtoHandler<TInner> as ProtocolsHandler>::OutboundOpenInfo
)
[src]
&mut self,
out: <<ToggleProtoHandler<TInner> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<ToggleProtoHandler<TInner> as ProtocolsHandler>::Substream>>::Output,
info: <ToggleProtoHandler<TInner> as ProtocolsHandler>::OutboundOpenInfo
)
fn inject_event(
&mut self,
event: <ToggleProtoHandler<TInner> as ProtocolsHandler>::InEvent
)
[src]
&mut self,
event: <ToggleProtoHandler<TInner> as ProtocolsHandler>::InEvent
)
fn inject_dial_upgrade_error(
&mut self,
info: <ToggleProtoHandler<TInner> as ProtocolsHandler>::OutboundOpenInfo,
err: ProtocolsHandlerUpgrErr<<<ToggleProtoHandler<TInner> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<ToggleProtoHandler<TInner> as ProtocolsHandler>::Substream>>::Error>
)
[src]
&mut self,
info: <ToggleProtoHandler<TInner> as ProtocolsHandler>::OutboundOpenInfo,
err: ProtocolsHandlerUpgrErr<<<ToggleProtoHandler<TInner> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<ToggleProtoHandler<TInner> as ProtocolsHandler>::Substream>>::Error>
)
fn connection_keep_alive(&self) -> KeepAlive
[src]
fn poll(
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<ToggleProtoHandler<TInner> as ProtocolsHandler>::OutboundProtocol, <ToggleProtoHandler<TInner> as ProtocolsHandler>::OutboundOpenInfo, <ToggleProtoHandler<TInner> as ProtocolsHandler>::OutEvent>>, <ToggleProtoHandler<TInner> as ProtocolsHandler>::Error>
[src]
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<ToggleProtoHandler<TInner> as ProtocolsHandler>::OutboundProtocol, <ToggleProtoHandler<TInner> as ProtocolsHandler>::OutboundOpenInfo, <ToggleProtoHandler<TInner> as ProtocolsHandler>::OutEvent>>, <ToggleProtoHandler<TInner> as ProtocolsHandler>::Error>
impl<TProtoHandler, TMap, TNewIn> ProtocolsHandler for MapInEvent<TProtoHandler, TNewIn, TMap> where
TMap: Fn(TNewIn) -> Option<<TProtoHandler as ProtocolsHandler>::InEvent>,
TProtoHandler: ProtocolsHandler,
[src]
TMap: Fn(TNewIn) -> Option<<TProtoHandler as ProtocolsHandler>::InEvent>,
TProtoHandler: ProtocolsHandler,
type InEvent = TNewIn
type OutEvent = <TProtoHandler as ProtocolsHandler>::OutEvent
type Error = <TProtoHandler as ProtocolsHandler>::Error
type Substream = <TProtoHandler as ProtocolsHandler>::Substream
type InboundProtocol = <TProtoHandler as ProtocolsHandler>::InboundProtocol
type OutboundProtocol = <TProtoHandler as ProtocolsHandler>::OutboundProtocol
type OutboundOpenInfo = <TProtoHandler as ProtocolsHandler>::OutboundOpenInfo
fn listen_protocol(
&self
) -> SubstreamProtocol<<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::InboundProtocol>
[src]
&self
) -> SubstreamProtocol<<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::InboundProtocol>
fn inject_fully_negotiated_inbound(
&mut self,
protocol: <<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::Substream>>::Output
)
[src]
&mut self,
protocol: <<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::Substream>>::Output
)
fn inject_fully_negotiated_outbound(
&mut self,
protocol: <<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::Substream>>::Output,
info: <MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::OutboundOpenInfo
)
[src]
&mut self,
protocol: <<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::Substream>>::Output,
info: <MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::OutboundOpenInfo
)
fn inject_event(&mut self, event: TNewIn)
[src]
fn inject_dial_upgrade_error(
&mut self,
info: <MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::OutboundOpenInfo,
error: ProtocolsHandlerUpgrErr<<<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::Substream>>::Error>
)
[src]
&mut self,
info: <MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::OutboundOpenInfo,
error: ProtocolsHandlerUpgrErr<<<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::Substream>>::Error>
)
fn connection_keep_alive(&self) -> KeepAlive
[src]
fn poll(
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::OutboundProtocol, <MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::OutboundOpenInfo, <MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::OutEvent>>, <MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::Error>
[src]
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::OutboundProtocol, <MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::OutboundOpenInfo, <MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::OutEvent>>, <MapInEvent<TProtoHandler, TNewIn, TMap> as ProtocolsHandler>::Error>
impl<TProtoHandler, TMap, TNewOut> ProtocolsHandler for MapOutEvent<TProtoHandler, TMap> where
TMap: FnMut(<TProtoHandler as ProtocolsHandler>::OutEvent) -> TNewOut,
TProtoHandler: ProtocolsHandler,
[src]
TMap: FnMut(<TProtoHandler as ProtocolsHandler>::OutEvent) -> TNewOut,
TProtoHandler: ProtocolsHandler,
type InEvent = <TProtoHandler as ProtocolsHandler>::InEvent
type OutEvent = TNewOut
type Error = <TProtoHandler as ProtocolsHandler>::Error
type Substream = <TProtoHandler as ProtocolsHandler>::Substream
type InboundProtocol = <TProtoHandler as ProtocolsHandler>::InboundProtocol
type OutboundProtocol = <TProtoHandler as ProtocolsHandler>::OutboundProtocol
type OutboundOpenInfo = <TProtoHandler as ProtocolsHandler>::OutboundOpenInfo
fn listen_protocol(
&self
) -> SubstreamProtocol<<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::InboundProtocol>
[src]
&self
) -> SubstreamProtocol<<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::InboundProtocol>
fn inject_fully_negotiated_inbound(
&mut self,
protocol: <<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::Substream>>::Output
)
[src]
&mut self,
protocol: <<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::Substream>>::Output
)
fn inject_fully_negotiated_outbound(
&mut self,
protocol: <<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::Substream>>::Output,
info: <MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::OutboundOpenInfo
)
[src]
&mut self,
protocol: <<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::Substream>>::Output,
info: <MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::OutboundOpenInfo
)
fn inject_event(
&mut self,
event: <MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::InEvent
)
[src]
&mut self,
event: <MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::InEvent
)
fn inject_dial_upgrade_error(
&mut self,
info: <MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::OutboundOpenInfo,
error: ProtocolsHandlerUpgrErr<<<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::Substream>>::Error>
)
[src]
&mut self,
info: <MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::OutboundOpenInfo,
error: ProtocolsHandlerUpgrErr<<<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::Substream>>::Error>
)
fn connection_keep_alive(&self) -> KeepAlive
[src]
fn poll(
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::OutboundProtocol, <MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::OutboundOpenInfo, <MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::OutEvent>>, <MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::Error>
[src]
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::OutboundProtocol, <MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::OutboundOpenInfo, <MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::OutEvent>>, <MapOutEvent<TProtoHandler, TMap> as ProtocolsHandler>::Error>
impl<TSubstream> ProtocolsHandler for IdentifyListenHandler<TSubstream> where
TSubstream: AsyncRead + AsyncWrite,
[src]
TSubstream: AsyncRead + AsyncWrite,
type InEvent = Void
type OutEvent = IdentifySender<Negotiated<TSubstream>>
type Error = Void
type Substream = TSubstream
type InboundProtocol = IdentifyProtocolConfig
type OutboundProtocol = DeniedUpgrade
type OutboundOpenInfo = ()
fn listen_protocol(
&self
) -> SubstreamProtocol<<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::InboundProtocol>
[src]
&self
) -> SubstreamProtocol<<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::InboundProtocol>
fn inject_fully_negotiated_inbound(
&mut self,
protocol: <<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<TSubstream>>::Output
)
[src]
&mut self,
protocol: <<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<TSubstream>>::Output
)
fn inject_fully_negotiated_outbound(
&mut self,
protocol: Void,
<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo
)
[src]
&mut self,
protocol: Void,
<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo
)
fn inject_event(
&mut self,
<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::InEvent
)
[src]
&mut self,
<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::InEvent
)
fn inject_dial_upgrade_error(
&mut self,
<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo,
ProtocolsHandlerUpgrErr<<<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::Substream>>::Error>
)
[src]
&mut self,
<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo,
ProtocolsHandlerUpgrErr<<<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::Substream>>::Error>
)
fn connection_keep_alive(&self) -> KeepAlive
[src]
fn poll(
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol, <IdentifyListenHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo, <IdentifyListenHandler<TSubstream> as ProtocolsHandler>::OutEvent>>, <IdentifyListenHandler<TSubstream> as ProtocolsHandler>::Error>
[src]
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<IdentifyListenHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol, <IdentifyListenHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo, <IdentifyListenHandler<TSubstream> as ProtocolsHandler>::OutEvent>>, <IdentifyListenHandler<TSubstream> as ProtocolsHandler>::Error>
impl<TSubstream> ProtocolsHandler for PeriodicIdHandler<TSubstream> where
TSubstream: AsyncRead + AsyncWrite,
[src]
TSubstream: AsyncRead + AsyncWrite,
type InEvent = Void
type OutEvent = PeriodicIdHandlerEvent
type Error = Error
type Substream = TSubstream
type InboundProtocol = DeniedUpgrade
type OutboundProtocol = IdentifyProtocolConfig
type OutboundOpenInfo = ()
fn listen_protocol(
&self
) -> SubstreamProtocol<<PeriodicIdHandler<TSubstream> as ProtocolsHandler>::InboundProtocol>
[src]
&self
) -> SubstreamProtocol<<PeriodicIdHandler<TSubstream> as ProtocolsHandler>::InboundProtocol>
fn inject_fully_negotiated_inbound(&mut self, protocol: Void)
[src]
fn inject_fully_negotiated_outbound(
&mut self,
protocol: <<PeriodicIdHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<TSubstream>>::Output,
_info: <PeriodicIdHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo
)
[src]
&mut self,
protocol: <<PeriodicIdHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<TSubstream>>::Output,
_info: <PeriodicIdHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo
)
fn inject_event(
&mut self,
<PeriodicIdHandler<TSubstream> as ProtocolsHandler>::InEvent
)
[src]
&mut self,
<PeriodicIdHandler<TSubstream> as ProtocolsHandler>::InEvent
)
fn inject_dial_upgrade_error(
&mut self,
<PeriodicIdHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo,
err: ProtocolsHandlerUpgrErr<<<PeriodicIdHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<PeriodicIdHandler<TSubstream> as ProtocolsHandler>::Substream>>::Error>
)
[src]
&mut self,
<PeriodicIdHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo,
err: ProtocolsHandlerUpgrErr<<<PeriodicIdHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<PeriodicIdHandler<TSubstream> as ProtocolsHandler>::Substream>>::Error>
)
fn connection_keep_alive(&self) -> KeepAlive
[src]
fn poll(
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<PeriodicIdHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol, <PeriodicIdHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo, PeriodicIdHandlerEvent>>, <PeriodicIdHandler<TSubstream> as ProtocolsHandler>::Error>
[src]
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<PeriodicIdHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol, <PeriodicIdHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo, PeriodicIdHandlerEvent>>, <PeriodicIdHandler<TSubstream> as ProtocolsHandler>::Error>
impl<TSubstream> ProtocolsHandler for PingHandler<TSubstream> where
TSubstream: AsyncRead + AsyncWrite,
[src]
TSubstream: AsyncRead + AsyncWrite,
type InEvent = Void
type OutEvent = Result<PingSuccess, PingFailure>
type Error = PingFailure
type Substream = TSubstream
type InboundProtocol = Ping
type OutboundProtocol = Ping
type OutboundOpenInfo = ()
fn listen_protocol(&self) -> SubstreamProtocol<Ping>
[src]
fn inject_fully_negotiated_inbound(&mut self, ())
[src]
fn inject_fully_negotiated_outbound(&mut self, rtt: Duration, _info: ())
[src]
fn inject_event(&mut self, Void)
[src]
fn inject_dial_upgrade_error(
&mut self,
_info: (),
error: ProtocolsHandlerUpgrErr<Error>
)
[src]
&mut self,
_info: (),
error: ProtocolsHandlerUpgrErr<Error>
)
fn connection_keep_alive(&self) -> KeepAlive
[src]
fn poll(
&mut self
) -> Result<Async<ProtocolsHandlerEvent<Ping, (), Result<PingSuccess, PingFailure>>>, <PingHandler<TSubstream> as ProtocolsHandler>::Error>
[src]
&mut self
) -> Result<Async<ProtocolsHandlerEvent<Ping, (), Result<PingSuccess, PingFailure>>>, <PingHandler<TSubstream> as ProtocolsHandler>::Error>
impl<TSubstream> ProtocolsHandler for DummyProtocolsHandler<TSubstream> where
TSubstream: AsyncRead + AsyncWrite,
[src]
TSubstream: AsyncRead + AsyncWrite,
type InEvent = Void
type OutEvent = Void
type Error = Void
type Substream = TSubstream
type InboundProtocol = DeniedUpgrade
type OutboundProtocol = DeniedUpgrade
type OutboundOpenInfo = Void
fn listen_protocol(
&self
) -> SubstreamProtocol<<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::InboundProtocol>
[src]
&self
) -> SubstreamProtocol<<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::InboundProtocol>
fn inject_fully_negotiated_inbound(
&mut self,
<<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<TSubstream>>::Output
)
[src]
&mut self,
<<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<TSubstream>>::Output
)
fn inject_fully_negotiated_outbound(
&mut self,
<<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<TSubstream>>::Output,
<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo
)
[src]
&mut self,
<<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<TSubstream>>::Output,
<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo
)
fn inject_event(
&mut self,
<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::InEvent
)
[src]
&mut self,
<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::InEvent
)
fn inject_dial_upgrade_error(
&mut self,
<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo,
ProtocolsHandlerUpgrErr<<<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::Substream>>::Error>
)
[src]
&mut self,
<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo,
ProtocolsHandlerUpgrErr<<<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::Substream>>::Error>
)
fn connection_keep_alive(&self) -> KeepAlive
[src]
fn poll(
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol, <DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo, <DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::OutEvent>>, Void>
[src]
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::OutboundProtocol, <DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::OutboundOpenInfo, <DummyProtocolsHandler<TSubstream> as ProtocolsHandler>::OutEvent>>, Void>
impl<TSubstream, TInProto, TOutProto, TOutEvent> ProtocolsHandler for OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> where
TInProto: InboundUpgrade<TSubstream>,
TOutProto: OutboundUpgrade<TSubstream>,
TSubstream: AsyncRead + AsyncWrite,
<TInProto as InboundUpgrade<TSubstream>>::Output: Into<TOutEvent>,
<TOutProto as OutboundUpgrade<TSubstream>>::Output: Into<TOutEvent>,
<TOutProto as OutboundUpgrade<TSubstream>>::Error: Error,
<TOutProto as OutboundUpgrade<TSubstream>>::Error: 'static,
SubstreamProtocol<TInProto>: Clone,
[src]
TInProto: InboundUpgrade<TSubstream>,
TOutProto: OutboundUpgrade<TSubstream>,
TSubstream: AsyncRead + AsyncWrite,
<TInProto as InboundUpgrade<TSubstream>>::Output: Into<TOutEvent>,
<TOutProto as OutboundUpgrade<TSubstream>>::Output: Into<TOutEvent>,
<TOutProto as OutboundUpgrade<TSubstream>>::Error: Error,
<TOutProto as OutboundUpgrade<TSubstream>>::Error: 'static,
SubstreamProtocol<TInProto>: Clone,
type InEvent = TOutProto
type OutEvent = TOutEvent
type Error = ProtocolsHandlerUpgrErr<<<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::Substream>>::Error>
type Substream = TSubstream
type InboundProtocol = TInProto
type OutboundProtocol = TOutProto
type OutboundOpenInfo = ()
fn listen_protocol(
&self
) -> SubstreamProtocol<<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::InboundProtocol>
[src]
&self
) -> SubstreamProtocol<<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::InboundProtocol>
fn inject_fully_negotiated_inbound(
&mut self,
out: <<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::Substream>>::Output
)
[src]
&mut self,
out: <<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::Substream>>::Output
)
fn inject_fully_negotiated_outbound(
&mut self,
out: <<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::Substream>>::Output,
<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutboundOpenInfo
)
[src]
&mut self,
out: <<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::Substream>>::Output,
<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutboundOpenInfo
)
fn inject_event(
&mut self,
event: <OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::InEvent
)
[src]
&mut self,
event: <OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::InEvent
)
fn inject_dial_upgrade_error(
&mut self,
<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutboundOpenInfo,
error: ProtocolsHandlerUpgrErr<<<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::Substream>>::Error>
)
[src]
&mut self,
<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutboundOpenInfo,
error: ProtocolsHandlerUpgrErr<<<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::Substream>>::Error>
)
fn connection_keep_alive(&self) -> KeepAlive
[src]
fn poll(
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutboundProtocol, <OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutboundOpenInfo, <OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutEvent>>, <OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::Error>
[src]
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutboundProtocol, <OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutboundOpenInfo, <OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::OutEvent>>, <OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent> as ProtocolsHandler>::Error>
impl<TSubstream, TProto1, TProto2> ProtocolsHandler for ProtocolsHandlerSelect<TProto1, TProto2> where
TProto1: ProtocolsHandler<Substream = TSubstream>,
TProto2: ProtocolsHandler<Substream = TSubstream>,
TSubstream: AsyncRead + AsyncWrite,
<TProto1 as ProtocolsHandler>::InboundProtocol: InboundUpgrade<TSubstream>,
<TProto2 as ProtocolsHandler>::InboundProtocol: InboundUpgrade<TSubstream>,
<TProto1 as ProtocolsHandler>::OutboundProtocol: OutboundUpgrade<TSubstream>,
<TProto2 as ProtocolsHandler>::OutboundProtocol: OutboundUpgrade<TSubstream>,
[src]
TProto1: ProtocolsHandler<Substream = TSubstream>,
TProto2: ProtocolsHandler<Substream = TSubstream>,
TSubstream: AsyncRead + AsyncWrite,
<TProto1 as ProtocolsHandler>::InboundProtocol: InboundUpgrade<TSubstream>,
<TProto2 as ProtocolsHandler>::InboundProtocol: InboundUpgrade<TSubstream>,
<TProto1 as ProtocolsHandler>::OutboundProtocol: OutboundUpgrade<TSubstream>,
<TProto2 as ProtocolsHandler>::OutboundProtocol: OutboundUpgrade<TSubstream>,
type InEvent = EitherOutput<<TProto1 as ProtocolsHandler>::InEvent, <TProto2 as ProtocolsHandler>::InEvent>
type OutEvent = EitherOutput<<TProto1 as ProtocolsHandler>::OutEvent, <TProto2 as ProtocolsHandler>::OutEvent>
type Error = EitherError<<TProto1 as ProtocolsHandler>::Error, <TProto2 as ProtocolsHandler>::Error>
type Substream = TSubstream
type InboundProtocol = SelectUpgrade<<TProto1 as ProtocolsHandler>::InboundProtocol, <TProto2 as ProtocolsHandler>::InboundProtocol>
type OutboundProtocol = EitherUpgrade<<TProto1 as ProtocolsHandler>::OutboundProtocol, <TProto2 as ProtocolsHandler>::OutboundProtocol>
type OutboundOpenInfo = EitherOutput<<TProto1 as ProtocolsHandler>::OutboundOpenInfo, <TProto2 as ProtocolsHandler>::OutboundOpenInfo>
fn listen_protocol(
&self
) -> SubstreamProtocol<<ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::InboundProtocol>
[src]
&self
) -> SubstreamProtocol<<ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::InboundProtocol>
fn inject_fully_negotiated_outbound(
&mut self,
protocol: <<ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<TSubstream>>::Output,
endpoint: <ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::OutboundOpenInfo
)
[src]
&mut self,
protocol: <<ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<TSubstream>>::Output,
endpoint: <ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::OutboundOpenInfo
)
fn inject_fully_negotiated_inbound(
&mut self,
protocol: <<ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<TSubstream>>::Output
)
[src]
&mut self,
protocol: <<ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<TSubstream>>::Output
)
fn inject_event(
&mut self,
event: <ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::InEvent
)
[src]
&mut self,
event: <ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::InEvent
)
fn inject_dial_upgrade_error(
&mut self,
info: <ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::OutboundOpenInfo,
error: ProtocolsHandlerUpgrErr<<<ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::Substream>>::Error>
)
[src]
&mut self,
info: <ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::OutboundOpenInfo,
error: ProtocolsHandlerUpgrErr<<<ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<<ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::Substream>>::Error>
)
fn connection_keep_alive(&self) -> KeepAlive
[src]
fn poll(
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::OutboundProtocol, <ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::OutboundOpenInfo, <ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::OutEvent>>, <ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::Error>
[src]
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::OutboundProtocol, <ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::OutboundOpenInfo, <ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::OutEvent>>, <ProtocolsHandlerSelect<TProto1, TProto2> as ProtocolsHandler>::Error>
impl<TSubstream, TUserData> ProtocolsHandler for KademliaHandler<TSubstream, TUserData> where
TSubstream: AsyncRead + AsyncWrite,
TUserData: Clone,
[src]
TSubstream: AsyncRead + AsyncWrite,
TUserData: Clone,
type InEvent = KademliaHandlerIn<TUserData>
type OutEvent = KademliaHandlerEvent<TUserData>
type Error = Error
type Substream = TSubstream
type InboundProtocol = EitherUpgrade<KademliaProtocolConfig, DeniedUpgrade>
type OutboundProtocol = KademliaProtocolConfig
type OutboundOpenInfo = (KadRequestMsg, Option<TUserData>)
fn listen_protocol(
&self
) -> SubstreamProtocol<<KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::InboundProtocol>
[src]
&self
) -> SubstreamProtocol<<KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::InboundProtocol>
fn inject_fully_negotiated_outbound(
&mut self,
protocol: <<KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<TSubstream>>::Output,
<KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::OutboundOpenInfo
)
[src]
&mut self,
protocol: <<KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<TSubstream>>::Output,
<KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::OutboundOpenInfo
)
fn inject_fully_negotiated_inbound(
&mut self,
protocol: <<KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<TSubstream>>::Output
)
[src]
&mut self,
protocol: <<KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::InboundProtocol as InboundUpgrade<TSubstream>>::Output
)
fn inject_event(&mut self, message: KademliaHandlerIn<TUserData>)
[src]
fn inject_dial_upgrade_error(
&mut self,
<KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::OutboundOpenInfo,
error: ProtocolsHandlerUpgrErr<Error>
)
[src]
&mut self,
<KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::OutboundOpenInfo,
error: ProtocolsHandlerUpgrErr<Error>
)
fn connection_keep_alive(&self) -> KeepAlive
[src]
fn poll(
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::OutboundProtocol, <KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::OutboundOpenInfo, <KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::OutEvent>>, Error>
[src]
&mut self
) -> Result<Async<ProtocolsHandlerEvent<<KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::OutboundProtocol, <KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::OutboundOpenInfo, <KademliaHandler<TSubstream, TUserData> as ProtocolsHandler>::OutEvent>>, Error>