1use reqwest::StatusCode;
2use serde_json::Value;
3use tokio_tungstenite::tungstenite;
4
5pub type ClientResult<T> = Result<T, ClientError>;
7
8#[derive(thiserror::Error, Debug)]
10pub enum ClientError {
11 #[error(transparent)]
13 UrlParse(#[from] url::ParseError),
14
15 #[error(transparent)]
17 Reqwest(#[from] reqwest::Error),
18
19 #[error(transparent)]
21 Tungstenite(#[from] tungstenite::Error),
22
23 #[error(transparent)]
25 SerdeJson(#[from] serde_json::Error),
26
27 #[error("set websocket scheme failed")]
29 SetWsScheme,
30
31 #[error(transparent)]
33 Api(#[from] ApiError),
34}
35
36#[derive(thiserror::Error, Debug)]
38#[error("api error")]
39pub struct ApiError {
40 pub status: StatusCode,
42 pub body: ApiBody,
44}
45
46#[derive(Debug)]
48pub enum ApiBody {
49 Json(Value),
51 Text(String),
53}