Rust referenceweave-swarm
weave-swarm · events
Source declarations, signatures and documentation for events.
Source: sigil/weave/network/weave-swarm/src/events.rs. SHA-256: a7970b4eadc0d4db5e1c63d9959f666c981e713ceb705a6a36303cd138418851.
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.
events::SwarmEvent
Swarm events
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SwarmEvent {
/// New peer connection established
Connection { peer_id: PeerId },
/// Peer disconnected
Disconnection {
peer_id: PeerId,
reason: DisconnectReason,
},
/// Joined a topic
TopicJoined { topic: TopicId },
/// Left a topic
TopicLeft { topic: TopicId },
/// Error occurred
Error {
peer_id: Option<PeerId>,
error: String,
},
/// Received data from peer
Data {
peer_id: PeerId,
topic: TopicId,
data: Vec<u8>,
},
/// Peer joined topic
PeerJoined { peer_id: PeerId, topic: TopicId },
/// Peer left topic
PeerLeft { peer_id: PeerId, topic: TopicId },
/// Received raw message from peer (un--namespaced)
RawMessage { peer_id: PeerId, data: Vec<u8> },
}Source line: 8.
events::DisconnectReason
Reasons for disconnection
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum DisconnectReason {
/// Local node initiated disconnect
LocalClose,
/// Remote peer closed connection
RemoteClose,
/// Connection error
Error,
/// Connection timeout
Timeout,
/// Protocol violation
ProtocolViolation,
/// No shared topics
NoSharedTopics,
/// Duplicate connection
Duplicate,
/// Verification failed
VerificationFailed,
}Source line: 49.