@@ -116,31 +116,33 @@ impl RegisterSignatureMessageDmq {
116
116
117
117
/// Extract a `RegisterSignatureMessageDmq` from bytes.
118
118
pub fn try_from_bytes_vec ( bytes : & [ u8 ] ) -> StdResult < Self > {
119
+ const SIGNED_ENTITY_TYPE_LENGTH_BYTES_SIZE : usize = 2 ;
120
+ const SIGNATURE_LENGTH_BYTES_SIZE : usize = 4 ;
119
121
let mut bytes_index = 0 ;
120
122
121
- let mut u16_bytes = [ 0u8 ; 2 ] ;
123
+ let mut u16_bytes = [ 0u8 ; SIGNED_ENTITY_TYPE_LENGTH_BYTES_SIZE ] ;
122
124
u16_bytes. copy_from_slice (
123
125
bytes
124
- . get ( bytes_index..bytes_index + 2 )
126
+ . get ( bytes_index..bytes_index + SIGNED_ENTITY_TYPE_LENGTH_BYTES_SIZE )
125
127
. ok_or ( anyhow ! ( "Failed to read `Signed entity type length` bytes" ) ) ?,
126
128
) ;
127
129
let signed_entity_bytes_length = u16:: from_be_bytes ( u16_bytes) as usize ;
128
- bytes_index += 2 ;
130
+ bytes_index += SIGNED_ENTITY_TYPE_LENGTH_BYTES_SIZE ;
129
131
130
132
let signed_entity_bytes = bytes
131
133
. get ( bytes_index..bytes_index + signed_entity_bytes_length)
132
134
. ok_or ( anyhow ! ( "Failed to read `Signed entity type` bytes" ) ) ?;
133
135
let signed_entity_type = SignedEntityType :: try_from_bytes ( signed_entity_bytes) ?;
134
136
bytes_index += signed_entity_bytes_length;
135
137
136
- let mut u32_bytes = [ 0u8 ; 4 ] ;
138
+ let mut u32_bytes = [ 0u8 ; SIGNATURE_LENGTH_BYTES_SIZE ] ;
137
139
u32_bytes. copy_from_slice (
138
140
bytes
139
- . get ( bytes_index..bytes_index + 4 )
141
+ . get ( bytes_index..bytes_index + SIGNATURE_LENGTH_BYTES_SIZE )
140
142
. ok_or ( anyhow ! ( "Failed to read `Signature length` bytes" ) ) ?,
141
143
) ;
142
144
let signature_bytes_length = u32:: from_be_bytes ( u32_bytes) as usize ;
143
- bytes_index += 4 ;
145
+ bytes_index += SIGNATURE_LENGTH_BYTES_SIZE ;
144
146
145
147
let signature_bytes = bytes
146
148
. get ( bytes_index..bytes_index + signature_bytes_length)
0 commit comments