futu_backend/
price_reminder_change_push.rs1use futu_core::error::{FutuError, Result};
4
5const PRICE_REMINDER_CHANGE_BODY_LEN: usize = 12;
6
7#[derive(Clone, Copy, Debug, Eq, PartialEq)]
8pub struct DecodedPriceReminderChangePush {
9 pub stock_id: i64,
10 pub server_seq: i32,
11}
12
13pub fn decode_price_reminder_change_push(body: &[u8]) -> Result<DecodedPriceReminderChangePush> {
19 if body.len() < PRICE_REMINDER_CHANGE_BODY_LEN {
20 return Err(FutuError::Codec(format!(
21 "CMD6803 PriceReminderChange body too short: expected at least {PRICE_REMINDER_CHANGE_BODY_LEN}, got {}",
22 body.len()
23 )));
24 }
25
26 let stock_id = i64::from_be_bytes([
27 body[0], body[1], body[2], body[3], body[4], body[5], body[6], body[7],
28 ]);
29 let server_seq = i32::from_be_bytes([body[8], body[9], body[10], body[11]]);
30 Ok(DecodedPriceReminderChangePush {
31 stock_id,
32 server_seq,
33 })
34}