use thiserror::Error;
#[derive(Error, Debug)]
pub enum NetworkError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Transport error: {0}")]
Transport(String),
#[error("Connection error: {0}")]
Connection(String),
#[error("Peer not found: {0}")]
PeerNotFound(String),
#[error("Invalid message: {0}")]
InvalidMessage(String),
#[error("Serialization error: {0}")]
Serialization(#[from] bincode::Error),
#[error("Failed to publish to topic: {0}")]
PublishError(String),
#[error("Subscription error: {0}")]
SubscriptionError(String),
#[error("DHT error: {0}")]
DhtError(String),
#[error("Peer is banned: {0}")]
PeerBanned(String),
#[error("Maximum peers reached")]
MaxPeersReached,
#[error("Invalid configuration: {0}")]
InvalidConfig(String),
#[error("Channel send error")]
ChannelSend,
#[error("Channel receive error")]
ChannelReceive,
#[error("Service not started")]
ServiceNotStarted,
#[error("Service already running")]
ServiceAlreadyRunning,
#[error("Operation timed out")]
Timeout,
#[error("Protocol not supported: {0}")]
ProtocolNotSupported(String),
}
pub type Result<T> = std::result::Result<T, NetworkError>;