use crate::packet::PacketError;
use std::{io, fmt};
use std::error::Error;
#[derive(Debug)]
#[non_exhaustive]
pub enum TaskError {
#[cfg(feature = "connection")]
Join(tokio::task::JoinError),
Io(io::Error),
Packet(PacketError),
UnknownId(u32),
ExistingId(u32),
WrongPacketKind(&'static str),
#[cfg(feature = "encrypted")]
#[cfg_attr(docsrs, doc(cfg(feature = "encrypted")))]
IncorrectSignature
}
impl fmt::Display for TaskError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self, f)
}
}
impl Error for TaskError {}
#[derive(Debug)]
#[non_exhaustive]
pub enum RequestError {
ConnectionAlreadyClosed,
TaskFailed,
NoResponse,
MalformedRequest,
ResponsePacket(PacketError)
}
impl fmt::Display for RequestError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self, f)
}
}
impl Error for RequestError {}
#[derive(Debug)]
#[non_exhaustive]
pub enum ResponseError {
ConnectionClosed
}
impl fmt::Display for ResponseError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self, f)
}
}
impl Error for ResponseError {}
#[derive(Debug)]
#[non_exhaustive]
pub enum StreamError {
StreamAlreadyClosed
}
impl fmt::Display for StreamError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self, f)
}
}
impl Error for StreamError {}