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