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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#[cfg(not(any(feature = "rustls", feature = "native-tls")))]
compile_error!("至少应该启用一个 rustls 或是 native-tls features");
#[cfg(all(feature = "rustls", feature = "native-tls"))]
compile_error!("rustls 和 native-tls features 只能同时启用一个");
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde;
pub mod connection;
pub mod requests;
#[cfg(feature = "live")]
pub mod ws_protocol;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("Network error: {0}")]
Network(#[from] reqwest::Error),
#[cfg(feature = "live")]
#[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,
#[cfg(feature = "live")]
#[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;