1use crate::packet::PacketError;
2
3use std::{io, fmt};
4use std::error::Error;
5
6
7#[derive(Debug)]
8#[non_exhaustive]
9pub enum TaskError {
10 #[cfg(feature = "connection")]
11 Join(tokio::task::JoinError),
12 Io(io::Error),
13 Packet(PacketError),
15 UnknownId(u32),
18 ExistingId(u32),
19 WrongPacketKind(&'static str),
20 #[cfg(feature = "encrypted")]
22 #[cfg_attr(docsrs, doc(cfg(feature = "encrypted")))]
23 IncorrectSignature
24}
25
26impl fmt::Display for TaskError {
27 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28 fmt::Debug::fmt(self, f)
29 }
30}
31
32impl Error for TaskError {}
33
34
35#[derive(Debug)]
36#[non_exhaustive]
37pub enum RequestError {
38 ConnectionAlreadyClosed,
42 TaskFailed,
45 NoResponse,
48 MalformedRequest,
50 ResponsePacket(PacketError)
52}
53
54impl fmt::Display for RequestError {
55 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
56 fmt::Debug::fmt(self, f)
57 }
58}
59
60impl Error for RequestError {}
61
62
63#[derive(Debug)]
64#[non_exhaustive]
65pub enum ResponseError {
66 ConnectionClosed
67}
68
69impl fmt::Display for ResponseError {
70 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
71 fmt::Debug::fmt(self, f)
72 }
73}
74
75impl Error for ResponseError {}
76
77
78#[derive(Debug)]
80#[non_exhaustive]
81pub enum StreamError {
82 StreamAlreadyClosed
83}
84
85impl fmt::Display for StreamError {
86 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
87 fmt::Debug::fmt(self, f)
88 }
89}
90
91impl Error for StreamError {}