use action::Action;
use crust::{self, PeerId};
use event::Event;
use std::sync::mpsc::{RecvError, SendError};
use maidsafe_utilities::event_sender::{EventSenderError, MaidSafeEventCategory};
use maidsafe_utilities::serialisation;
#[derive(Debug)]
pub enum InterfaceError {
NotConnected,
InvalidState,
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,
RejectedClientMessage,
Utf8(::std::str::Utf8Error),
Interface(InterfaceError),
Io(::std::io::Error),
Crust(crust::CrustError),
SendEventError(SendError<Event>),
InvalidStateForOperation,
SerialisationError(serialisation::SerialisationError),
AsymmetricDecryptionFailure,
UnknownConnection(PeerId),
DirectionCheckFailed,
RoutingTableBucketIndexFailed,
InvalidDestination,
ProxyConnectionNotFound,
ClientConnectionNotFound,
InvalidSource,
CannotTunnelThroughTunnel,
HashMismatch,
}
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<crust::CrustError> for RoutingError {
fn from(error: crust::CrustError) -> RoutingError {
RoutingError::Crust(error)
}
}
impl From<SendError<Event>> for RoutingError {
fn from(error: SendError<Event>) -> RoutingError {
RoutingError::SendEventError(error)
}
}
impl From<serialisation::SerialisationError> for RoutingError {
fn from(error: serialisation::SerialisationError) -> RoutingError {
RoutingError::SerialisationError(error)
}
}