zoe_client/client/
info.rs

1use std::net::SocketAddr;
2use zoe_app_primitives::RelayAddress;
3use zoe_wire_protocol::KeyId;
4
5/// Connection information for a relay server
6///
7/// Stores the full RelayAddress configuration so we can attempt reconnection
8/// to all available addresses, not just the last successful one.
9#[derive(Debug, Clone)]
10pub struct RelayInfo {
11    pub relay_id: KeyId,
12    pub relay_address: RelayAddress,
13}
14
15/// Connection status for a relay
16#[derive(Debug, Clone, PartialEq, Eq)]
17pub enum RelayConnectionStatus {
18    /// Not connected
19    Disconnected {
20        /// Optional connection error that caused the disconnection
21        error: Option<String>,
22    },
23    /// Currently connecting
24    Connecting,
25    /// Connected and operational to a specific address
26    Connected {
27        /// The specific address that the connection succeeded on
28        connected_address: SocketAddr,
29    },
30    /// Connection failed
31    Failed { error: String },
32}
33
34/// Represents a relay connection with its status
35#[derive(Debug, Clone)]
36pub struct RelayConnectionInfo {
37    pub info: RelayInfo,
38    pub status: RelayConnectionStatus,
39}
40
41// ClientSecret is used directly - no wrapper needed
42
43/// Per-relay connection status update
44#[derive(Debug, Clone, PartialEq, Eq)]
45pub struct RelayStatusUpdate {
46    /// The relay ID
47    pub relay_id: KeyId,
48    /// The relay address information
49    pub relay_address: RelayAddress,
50    /// Current connection status
51    pub status: RelayConnectionStatus,
52}
53
54/// Overall connection status for the client
55#[derive(Debug, Clone, PartialEq, Eq)]
56pub struct OverallConnectionStatus {
57    /// True if connected to at least one relay
58    pub is_connected: bool,
59    /// Number of connected relays
60    pub connected_count: usize,
61    /// Total number of configured relays
62    pub total_count: usize,
63}