Weave documentation
Rust referenceweave-swarm

weave-swarm · swarm

Source declarations, signatures and documentation for swarm.

Source: sigil/weave/network/weave-swarm/src/swarm.rs. SHA-256: 07671d99fc19ebfae40a62d38e9deff13e5e9322695a48ca9ceee1bc28900f2c.

This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.

swarm::Swarm

Distributed networking swarm

pub struct Swarm {

}

Source line: 33.

swarm::Swarm::export_metrics_text

Export Prometheus metrics text

pub fn export_metrics_text(&self, namespace: &str) -> String;

Source line: 74.

swarm::Swarm::new

Create a new swarm

pub async fn new(config: SwarmConfig) -> Result<Self>;

Source line: 79.

swarm::Swarm::events

Get event receiver

pub fn events(&self) -> broadcast::Receiver<SwarmEvent>;

Source line: 124.

swarm::Swarm::local_peer_id

Get local peer ID

pub fn local_peer_id(&self) -> PeerId;

Source line: 129.

swarm::Swarm::connection_count

Get number of active connections

pub fn connection_count(&self) -> usize;

Source line: 137.

swarm::Swarm::topic_count

Get number of joined topics

pub fn topic_count(&self) -> usize;

Source line: 142.

swarm::Swarm::connections

Get a map of the current connections

pub fn connections(&self) -> Arc<DashMap<PeerId, Connection>>;

Source line: 147.

swarm::Swarm::send_to_peer

Send a data payload to a connected peer.

pub async fn send_to_peer(&self, peer_id: &PeerId, data: &[u8]) -> Result<()>;

Source line: 152.

swarm::Swarm::broadcast

Broadcast a data payload to all currently connected peers.

pub async fn broadcast(&self, data: &[u8]) -> Result<usize>;

Source line: 164.

swarm::Swarm::join

Join a topic (start finding peers)

pub async fn join(&self, topic: TopicId, opts: JoinOptions) -> Result<()>;

Source line: 178.

swarm::Swarm::leave

Leave a topic (stop finding peers)

pub async fn leave(&self, topic: &TopicId) -> Result<()>;

Source line: 217.

swarm::Swarm::connect

Connect to a specific peer

pub async fn connect(&self, peer_info: PeerInfo) -> Result<Connection>;

Source line: 248.

swarm::Swarm::disconnect

Disconnect from a peer

pub async fn disconnect(&self, peer_id: &PeerId) -> Result<()>;

Source line: 361.

swarm::Swarm::shutdown

Shutdown the swarm

pub async fn shutdown(&self) -> Result<()>;

Source line: 886.

On this page