1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum NetworkError {
8 #[error("I/O error: {0}")]
10 Io(#[from] std::io::Error),
11
12 #[error("Transport error: {0}")]
14 Transport(String),
15
16 #[error("Connection error: {0}")]
18 Connection(String),
19
20 #[error("Peer not found: {0}")]
22 PeerNotFound(String),
23
24 #[error("Invalid message: {0}")]
26 InvalidMessage(String),
27
28 #[error("Serialization error: {0}")]
30 Serialization(#[from] bincode::Error),
31
32 #[error("Failed to publish to topic: {0}")]
34 PublishError(String),
35
36 #[error("Subscription error: {0}")]
38 SubscriptionError(String),
39
40 #[error("DHT error: {0}")]
42 DhtError(String),
43
44 #[error("Peer is banned: {0}")]
46 PeerBanned(String),
47
48 #[error("Maximum peers reached")]
50 MaxPeersReached,
51
52 #[error("Invalid configuration: {0}")]
54 InvalidConfig(String),
55
56 #[error("Channel send error")]
58 ChannelSend,
59
60 #[error("Channel receive error")]
62 ChannelReceive,
63
64 #[error("Service not started")]
66 ServiceNotStarted,
67
68 #[error("Service already running")]
70 ServiceAlreadyRunning,
71
72 #[error("Operation timed out")]
74 Timeout,
75
76 #[error("Protocol not supported: {0}")]
78 ProtocolNotSupported(String),
79}
80
81pub type Result<T> = std::result::Result<T, NetworkError>;