[][src]Module libp2p_core::swarm

High level manager of the network.

A Swarm contains the state of the network as a whole. The entire behaviour of a libp2p network can be controlled through the Swarm.

Initializing a Swarm

Creating a Swarm requires three things:

  1. A network identity of the local node in form of a PeerId.
  2. An implementation of the Transport trait. This is the type that will be used in order to reach nodes on the network based on their address. See the transport module for more information.
  3. An implementation of the [NetworkBehaviour] trait. This is a state machine that defines how the swarm should behave once it is connected to a node.

Network Behaviour

The NetworkBehaviour trait is implemented on types that indicate to the swarm how it should behave. This includes which protocols are supported and which nodes to try to connect to.

Re-exports

pub use crate::nodes::raw_swarm::ConnectedPoint;

Modules

toggle

Structs

ExpandedSwarm

Contains the state of the network, plus the way it should behave.

PollParameters

Parameters passed to poll(), that the NetworkBehaviour has access to.

SwarmBuilder

Enums

NetworkBehaviourAction

An action that a NetworkBehaviour can trigger in the [Swarm] in whose context it is executing.

Traits

NetworkBehaviour

A behaviour for the network. Allows customizing the swarm.

NetworkBehaviourEventProcess

Used when deriving NetworkBehaviour. When deriving NetworkBehaviour, must be implemented for all the possible event types generated by the various fields.

Type Definitions

Swarm

Contains the state of the network, plus the way it should behave.