rocketmq_client_v4/protocols/header/
get_max_offset_request_header.rs

1use serde::Serialize;
2use crate::protocols::mq_command::MqCommand;
3use crate::protocols::{request_code, SerializeDeserialize};
4
5#[derive(Debug, Serialize)]
6#[allow(non_snake_case)]
7pub struct GetMaxOffsetRequestHeader {
8    pub topic: String,
9    pub queueId: i32,
10}
11
12impl GetMaxOffsetRequestHeader {
13    pub fn new(topic: String, queue_id: i32) -> Self {
14        Self {
15            topic,
16            queueId: queue_id,
17        }
18    }
19
20    pub fn convert_from_cmd(cmd: &MqCommand) -> Self {
21        let header = cmd.e_body.clone();
22        let map = Self::bytes_1_to_map(header);
23        Self {
24            topic: map.get("topic").unwrap().to_string(),
25            queueId: map.get("queueId").unwrap().parse().unwrap(),
26        }
27    }
28    pub fn to_cmd(&self) -> MqCommand {
29
30        let header = self.to_bytes_1();
31        let cmd = MqCommand::new_with_body(request_code::GET_MAX_OFFSET, vec![], header, vec![]);
32        cmd
33    }
34}
35
36impl SerializeDeserialize for  GetMaxOffsetRequestHeader {
37
38}