rustydht_lib/dht/dht_event.rs
1use crate::packets::Message;
2
3/// Top-level message that [DHT](crate::dht::DHT) will send to callers that
4/// [subscribe](crate::dht::DHT::subscribe) to events.
5#[derive(Debug, PartialEq, Clone)]
6pub struct DHTEvent {
7 pub event_type: DHTEventType,
8}
9
10/// Enum that represents the different types of events that can be sent from the DHT.
11#[derive(Debug, PartialEq, Clone)]
12pub enum DHTEventType {
13 MessageReceived(MessageReceivedEvent),
14}
15
16/// This struct is used when [DHT](crate::dht::DHT) receives a message from another
17/// node on the DHT.
18///
19/// The event is sent after the DHT has finished all other processing for the message.
20#[derive(Debug, PartialEq, Clone)]
21pub struct MessageReceivedEvent {
22 pub message: Message,
23}