openethereum/util/src/network/error.rs

48 lines
788 B
Rust
Raw Normal View History

2016-01-15 16:36:08 +01:00
use io::IoError;
use rlp::*;
#[derive(Debug, Copy, Clone)]
pub enum DisconnectReason
{
DisconnectRequested,
2016-02-02 14:54:46 +01:00
_TCPError,
_BadProtocol,
2016-01-15 16:36:08 +01:00
UselessPeer,
2016-02-02 14:54:46 +01:00
_TooManyPeers,
_DuplicatePeer,
_IncompatibleProtocol,
_NullIdentity,
_ClientQuit,
_UnexpectedIdentity,
_LocalIdentity,
2016-02-02 20:58:12 +01:00
PingTimeout,
2016-01-15 16:36:08 +01:00
}
#[derive(Debug)]
/// Network error.
2016-01-15 16:36:08 +01:00
pub enum NetworkError {
/// Authentication error.
2016-01-15 16:36:08 +01:00
Auth,
/// Unrecognised protocol.
2016-01-15 16:36:08 +01:00
BadProtocol,
/// Peer not found.
2016-01-15 16:36:08 +01:00
PeerNotFound,
/// Peer is diconnected.
2016-01-15 16:36:08 +01:00
Disconnect(DisconnectReason),
/// Socket IO error.
2016-01-15 16:36:08 +01:00
Io(IoError),
}
impl From<DecoderError> for NetworkError {
fn from(_err: DecoderError) -> NetworkError {
NetworkError::Auth
}
}
impl From<IoError> for NetworkError {
fn from(err: IoError) -> NetworkError {
NetworkError::Io(err)
}
}