shoal_core/client/errors.rs
1//! The errors that can be returned from the Shoal client.
2
3/// The errors that can be returned from the Shoal client
4#[derive(Debug)]
5pub enum Errors {
6 /// Attempt to cast a shoal response to the wrong type
7 WrongType(String),
8 /// An IO error occured
9 IO(std::io::Error),
10 /// An rkyv error
11 Rkyv(rkyv::rancor::Error),
12 /// An error sending data to a kanal channel
13 KanalSend(kanal::SendError),
14 /// An error receiving data from a kanal channel
15 KanalReceive(kanal::ReceiveError),
16 /// A stream has already ended
17 StreamAlreadyTerminated,
18}
19
20impl From<std::io::Error> for Errors {
21 /// Convert this error to our error type
22 ///
23 /// # Arguments
24 ///
25 /// * `error` - The error to convert
26 fn from(error: std::io::Error) -> Self {
27 Errors::IO(error)
28 }
29}
30
31impl From<rkyv::rancor::Error> for Errors {
32 /// Convert this error to our error type
33 ///
34 /// # Arguments
35 ///
36 /// * `error` - The error to convert
37 fn from(error: rkyv::rancor::Error) -> Self {
38 Errors::Rkyv(error)
39 }
40}
41
42impl From<kanal::SendError> for Errors {
43 /// Convert this error to our error type
44 ///
45 /// # Arguments
46 ///
47 /// * `error` - The error to convert
48 fn from(error: kanal::SendError) -> Self {
49 Errors::KanalSend(error)
50 }
51}
52
53impl From<kanal::ReceiveError> for Errors {
54 /// Convert this error to our error type
55 ///
56 /// # Arguments
57 ///
58 /// * `error` - The error to convert
59 fn from(error: kanal::ReceiveError) -> Self {
60 Errors::KanalReceive(error)
61 }
62}