Trait libp2p::core::connection::ConnectionHandler [−][src]
The interface of a connection handler.
Each handler is responsible for a single connection.
Associated Types
type InEvent
[src]
The inbound type of events used to notify the handler through the Network
.
See also EstablishedConnection::notify_handler
and ConnectionHandler::inject_event
.
type OutEvent
[src]
The outbound type of events that the handler emits to the Network
through ConnectionHandler::poll
.
See also NetworkEvent::ConnectionEvent
.
type Error
[src]
The type of errors that the handler can produce when polled by the Network
.
type Substream
[src]
The type of the substream containing the data.
type OutboundOpenInfo
[src]
Information about a substream. Can be sent to the handler through a SubstreamEndpoint
,
and will be passed back in inject_substream
or inject_outbound_closed
.
Required methods
pub fn inject_substream(
&mut self,
substream: Self::Substream,
endpoint: SubstreamEndpoint<Self::OutboundOpenInfo>
)
[src]
&mut self,
substream: Self::Substream,
endpoint: SubstreamEndpoint<Self::OutboundOpenInfo>
)
Sends a new substream to the handler.
The handler is responsible for upgrading the substream to whatever protocol it wants.
Panic
Implementations are allowed to panic in the case of dialing if the user_data
in
endpoint
doesn’t correspond to what was returned earlier when polling, or is used
multiple times.
pub fn inject_event(&mut self, event: Self::InEvent)
[src]
Notifies the handler of an event.
pub fn inject_address_change(&mut self, new_address: &Multiaddr)
[src]
Notifies the handler of a change in the address of the remote.
pub fn poll(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<ConnectionHandlerEvent<Self::OutboundOpenInfo, Self::OutEvent>, Self::Error>>
[src]
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<ConnectionHandlerEvent<Self::OutboundOpenInfo, Self::OutEvent>, Self::Error>>
Polls the handler for events.
Returning an error will close the connection to the remote.
Implementors
impl<TProtoHandler> ConnectionHandler for NodeHandlerWrapper<TProtoHandler> where
TProtoHandler: ProtocolsHandler,
[src]
TProtoHandler: ProtocolsHandler,
type InEvent = <TProtoHandler as ProtocolsHandler>::InEvent
type OutEvent = <TProtoHandler as ProtocolsHandler>::OutEvent
type Error = NodeHandlerWrapperError<<TProtoHandler as ProtocolsHandler>::Error>
type Substream = SubstreamRef<Arc<StreamMuxerBox>>
type OutboundOpenInfo = (u64, <TProtoHandler as ProtocolsHandler>::OutboundOpenInfo, Duration)
pub fn inject_substream(
&mut self,
substream: <NodeHandlerWrapper<TProtoHandler> as ConnectionHandler>::Substream,
endpoint: SubstreamEndpoint<<NodeHandlerWrapper<TProtoHandler> as ConnectionHandler>::OutboundOpenInfo>
)
[src]
&mut self,
substream: <NodeHandlerWrapper<TProtoHandler> as ConnectionHandler>::Substream,
endpoint: SubstreamEndpoint<<NodeHandlerWrapper<TProtoHandler> as ConnectionHandler>::OutboundOpenInfo>
)
pub fn inject_event(
&mut self,
event: <NodeHandlerWrapper<TProtoHandler> as ConnectionHandler>::InEvent
)
[src]
&mut self,
event: <NodeHandlerWrapper<TProtoHandler> as ConnectionHandler>::InEvent
)
pub fn inject_address_change(&mut self, new_address: &Multiaddr)
[src]
pub fn poll(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<ConnectionHandlerEvent<<NodeHandlerWrapper<TProtoHandler> as ConnectionHandler>::OutboundOpenInfo, <NodeHandlerWrapper<TProtoHandler> as ConnectionHandler>::OutEvent>, <NodeHandlerWrapper<TProtoHandler> as ConnectionHandler>::Error>>
[src]
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<ConnectionHandlerEvent<<NodeHandlerWrapper<TProtoHandler> as ConnectionHandler>::OutboundOpenInfo, <NodeHandlerWrapper<TProtoHandler> as ConnectionHandler>::OutEvent>, <NodeHandlerWrapper<TProtoHandler> as ConnectionHandler>::Error>>