Add ProtocolsHandler trait (#573)

* Add ProtocolsHandler trait

* Reexport symbols

* Add a note about shutting down

* Add map_protocol

* Add a NodeHandlerWrapperBuilder

* Update core/src/nodes/protocols_handler.rs

Co-Authored-By: tomaka <pierre.krieger1708@gmail.com>

* Fix compilation
This commit is contained in:
Pierre Krieger
2018-11-01 11:06:32 +01:00
committed by GitHub
parent 4627f21180
commit c730b4b3c9
5 changed files with 697 additions and 2 deletions

View File

@ -41,6 +41,12 @@ pub trait NodeHandler {
/// 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.
fn inject_substream(&mut self, substream: Self::Substream, endpoint: NodeHandlerEndpoint<Self::OutboundOpenInfo>);
/// Indicates to the handler that the inbound part of the muxer has been closed, and that
@ -49,6 +55,11 @@ pub trait NodeHandler {
/// Indicates to the handler that an outbound substream failed to open because the outbound
/// part of the muxer has been closed.
///
/// # Panic
///
/// Implementations are allowed to panic if `user_data` doesn't correspond to what was returned
/// earlier when polling, or is used multiple times.
fn inject_outbound_closed(&mut self, user_data: Self::OutboundOpenInfo);
/// Injects an event coming from the outside into the handler.