use iroh::EndpointId;
pub type Result<T, E = NetworkError> = std::result::Result<T, E>;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum NetworkError {
#[error("invalid configuration: {0}")]
InvalidConfig(String),
#[error("identity error: {0}")]
Identity(String),
#[error("invalid ticket: {0}")]
InvalidTicket(String),
#[error("network id mismatch")]
NetworkMismatch,
#[error("schema id mismatch")]
SchemaMismatch,
#[error("unsupported protocol version")]
UnsupportedProtocolVersion,
#[error("handshake rejected as invalid by remote peer")]
HandshakeRejected,
#[error("peer is not connected: {0}")]
PeerNotConnected(EndpointId),
#[error("message exceeds maximum size")]
MessageTooLarge,
#[error("request timed out")]
Timeout,
#[error("serialization error: {0}")]
Serialization(String),
#[error("transport error: {0}")]
Transport(String),
#[error("message rejected by peer: {0}")]
MessageRejected(String),
#[error("unknown stream protocol: {0}")]
UnknownStreamProtocol(String),
#[error("stream acceptor already taken: {0}")]
StreamAcceptorTaken(String),
#[error("engine is shutting down")]
ShuttingDown,
}