rocketmq_client_rust/base/query_result.rs
1// Copyright 2023 The RocketMQ Rust Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::fmt;
16
17use rocketmq_common::common::message::message_ext::MessageExt;
18
19#[derive(Debug, Clone, Default)]
20pub struct QueryResult {
21 index_last_update_timestamp: u64,
22 message_list: Vec<MessageExt>,
23}
24
25impl QueryResult {
26 // Constructor equivalent
27 #[inline]
28 pub fn new(index_last_update_timestamp: u64, message_list: Vec<MessageExt>) -> Self {
29 QueryResult {
30 index_last_update_timestamp,
31 message_list,
32 }
33 }
34
35 // Getter methods equivalent
36 #[inline]
37 pub fn index_last_update_timestamp(&self) -> u64 {
38 self.index_last_update_timestamp
39 }
40
41 #[inline]
42 pub fn message_list(&self) -> &Vec<MessageExt> {
43 &self.message_list
44 }
45}
46
47// Implementing the Display trait for pretty printing, similar to Java's toString method
48impl fmt::Display for QueryResult {
49 #[inline]
50 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
51 write!(
52 f,
53 "QueryResult [index_last_update_timestamp={}, message_list={:?}]",
54 self.index_last_update_timestamp, self.message_list
55 )
56 }
57}