use action::Action;
#[cfg(not(feature = "use-mock-crust"))]
use crust::PeerId;
#[cfg(feature = "use-mock-crust")]
use mock_crust::crust::PeerId;
use event::Event;
use std::sync::mpsc::{RecvError, SendError};
use maidsafe_utilities::event_sender::{EventSenderError, MaidSafeEventCategory};
#[derive(Debug)]
pub enum InterfaceError {
NotConnected,
ChannelRxError(RecvError),
EventSenderError(EventSenderError<MaidSafeEventCategory, Action>),
}
impl From<EventSenderError<MaidSafeEventCategory, Action>> for InterfaceError {
fn from(error: EventSenderError<MaidSafeEventCategory, Action>) -> InterfaceError {
InterfaceError::EventSenderError(error)
}
}
impl From<RecvError> for InterfaceError {
fn from(error: RecvError) -> InterfaceError {
InterfaceError::ChannelRxError(error)
}
}
#[derive(Debug)]
pub enum RoutingError {
NotBootstrapped,
Terminated,
BadAuthority,
AlreadyConnected,
UnknownMessageType,
FailedSignature,
NotEnoughSignatures,
DuplicateSignatures,
FilterCheckFailed,
FailedToBootstrap,
RoutingTableEmpty,
RejectedPublicId,
RefusedFromRoutingTable,
RejectedGetCloseGroup,
RejectedGetNetworkName,
Utf8(::std::str::Utf8Error),
Interface(InterfaceError),
Io(::std::io::Error),
SendEventError(SendError<Event>),
BitIndexOutOfBoundsError,
InvalidStateForOperation,
SerialisationError(::maidsafe_utilities::serialisation::SerialisationError),
AsymmetricDecryptionFailure,
UnknownConnection(PeerId),
DirectionCheckFailed,
RoutingTableBucketIndexFailed,
InvalidDestination,
ProxyConnectionNotFound,
ClientConnectionNotFound,
InvalidSource,
CannotTunnelThroughTunnel,
}
impl From<::std::str::Utf8Error> for RoutingError {
fn from(error: ::std::str::Utf8Error) -> RoutingError {
RoutingError::Utf8(error)
}
}
impl From<::std::io::Error> for RoutingError {
fn from(error: ::std::io::Error) -> RoutingError {
RoutingError::Io(error)
}
}
impl From<InterfaceError> for RoutingError {
fn from(error: InterfaceError) -> RoutingError {
RoutingError::Interface(error)
}
}
impl From<SendError<Event>> for RoutingError {
fn from(error: SendError<Event>) -> RoutingError {
RoutingError::SendEventError(error)
}
}
impl From<::maidsafe_utilities::serialisation::SerialisationError> for RoutingError {
fn from(error: ::maidsafe_utilities::serialisation::SerialisationError) -> RoutingError {
RoutingError::SerialisationError(error)
}
}
impl From<::xor_name::BitIndexOutOfBoundsError> for RoutingError {
fn from(_: ::xor_name::BitIndexOutOfBoundsError) -> RoutingError {
RoutingError::BitIndexOutOfBoundsError
}
}