rocketmq_protocol/protocol/remoting_command/
legacy_api.rs1use bytes::Bytes;
16use bytes::BytesMut;
17
18use super::RemotingCommand;
19use crate::protocol::command_custom_header::CommandCustomHeader;
20
21impl RemotingCommand {
22 #[deprecated(
29 note = "use create_success_response_command for SUCCESS or create_java_default_error_response_command for Java-compatible unset errors"
30 )]
31 pub fn create_response_command() -> Self {
32 Self::create_success_response_command()
33 }
34
35 #[deprecated(
41 note = "use create_success_response_command_with_header for SUCCESS or create_java_default_error_response_command_with_header for Java-compatible unset errors"
42 )]
43 pub fn create_response_command_with_header(header: impl CommandCustomHeader + Sync + Send + 'static) -> Self {
44 Self::create_success_response_command_with_header(header)
45 }
46
47 #[inline]
49 pub fn make_custom_header_to_net(&mut self) {
50 let _ = self.try_make_custom_header_to_net();
51 }
52
53 #[inline]
54 pub fn materialize_custom_header_to_ext_fields(&mut self) {
55 let _ = self.try_make_custom_header_to_net();
56 }
57
58 #[deprecated(
59 since = "1.0.0",
60 note = "use try_read_custom_header_ref; this compatibility alias is fallible despite its historical unchecked name"
61 )]
62 pub fn read_custom_header_ref_unchecked<T>(&self) -> rocketmq_error::Result<&T>
63 where
64 T: CommandCustomHeader + Sync + Send + 'static,
65 {
66 self.try_read_custom_header_ref::<T>()
67 }
68
69 #[deprecated(note = "use read_custom_header_mut; shared-reference mutation is no longer supported")]
74 pub fn read_custom_header_mut_from_ref<T>(&mut self) -> Option<&mut T>
75 where
76 T: CommandCustomHeader + Sync + Send + 'static,
77 {
78 self.try_read_custom_header_mut::<T>().ok()
79 }
80
81 #[deprecated(
82 since = "1.0.0",
83 note = "use try_read_custom_header_mut; this compatibility alias is fallible despite its historical unchecked name"
84 )]
85 pub fn read_custom_header_mut_unchecked<T>(&mut self) -> rocketmq_error::Result<&mut T>
86 where
87 T: CommandCustomHeader + Sync + Send + 'static,
88 {
89 self.try_read_custom_header_mut::<T>()
90 }
91
92 pub fn read_custom_header_ref<T>(&self) -> Option<&T>
93 where
94 T: CommandCustomHeader + Sync + Send + 'static,
95 {
96 self.try_read_custom_header_ref::<T>().ok()
97 }
98
99 pub fn read_custom_header_mut<T>(&mut self) -> Option<&mut T>
100 where
101 T: CommandCustomHeader + Sync + Send + 'static,
102 {
103 self.try_read_custom_header_mut::<T>().ok()
104 }
105
106 #[inline]
108 pub fn header_encode(&mut self) -> Option<Bytes> {
109 self.try_header_encode().ok()
110 }
111
112 #[inline]
113 pub fn fast_header_encode(&mut self, dst: &mut BytesMut) {
114 let _ = self.try_fast_header_encode(dst);
115 }
116
117 #[inline]
119 pub fn encode_header(&mut self) -> Option<Bytes> {
120 let body_length = self.body.as_ref().map_or(0, |b| b.len());
121 self.try_encode_header_with_body_length(body_length).ok()
122 }
123
124 #[inline]
126 pub fn encode_header_with_body_length(&mut self, body_length: usize) -> Option<Bytes> {
127 self.try_encode_header_with_body_length(body_length).ok()
128 }
129}