Skip to main content

p2panda_net/discovery/
events.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3use std::time::Duration;
4
5use p2panda_discovery::DiscoveryResult;
6
7use crate::NodeId;
8use crate::addrs::NodeInfo;
9
10/// Discovery "system" events other processes can subscribe to.
11#[derive(Clone, Debug, PartialEq, Eq)]
12#[allow(clippy::enum_variant_names)]
13#[allow(clippy::large_enum_variant)]
14pub enum DiscoveryEvent {
15    SessionStarted {
16        role: SessionRole,
17        remote_node_id: NodeId,
18    },
19    SessionEnded {
20        role: SessionRole,
21        remote_node_id: NodeId,
22        result: DiscoveryResult<NodeId, NodeInfo>,
23        duration: Duration,
24    },
25    SessionFailed {
26        role: SessionRole,
27        remote_node_id: NodeId,
28        duration: Duration,
29        reason: String,
30    },
31}
32
33#[derive(Clone, Debug, PartialEq, Eq)]
34pub enum SessionRole {
35    Initiated,
36    Accepted,
37}