Enum libp2p_swarm::NetworkBehaviourAction [−][src]
pub enum NetworkBehaviourAction<TInEvent, TOutEvent> {
GenerateEvent(TOutEvent),
DialAddress {
address: Multiaddr,
},
DialPeer {
peer_id: PeerId,
condition: DialPeerCondition,
},
NotifyHandler {
peer_id: PeerId,
handler: NotifyHandler,
event: TInEvent,
},
ReportObservedAddr {
address: Multiaddr,
score: AddressScore,
},
}An action that a NetworkBehaviour can trigger in the Swarm
in whose context it is executing.
Variants
Instructs the Swarm to return an event when it is being polled.
Instructs the swarm to dial the given multiaddress, with no knowledge of the PeerId that
may be reached.
Show fields
Fields of DialAddress
address: MultiaddrThe address to dial.
Instructs the swarm to dial a known PeerId.
The addresses_of_peer method is called to determine which addresses to attempt to reach.
If we were already trying to dial this node, the addresses that are not yet in the queue of addresses to try are added back to this queue.
On success, NetworkBehaviour::inject_connected is invoked.
On failure, NetworkBehaviour::inject_dial_failure is invoked.
Show fields
Fields of DialPeer
peer_id: PeerIdThe peer to try reach.
condition: DialPeerConditionThe condition for initiating a new dialing attempt.
Instructs the Swarm to send an event to the handler dedicated to a
connection with a peer.
If the Swarm is connected to the peer, the message is delivered to the
ProtocolsHandler instance identified by the peer ID and connection ID.
If the specified connection no longer exists, the event is silently dropped.
Typically the connection ID given is the same as the one passed to
NetworkBehaviour::inject_event, i.e. whenever the behaviour wishes to
respond to a request on the same connection (and possibly the same
substream, as per the implementation of ProtocolsHandler).
Note that even if the peer is currently connected, connections can get closed at any time and thus the event may not reach a handler.
Show fields
Fields of NotifyHandler
peer_id: PeerIdThe peer for whom a ProtocolsHandler should be notified.
handler: NotifyHandlerThe options w.r.t. which connection handler to notify of the event.
event: TInEventThe event to send.
Informs the Swarm about an address observed by a remote for
the local node by which the local node is supposedly publicly
reachable.
It is advisable to issue ReportObservedAddr actions at a fixed frequency
per node. This way address information will be more accurate over time
and individual outliers carry less weight.
Show fields
Fields of ReportObservedAddr
address: MultiaddrThe observed address of the local node.
score: AddressScoreThe score to associate with this observation, i.e. an indicator for the trusworthiness of this address relative to other observed addresses.
Implementations
impl<TInEvent, TOutEvent> NetworkBehaviourAction<TInEvent, TOutEvent>[src]
impl<TInEvent, TOutEvent> NetworkBehaviourAction<TInEvent, TOutEvent>[src]pub fn map_in<E>(
self,
f: impl FnOnce(TInEvent) -> E
) -> NetworkBehaviourAction<E, TOutEvent>[src]
self,
f: impl FnOnce(TInEvent) -> E
) -> NetworkBehaviourAction<E, TOutEvent>
Map the handler event.
pub fn map_out<E>(
self,
f: impl FnOnce(TOutEvent) -> E
) -> NetworkBehaviourAction<TInEvent, E>[src]
self,
f: impl FnOnce(TOutEvent) -> E
) -> NetworkBehaviourAction<TInEvent, E>
Map the event the swarm will return.
Trait Implementations
Auto Trait Implementations
impl<TInEvent, TOutEvent> RefUnwindSafe for NetworkBehaviourAction<TInEvent, TOutEvent> where
TInEvent: RefUnwindSafe,
TOutEvent: RefUnwindSafe,
TInEvent: RefUnwindSafe,
TOutEvent: RefUnwindSafe,
impl<TInEvent, TOutEvent> Send for NetworkBehaviourAction<TInEvent, TOutEvent> where
TInEvent: Send,
TOutEvent: Send,
TInEvent: Send,
TOutEvent: Send,
impl<TInEvent, TOutEvent> Sync for NetworkBehaviourAction<TInEvent, TOutEvent> where
TInEvent: Sync,
TOutEvent: Sync,
TInEvent: Sync,
TOutEvent: Sync,
impl<TInEvent, TOutEvent> Unpin for NetworkBehaviourAction<TInEvent, TOutEvent> where
TInEvent: Unpin,
TOutEvent: Unpin,
TInEvent: Unpin,
TOutEvent: Unpin,
impl<TInEvent, TOutEvent> UnwindSafe for NetworkBehaviourAction<TInEvent, TOutEvent> where
TInEvent: UnwindSafe,
TOutEvent: UnwindSafe,
TInEvent: UnwindSafe,
TOutEvent: UnwindSafe,