rocketmq_remoting/protocol/admin/
topic_offset.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 */
17
18use serde::Deserialize;
19use serde::Serialize;
20
21#[derive(Debug, Clone, Serialize, Deserialize, Default)]
22#[serde(rename_all = "camelCase")]
23pub struct TopicOffset {
24    min_offset: i64,
25    max_offset: i64,
26    last_update_timestamp: i64,
27}
28
29impl TopicOffset {
30    pub fn new() -> Self {
31        Self {
32            min_offset: 0,
33            max_offset: 0,
34            last_update_timestamp: 0,
35        }
36    }
37
38    pub fn get_min_offset(&self) -> i64 {
39        self.min_offset
40    }
41
42    pub fn set_min_offset(&mut self, min_offset: i64) {
43        self.min_offset = min_offset;
44    }
45
46    pub fn get_max_offset(&self) -> i64 {
47        self.max_offset
48    }
49
50    pub fn set_max_offset(&mut self, max_offset: i64) {
51        self.max_offset = max_offset;
52    }
53
54    pub fn get_last_update_timestamp(&self) -> i64 {
55        self.last_update_timestamp
56    }
57
58    pub fn set_last_update_timestamp(&mut self, last_update_timestamp: i64) {
59        self.last_update_timestamp = last_update_timestamp;
60    }
61}
62
63impl std::fmt::Display for TopicOffset {
64    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
65        write!(
66            f,
67            "TopicOffset{{min_offset={}, max_offset={}, last_update_timestamp={}}}",
68            self.min_offset, self.max_offset, self.last_update_timestamp
69        )
70    }
71}