futu_backend/
qot_right_push.rs1use futu_core::error::{FutuError, Result};
4use prost::Message;
5
6use crate::proto_internal::ftcmd6651_qta_auth_chg::QuoteChangeNotify;
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub struct QotRightChangedPushItem {
10 pub quote_type: Option<i32>,
11 pub before: Option<i32>,
12 pub after: Option<i32>,
13 pub client_type: Option<i32>,
14 pub ip_area: Option<i32>,
15}
16
17#[derive(Debug, Clone, PartialEq, Eq)]
18pub struct QotRightChangedPush {
19 pub changes: Vec<QotRightChangedPushItem>,
20}
21
22pub fn decode_qot_right_changed_push(body: &[u8]) -> Result<QotRightChangedPush> {
23 let message = QuoteChangeNotify::decode(body)
24 .map_err(|error| FutuError::Codec(format!("CMD6651 decode: {error}")))?;
25 let changes = message
26 .quote_change_list
27 .into_iter()
28 .map(|item| QotRightChangedPushItem {
29 quote_type: item.quote_type,
30 before: item.quote_before_change,
31 after: item.quote_after_change,
32 client_type: item.clt_type,
33 ip_area: item.ip_area,
34 })
35 .collect();
36 Ok(QotRightChangedPush { changes })
37}
38
39#[cfg(test)]
40#[path = "qot_right_push_tests.rs"]
41mod qot_right_push_tests;