rocketmq_protocol/protocol/remoting_command/
flags.rs1use super::RemotingCommand;
16use super::RemotingCommandType;
17use super::SerializeType;
18
19impl RemotingCommand {
20 pub(crate) const RPC_ONEWAY: i32 = 1;
21 pub(crate) const RPC_TYPE: i32 = 0;
22
23 #[inline]
24 pub fn set_flag(mut self, flag: i32) -> Self {
25 self.flag = flag;
26 self
27 }
28
29 #[inline]
30 pub fn mark_response_type(mut self) -> Self {
31 let mark = 1 << Self::RPC_TYPE;
32 self.flag |= mark;
33 self
34 }
35
36 #[inline]
37 pub fn mark_response_type_ref(&mut self) {
38 let mark = 1 << Self::RPC_TYPE;
39 self.flag |= mark;
40 }
41
42 #[inline]
43 pub fn mark_oneway_rpc(mut self) -> Self {
44 let mark = 1 << Self::RPC_ONEWAY;
45 self.flag |= mark;
46 self
47 }
48
49 #[inline]
50 pub fn mark_oneway_rpc_ref(&mut self) {
51 let mark = 1 << Self::RPC_ONEWAY;
52 self.flag |= mark;
53 }
54
55 #[inline]
56 pub fn get_serialize_type(&self) -> SerializeType {
57 self.serialize_type
58 }
59
60 #[inline]
61 pub fn flag(&self) -> i32 {
62 self.flag
63 }
64
65 #[inline]
66 pub fn is_response_type(&self) -> bool {
67 let bits = 1 << Self::RPC_TYPE;
68 (self.flag & bits) == bits
69 }
70
71 #[inline]
72 pub fn is_oneway_rpc(&self) -> bool {
73 let bits = 1 << Self::RPC_ONEWAY;
74 (self.flag & bits) == bits
75 }
76
77 pub fn get_type(&self) -> RemotingCommandType {
78 if self.is_response_type() {
79 RemotingCommandType::RESPONSE
80 } else {
81 RemotingCommandType::REQUEST
82 }
83 }
84}