1use thiserror::Error;
2
3#[derive(Debug, Error)]
5pub enum FutuError {
6 #[error("网络错误: {0}")]
7 Network(#[from] std::io::Error),
8
9 #[error("协议解析错误: {0}")]
10 Codec(String),
11
12 #[error("Protobuf 解码失败: {0}")]
13 Proto(#[from] prost::DecodeError),
14
15 #[error("服务端返回错误, ret_type={ret_type}, msg={msg}")]
16 ServerError { ret_type: i32, msg: String },
17
18 #[error("连接超时")]
19 Timeout,
20
21 #[error("未初始化")]
22 NotInitialized,
23
24 #[error("加密错误: {0}")]
25 Encryption(String),
26
27 #[error("SHA1 校验失败")]
28 Sha1Mismatch,
29
30 #[error("无效的协议帧头")]
31 InvalidHeader,
32}
33
34pub type Result<T> = std::result::Result<T, FutuError>;