rocketmq_client_rust/base/
query_result.rs

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