Skip to main content

bpi_rs/err/
from.rs

1use super::error::BpiError;
2
3// 从reqwest错误转换
4impl From<reqwest::Error> for BpiError {
5    fn from(err: reqwest::Error) -> Self {
6        BpiError::Transport { source: err }
7    }
8}
9
10// 从API响应转换
11impl<T> From<crate::response::ApiEnvelope<T>> for BpiError {
12    fn from(resp: crate::response::ApiEnvelope<T>) -> Self {
13        BpiError::from_api_response(resp)
14    }
15}
16
17// 从JSON序列化错误转换
18impl From<serde_json::Error> for BpiError {
19    fn from(err: serde_json::Error) -> Self {
20        BpiError::Decode { source: err }
21    }
22}