@@ -13,10 +13,10 @@ pub fn bufferfish_impl_encodable(input: proc_macro::TokenStream) -> proc_macro::
1313 let ast = parse_macro_input ! ( input as DeriveInput ) ;
1414 let name = & ast. ident ;
1515
16- let packet_id = get_packet_id ( & ast) ;
17- let packet_id_snippet = {
18- if let Some ( packet_id ) = packet_id {
19- quote ! { bf. write_u16( u16 :: from( #packet_id ) ) ?; }
16+ let message_id = get_message_id ( & ast) ;
17+ let message_id_snippet = {
18+ if let Some ( message_id ) = message_id {
19+ quote ! { bf. write_u16( u16 :: from( #message_id ) ) ?; }
2020 } else {
2121 quote ! { }
2222 }
@@ -69,7 +69,7 @@ pub fn bufferfish_impl_encodable(input: proc_macro::TokenStream) -> proc_macro::
6969
7070 fn encode( & self , bf: & mut bufferfish:: Bufferfish ) -> Result <( ) , bufferfish:: BufferfishError >
7171 {
72- #packet_id_snippet
72+ #message_id_snippet
7373 self . encode_value( bf)
7474 }
7575 }
@@ -84,14 +84,14 @@ pub fn bufferfish_impl_decodable(input: proc_macro::TokenStream) -> proc_macro::
8484 let ast = parse_macro_input ! ( input as DeriveInput ) ;
8585 let name = & ast. ident ;
8686
87- let packet_id = get_packet_id ( & ast) ;
88- let has_packet_id = packet_id . is_some ( ) ;
89- let packet_id_snippet = {
90- if let Some ( packet_id ) = packet_id {
87+ let message_id = get_message_id ( & ast) ;
88+ let has_message_id = message_id . is_some ( ) ;
89+ let message_id_snippet = {
90+ if let Some ( message_id ) = message_id {
9191 quote ! {
92- let packet_id = bf. read_u16( ) ?;
93- if packet_id != u16 :: from( #packet_id ) {
94- return Err ( bufferfish:: BufferfishError :: InvalidPacketId ) ;
92+ let message_id = bf. read_u16( ) ?;
93+ if message_id != u16 :: from( #message_id ) {
94+ return Err ( bufferfish:: BufferfishError :: InvalidmessageId ) ;
9595 }
9696 }
9797 } else {
@@ -217,7 +217,7 @@ pub fn bufferfish_impl_decodable(input: proc_macro::TokenStream) -> proc_macro::
217217 quote ! {
218218 impl bufferfish:: Decodable for #name {
219219 fn decode( bf: & mut bufferfish:: Bufferfish ) -> Result <Self , bufferfish:: BufferfishError > {
220- #packet_id_snippet
220+ #message_id_snippet
221221 Self :: decode_value( bf)
222222 }
223223
@@ -228,15 +228,15 @@ pub fn bufferfish_impl_decodable(input: proc_macro::TokenStream) -> proc_macro::
228228 }
229229
230230 fn min_bytes_required( ) -> Option <usize > {
231- let packet_id_size = if #has_packet_id { 2 } else { 0 } ;
232- let mut min_size = packet_id_size ;
231+ let message_id_size = if #has_message_id { 2 } else { 0 } ;
232+ let mut min_size = message_id_size ;
233233 #( #min_size_snippets) *
234234 Some ( min_size)
235235 }
236236
237237 fn max_bytes_allowed( ) -> Option <usize > {
238- let packet_id_size = if #has_packet_id { 2 } else { 0 } ;
239- let mut max_size = packet_id_size ;
238+ let message_id_size = if #has_message_id { 2 } else { 0 } ;
239+ let mut max_size = message_id_size ;
240240 #( #max_size_snippets) *
241241 Some ( max_size)
242242 }
@@ -247,7 +247,7 @@ pub fn bufferfish_impl_decodable(input: proc_macro::TokenStream) -> proc_macro::
247247 quote ! {
248248 impl bufferfish:: Decodable for #name {
249249 fn decode( bf: & mut bufferfish:: Bufferfish ) -> Result <Self , bufferfish:: BufferfishError > {
250- #packet_id_snippet
250+ #message_id_snippet
251251 Self :: decode_value( bf)
252252 }
253253
@@ -258,15 +258,15 @@ pub fn bufferfish_impl_decodable(input: proc_macro::TokenStream) -> proc_macro::
258258 }
259259
260260 fn min_bytes_required( ) -> Option <usize > {
261- let packet_id_size = if #has_packet_id { 2 } else { 0 } ;
262- let mut min_size = packet_id_size ;
261+ let message_id_size = if #has_message_id { 2 } else { 0 } ;
262+ let mut min_size = message_id_size ;
263263 #( #min_size_snippets) *
264264 Some ( min_size)
265265 }
266266
267267 fn max_bytes_allowed( ) -> Option <usize > {
268- let packet_id_size = if #has_packet_id { 2 } else { 0 } ;
269- let mut max_size = packet_id_size ;
268+ let message_id_size = if #has_message_id { 2 } else { 0 } ;
269+ let mut max_size = message_id_size ;
270270 #( #max_size_snippets) *
271271 Some ( max_size)
272272 }
@@ -277,7 +277,7 @@ pub fn bufferfish_impl_decodable(input: proc_macro::TokenStream) -> proc_macro::
277277 quote ! {
278278 impl bufferfish:: Decodable for #name {
279279 fn decode( bf: & mut bufferfish:: Bufferfish ) -> Result <Self , bufferfish:: BufferfishError > {
280- #packet_id_snippet
280+ #message_id_snippet
281281 Self :: decode_value( bf)
282282 }
283283
@@ -286,13 +286,13 @@ pub fn bufferfish_impl_decodable(input: proc_macro::TokenStream) -> proc_macro::
286286 }
287287
288288 fn min_bytes_required( ) -> Option <usize > {
289- let packet_id_size = if #has_packet_id { 2 } else { 0 } ;
290- Some ( packet_id_size )
289+ let message_id_size = if #has_message_id { 2 } else { 0 } ;
290+ Some ( message_id_size )
291291 }
292292
293293 fn max_bytes_allowed( ) -> Option <usize > {
294- let packet_id_size = if #has_packet_id { 2 } else { 0 } ;
295- Some ( packet_id_size )
294+ let message_id_size = if #has_message_id { 2 } else { 0 } ;
295+ Some ( message_id_size )
296296 }
297297 }
298298 }
@@ -302,7 +302,7 @@ pub fn bufferfish_impl_decodable(input: proc_macro::TokenStream) -> proc_macro::
302302 quote ! {
303303 impl bufferfish:: Decodable for #name {
304304 fn decode( bf: & mut bufferfish:: Bufferfish ) -> Result <Self , bufferfish:: BufferfishError > {
305- #packet_id_snippet
305+ #message_id_snippet
306306 Self :: decode_value( bf)
307307 }
308308
@@ -315,15 +315,15 @@ pub fn bufferfish_impl_decodable(input: proc_macro::TokenStream) -> proc_macro::
315315 }
316316
317317 fn min_bytes_required( ) -> Option <usize > {
318- // Enum variant (u8) + packet id if present
319- let packet_id_size = if #has_packet_id { 2 } else { 0 } ;
320- Some ( 1 + packet_id_size ) // 1 byte for variant + packet id size if present
318+ // Enum variant (u8) + message id if present
319+ let message_id_size = if #has_message_id { 2 } else { 0 } ;
320+ Some ( 1 + message_id_size ) // 1 byte for variant + message id size if present
321321 }
322322
323323 fn max_bytes_allowed( ) -> Option <usize > {
324- // Enum variant (u8) + packet id if present
325- let packet_id_size = if #has_packet_id { 2 } else { 0 } ;
326- Some ( 1 + packet_id_size ) // 1 byte for variant + packet id size if present
324+ // Enum variant (u8) + message id if present
325+ let message_id_size = if #has_message_id { 2 } else { 0 } ;
326+ Some ( 1 + message_id_size ) // 1 byte for variant + message id size if present
327327 }
328328 }
329329 }
@@ -334,7 +334,7 @@ pub fn bufferfish_impl_decodable(input: proc_macro::TokenStream) -> proc_macro::
334334 generated. into ( )
335335}
336336
337- fn get_packet_id ( ast : & DeriveInput ) -> Option < Expr > {
337+ fn get_message_id ( ast : & DeriveInput ) -> Option < Expr > {
338338 for attr in & ast. attrs {
339339 if attr. path ( ) . is_ident ( "bufferfish" ) {
340340 if let Ok ( expr) = attr. parse_args :: < syn:: Expr > ( ) {
0 commit comments