[][src]Trait susyp2p::core::swarm::NetworkBehaviour

pub trait NetworkBehaviour {
type ProtocolsHandler: IntoProtocolsHandler;
type OutEvent;
    fn new_handler(&mut self) -> Self::ProtocolsHandler;
fn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec<Multiaddr>;
fn inject_connected(&mut self, peer_id: PeerId, endpoint: ConnectedPoint);
fn inject_disconnected(
        &mut self,
        peer_id: &PeerId,
        endpoint: ConnectedPoint
    );
fn inject_node_event(
        &mut self,
        peer_id: PeerId,
        event: <<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutEvent
    );
fn poll(
        &mut self,
        params: &mut PollParameters
    ) -> Async<NetworkBehaviourAction<<<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent, Self::OutEvent>>; fn inject_replaced(
        &mut self,
        peer_id: PeerId,
        closed_endpoint: ConnectedPoint,
        new_endpoint: ConnectedPoint
    ) { ... }
fn inject_addr_reach_failure(
        &mut self,
        _peer_id: Option<&PeerId>,
        _addr: &Multiaddr,
        _error: &dyn Error
    ) { ... }
fn inject_dial_failure(&mut self, _peer_id: &PeerId) { ... }
fn inject_new_listen_addr(&mut self, _addr: &Multiaddr) { ... }
fn inject_expired_listen_addr(&mut self, _addr: &Multiaddr) { ... }
fn inject_new_external_addr(&mut self, _addr: &Multiaddr) { ... } }

A behaviour for the network. Allows customizing the swarm.

This trait has been designed to be composable. Multiple implementations can be combined into one that handles all the behaviours at once.

Associated Types

type ProtocolsHandler: IntoProtocolsHandler

Handler for all the protocols the network supports.

type OutEvent

Event generated by the swarm.

Loading content...

Required methods

fn new_handler(&mut self) -> Self::ProtocolsHandler

Creates a new ProtocolsHandler for a connection with a peer.

fn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec<Multiaddr>

Addresses that this behaviour is aware of for this specific peer, and that may allow reaching the peer.

fn inject_connected(&mut self, peer_id: PeerId, endpoint: ConnectedPoint)

Indicates the behaviour that we connected to the node with the given peer id through the given endpoint.

fn inject_disconnected(&mut self, peer_id: &PeerId, endpoint: ConnectedPoint)

Indicates the behaviour that we disconnected from the node with the given peer id. The endpoint is the one we used to be connected to.

fn inject_node_event(
    &mut self,
    peer_id: PeerId,
    event: <<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutEvent
)

Indicates the behaviour that the node with the given peer id has generated an event for us.

Note: This method is only called for events generated by the protocols handler.

fn poll(
    &mut self,
    params: &mut PollParameters
) -> Async<NetworkBehaviourAction<<<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent, Self::OutEvent>>

Polls for things that swarm should do.

This API mimics the API of the Stream trait.

Loading content...

Provided methods

fn inject_replaced(
    &mut self,
    peer_id: PeerId,
    closed_endpoint: ConnectedPoint,
    new_endpoint: ConnectedPoint
)

Indicates the behaviour that we replace the connection from the node with another.

fn inject_addr_reach_failure(
    &mut self,
    _peer_id: Option<&PeerId>,
    _addr: &Multiaddr,
    _error: &dyn Error
)

Indicates to the behaviour that we tried to reach an address, but failed.

If we were trying to reach a specific node, its ID is passed as parameter. If this is the last address to attempt for the given node, then inject_dial_failure is called afterwards.

fn inject_dial_failure(&mut self, _peer_id: &PeerId)

Indicates to the behaviour that we tried to dial all the addresses known for a node, but failed.

fn inject_new_listen_addr(&mut self, _addr: &Multiaddr)

Indicates to the behaviour that we have started listening on a new multiaddr.

fn inject_expired_listen_addr(&mut self, _addr: &Multiaddr)

Indicates to the behaviour that a new multiaddr we were listening on has expired, which means that we are no longer listening in it.

fn inject_new_external_addr(&mut self, _addr: &Multiaddr)

Indicates to the behaviour that we have discovered a new external address for us.

Loading content...

Implementors

impl<TBehaviour> NetworkBehaviour for Toggle<TBehaviour> where
    TBehaviour: NetworkBehaviour
[src]

type ProtocolsHandler = ToggleIntoProtoHandler<<TBehaviour as NetworkBehaviour>::ProtocolsHandler>

type OutEvent = <TBehaviour as NetworkBehaviour>::OutEvent

impl<TSubstream> NetworkBehaviour for Floodsub<TSubstream> where
    TSubstream: AsyncRead + AsyncWrite
[src]

type ProtocolsHandler = OneShotHandler<TSubstream, FloodsubConfig, FloodsubRpc, InnerMessage>

type OutEvent = FloodsubEvent

fn inject_replaced(
    &mut self,
    peer_id: PeerId,
    closed_endpoint: ConnectedPoint,
    new_endpoint: ConnectedPoint
)
[src]

fn inject_addr_reach_failure(
    &mut self,
    _peer_id: Option<&PeerId>,
    _addr: &Multiaddr,
    _error: &dyn Error
)
[src]

fn inject_dial_failure(&mut self, _peer_id: &PeerId)[src]

fn inject_new_listen_addr(&mut self, _addr: &Multiaddr)[src]

fn inject_expired_listen_addr(&mut self, _addr: &Multiaddr)[src]

fn inject_new_external_addr(&mut self, _addr: &Multiaddr)[src]

impl<TSubstream> NetworkBehaviour for Identify<TSubstream> where
    TSubstream: AsyncRead + AsyncWrite
[src]

type ProtocolsHandler = ProtocolsHandlerSelect<IdentifyListenHandler<TSubstream>, PeriodicIdHandler<TSubstream>>

type OutEvent = IdentifyEvent

fn inject_replaced(
    &mut self,
    peer_id: PeerId,
    closed_endpoint: ConnectedPoint,
    new_endpoint: ConnectedPoint
)
[src]

fn inject_addr_reach_failure(
    &mut self,
    _peer_id: Option<&PeerId>,
    _addr: &Multiaddr,
    _error: &dyn Error
)
[src]

fn inject_dial_failure(&mut self, _peer_id: &PeerId)[src]

fn inject_new_listen_addr(&mut self, _addr: &Multiaddr)[src]

fn inject_expired_listen_addr(&mut self, _addr: &Multiaddr)[src]

fn inject_new_external_addr(&mut self, _addr: &Multiaddr)[src]

impl<TSubstream> NetworkBehaviour for Kademlia<TSubstream> where
    TSubstream: AsyncRead + AsyncWrite
[src]

type ProtocolsHandler = KademliaHandler<TSubstream, QueryId>

type OutEvent = KademliaOut

fn inject_new_listen_addr(&mut self, _addr: &Multiaddr)[src]

fn inject_expired_listen_addr(&mut self, _addr: &Multiaddr)[src]

fn inject_new_external_addr(&mut self, _addr: &Multiaddr)[src]

impl<TSubstream> NetworkBehaviour for Mdns<TSubstream> where
    TSubstream: AsyncRead + AsyncWrite
[src]

type ProtocolsHandler = DummyProtocolsHandler<TSubstream>

type OutEvent = MdnsEvent

fn inject_replaced(
    &mut self,
    peer_id: PeerId,
    closed_endpoint: ConnectedPoint,
    new_endpoint: ConnectedPoint
)
[src]

fn inject_addr_reach_failure(
    &mut self,
    _peer_id: Option<&PeerId>,
    _addr: &Multiaddr,
    _error: &dyn Error
)
[src]

fn inject_dial_failure(&mut self, _peer_id: &PeerId)[src]

fn inject_new_listen_addr(&mut self, _addr: &Multiaddr)[src]

fn inject_expired_listen_addr(&mut self, _addr: &Multiaddr)[src]

fn inject_new_external_addr(&mut self, _addr: &Multiaddr)[src]

impl<TSubstream> NetworkBehaviour for Ping<TSubstream> where
    TSubstream: AsyncRead + AsyncWrite
[src]

type ProtocolsHandler = PingHandler<TSubstream>

type OutEvent = PingEvent

fn inject_replaced(
    &mut self,
    peer_id: PeerId,
    closed_endpoint: ConnectedPoint,
    new_endpoint: ConnectedPoint
)
[src]

fn inject_addr_reach_failure(
    &mut self,
    _peer_id: Option<&PeerId>,
    _addr: &Multiaddr,
    _error: &dyn Error
)
[src]

fn inject_dial_failure(&mut self, _peer_id: &PeerId)[src]

fn inject_new_listen_addr(&mut self, _addr: &Multiaddr)[src]

fn inject_expired_listen_addr(&mut self, _addr: &Multiaddr)[src]

fn inject_new_external_addr(&mut self, _addr: &Multiaddr)[src]

Loading content...