1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde;
pub mod connection;
pub mod requests;
pub mod ws_protocol;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("Network error: {0}")]
Network(#[from] reqwest::Error),
#[error("Websocket error: {0}")]
WebSocket(#[from] async_tungstenite::tungstenite::Error),
#[error("Unexpected status code: {0}")]
StatusCode(reqwest::StatusCode),
#[error("Failed to parse http body as expected json.")]
Serde(#[from] serde_json::Error),
#[error("Bilibili error: ({}) {}", .code, .message)]
BiliCustom { code: i64, message: String },
#[error("The request seems ok but no data is found.")]
DataNotFound,
#[error("Failed to parse as bilibili protocol: {0}")]
Protocol(#[from] ws_protocol::ParseError),
}
pub type Result<T, E = Error> = std::result::Result<T, E>;
pub use requests::Request;