rocketmq_remoting/protocol/admin/
offset_wrapper.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)]
22pub struct OffsetWrapper {
23    broker_offset: i64,
24    consumer_offset: i64,
25    pull_offset: i64,
26    last_timestamp: i64,
27}
28
29impl OffsetWrapper {
30    pub fn new() -> Self {
31        Self {
32            broker_offset: 0,
33            consumer_offset: 0,
34            pull_offset: 0,
35            last_timestamp: 0,
36        }
37    }
38
39    pub fn get_broker_offset(&self) -> i64 {
40        self.broker_offset
41    }
42
43    pub fn set_broker_offset(&mut self, broker_offset: i64) {
44        self.broker_offset = broker_offset;
45    }
46
47    pub fn get_consumer_offset(&self) -> i64 {
48        self.consumer_offset
49    }
50
51    pub fn set_consumer_offset(&mut self, consumer_offset: i64) {
52        self.consumer_offset = consumer_offset;
53    }
54
55    pub fn get_pull_offset(&self) -> i64 {
56        self.pull_offset
57    }
58
59    pub fn set_pull_offset(&mut self, pull_offset: i64) {
60        self.pull_offset = pull_offset;
61    }
62
63    pub fn get_last_timestamp(&self) -> i64 {
64        self.last_timestamp
65    }
66
67    pub fn set_last_timestamp(&mut self, last_timestamp: i64) {
68        self.last_timestamp = last_timestamp;
69    }
70}