snowstorm/net/
event.rs

1pub use libp2p::swarm::ConnectionError as LP2PConnectionError;
2use libp2p::Multiaddr;
3pub use libp2p::PeerId;
4
5#[derive(Debug, Clone)]
6pub enum ConnectionError {
7    IO,
8    KeepAliveTimeout,
9}
10
11#[derive(Debug, Clone)]
12pub enum Event {
13    Peering,
14    Discovered(PeerId),
15    ConnectionEstablished(PeerId),
16    ListenerConnectionEstablished(PeerId),
17    DialerConnectionEstablished(PeerId, bool),
18    ExitDiscovered(PeerId),
19    ConnectionClosed(PeerId, Option<ConnectionError>),
20    NewListenAddr(Multiaddr),
21    NewObservedAddr(Multiaddr),
22    IncapableOfVolunteering,
23    Stop,
24    NotificationReceived(i64),
25}
26
27
28impl From<LP2PConnectionError> for ConnectionError {
29    fn from(error: LP2PConnectionError) -> Self {
30        match error {
31            LP2PConnectionError::IO(_) => ConnectionError::IO,
32            LP2PConnectionError::KeepAliveTimeout => ConnectionError::KeepAliveTimeout,
33        }
34    }
35}