[][src]Trait libp2p::core::nodes::handled_node::NodeHandler

pub trait NodeHandler {
    type InEvent;
    type OutEvent;
    type Error;
    type Substream;
    type OutboundOpenInfo;
    fn inject_substream(
        &mut self,
        substream: Self::Substream,
        endpoint: NodeHandlerEndpoint<Self::OutboundOpenInfo>
    );
fn inject_event(&mut self, event: Self::InEvent);
fn poll(
        &mut self,
        cx: &mut Context
    ) -> Poll<Result<NodeHandlerEvent<Self::OutboundOpenInfo, Self::OutEvent>, Self::Error>>; }

Handler for the substreams of a node.

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 by the Network.

type Error

Error that can happen during the processing of the node.

type Substream

The type of the substream containing the data.

type OutboundOpenInfo

Information about a substream. Can be sent to the handler through a NodeHandlerEndpoint, and will be passed back in inject_substream or inject_outbound_closed.

Loading content...

Required methods

fn inject_substream(
    &mut self,
    substream: Self::Substream,
    endpoint: NodeHandlerEndpoint<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.

fn inject_event(&mut self, event: Self::InEvent)

Injects an event coming from the outside into the handler.

fn poll(
    &mut self,
    cx: &mut Context
) -> Poll<Result<NodeHandlerEvent<Self::OutboundOpenInfo, Self::OutEvent>, Self::Error>>

Should behave like Stream::poll().

Returning an error will close the connection to the remote.

Loading content...

Implementors

impl<TProtoHandler> NodeHandler for NodeHandlerWrapper<TProtoHandler> where
    TProtoHandler: ProtocolsHandler
[src]

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)

Loading content...