|
@@ -1,3 +1,5 @@
|
|
|
|
|
+use std::time::Instant;
|
|
|
|
|
+
|
|
|
/**交易所返回数据处理之后,同意保存格式,为了内部其他接口调用*/
|
|
/**交易所返回数据处理之后,同意保存格式,为了内部其他接口调用*/
|
|
|
#[derive(Debug, Clone)]
|
|
#[derive(Debug, Clone)]
|
|
|
pub struct ResponseData {
|
|
pub struct ResponseData {
|
|
@@ -6,14 +8,25 @@ pub struct ResponseData {
|
|
|
pub message: String,
|
|
pub message: String,
|
|
|
pub channel: String,
|
|
pub channel: String,
|
|
|
pub data: String,
|
|
pub data: String,
|
|
|
- pub time: i64, //数据接受的时间
|
|
|
|
|
- pub reach_time: i64, //远程数据时间 弃用
|
|
|
|
|
- pub data_type: String // 數據類型, 例如 bybit 深度信息:snapshot(全量),delta(增量)
|
|
|
|
|
|
|
+ pub res_time: Instant, // 数据接收的ins
|
|
|
|
|
+ pub time: i64, // 数据接受的时间
|
|
|
|
|
+ pub reach_time: i64, // 远程数据时间 弃用
|
|
|
|
|
+ pub data_type: String // 數據類型, 例如 bybit 深度信息:snapshot(全量),delta(增量)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
impl ResponseData {
|
|
impl ResponseData {
|
|
|
pub fn new(label: String, code: String, message: String, data: String) -> ResponseData {
|
|
pub fn new(label: String, code: String, message: String, data: String) -> ResponseData {
|
|
|
- ResponseData { label, code, message, data, channel: "".to_string(), time: 0, reach_time: 0 , data_type: String::new()}
|
|
|
|
|
|
|
+ ResponseData {
|
|
|
|
|
+ label,
|
|
|
|
|
+ code,
|
|
|
|
|
+ message,
|
|
|
|
|
+ data,
|
|
|
|
|
+ channel: "".to_string(),
|
|
|
|
|
+ time: 0,
|
|
|
|
|
+ reach_time: 0,
|
|
|
|
|
+ data_type: String::new(),
|
|
|
|
|
+ res_time: Instant::now(),
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
pub fn error(label: String, message: String) -> ResponseData {
|
|
pub fn error(label: String, message: String) -> ResponseData {
|
|
|
ResponseData {
|
|
ResponseData {
|
|
@@ -24,7 +37,8 @@ impl ResponseData {
|
|
|
channel: "".to_string(),
|
|
channel: "".to_string(),
|
|
|
time: 0,
|
|
time: 0,
|
|
|
reach_time: 0,
|
|
reach_time: 0,
|
|
|
- data_type: String::new()
|
|
|
|
|
|
|
+ data_type: String::new(),
|
|
|
|
|
+ res_time: Instant::now(),
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|