use action::Action;
use std::sync::mpsc::RecvError;
use maidsafe_utilities::event_sender::{MaidSafeEventCategory, EventSenderError};
#[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)
}
}
#[allow(variant_size_differences)]
#[derive(Debug)]
pub enum RoutingError {
NotBootstrapped,
Terminated,
BadAuthority,
AlreadyConnected,
UnknownMessageType,
FailedSignature,
NotEnoughSignatures,
DuplicateSignatures,
FilterCheckFailed,
FailedToBootstrap,
RoutingTableEmpty,
RejectedPublicId,
RefusedFromRoutingTable,
RefreshNotFromGroup,
Utf8(::std::str::Utf8Error),
Interface(InterfaceError),
Io(::std::io::Error),
Cbor(::cbor::CborError),
InvalidStateForOperation,
SerialisationError(::maidsafe_utilities::serialisation::SerialisationError),
AsymmetricDecryptionFailure,
UnknownConnection,
DirectionCheckFailed,
RoutingTableBucketIndexFailed,
InvalidDestination,
ProxyConnectionNotFound,
ClientConnectionNotFound,
InvalidSource,
}
impl From<::std::str::Utf8Error> for RoutingError {
fn from(error: ::std::str::Utf8Error) -> RoutingError {
RoutingError::Utf8(error)
}
}
impl From<::cbor::CborError> for RoutingError {
fn from(error: ::cbor::CborError) -> RoutingError {
RoutingError::Cbor(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<::maidsafe_utilities::serialisation::SerialisationError> for RoutingError {
fn from(error: ::maidsafe_utilities::serialisation::SerialisationError) -> RoutingError {
RoutingError::SerialisationError(error)
}
}