rocketmq_remoting/protocol/subscription/simple_subscription_data.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 serde::Deserialize;
18use serde::Serialize;
19
20#[derive(Debug, Clone, Default, Serialize, Deserialize, Hash, Eq, PartialEq)]
21#[serde(rename_all = "camelCase")]
22pub struct SimpleSubscriptionData {
23 topic: String,
24 expression_type: String,
25 expression: String,
26 version: u64,
27}
28
29impl SimpleSubscriptionData {
30 pub fn new(topic: String, expression_type: String, expression: String, version: u64) -> Self {
31 SimpleSubscriptionData {
32 topic,
33 expression_type,
34 expression,
35 version,
36 }
37 }
38
39 pub fn topic(&self) -> &str {
40 &self.topic
41 }
42
43 pub fn expression_type(&self) -> &str {
44 &self.expression_type
45 }
46
47 pub fn expression(&self) -> &str {
48 &self.expression
49 }
50
51 pub fn version(&self) -> u64 {
52 self.version
53 }
54}