aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.rs
blob: df7295d36a49f56bf050a8832e6fb560f6db6c11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//! Event types for typed callback integration.
//!
//! Alternative to `Box<dyn Fn>` callbacks. Applications
//! can receive events via `std::sync::mpsc::Receiver`.

use crate::id::NodeId;
use crate::rdp::{RdpAddr, RdpEvent};

/// Events emitted by a Node.
#[derive(Debug, Clone)]
pub enum NodeEvent {
    /// Datagram received from a peer.
    DgramReceived { data: Vec<u8>, from: NodeId },

    /// RDP event on a connection.
    Rdp {
        desc: i32,
        addr: RdpAddr,
        event: RdpEvent,
    },

    /// Peer added to routing table.
    PeerAdded(NodeId),

    /// Value stored via DHT STORE.
    ValueStored { key: Vec<u8> },

    /// Node shutdown initiated.
    Shutdown,
}