1use crate::error_event::ErrorEventData;
2use thiserror::Error;
3use tokio::sync::oneshot;
4
5pub type Result<T> = std::result::Result<T, Error>;
6
7#[derive(Error, Debug)]
8pub enum Error {
9 #[error(transparent)]
10 IoError(#[from] tokio::io::Error),
11
12 #[error(transparent)]
13 Decode(#[from] rmp_serde::decode::Error),
14
15 #[error(transparent)]
16 Encode(#[from] rmp_serde::encode::Error),
17
18 #[error("Build Error: {0}")]
19 BuildError(String),
20
21 #[error("{0}")]
22 Message(String),
23
24 #[error("Channel Error: {0}")]
25 ReceiveError(#[from] oneshot::error::RecvError),
26
27 #[error("Send Error")]
28 SendError,
29
30 #[error("Error response: {0}")]
31 ErrorEvent(#[from] ErrorEventData),
32}
33
34impl From<String> for Error {
35 fn from(s: String) -> Self {
36 Error::Message(s)
37 }
38}
39
40impl From<&str> for Error {
41 fn from(s: &str) -> Self {
42 Error::Message(s.to_string())
43 }
44}