@@ -100,17 +100,15 @@ pub struct Set {
100
100
#[ derive( Debug , PartialEq , Clone , Serialize , Nom ) ]
101
101
#[ nom( ExtraArgs ( parser: & mut IPFixParser , set_id: u16 ) ) ]
102
102
pub struct Data {
103
- #[ nom(
104
- Parse = "{ |i| parse_fields::<Template>(i, parser.templates.get(&set_id).cloned()) }"
105
- ) ]
103
+ #[ nom( Parse = "{ |i| parse_fields::<Template>(i, parser.templates.get(&set_id)) }" ) ]
106
104
pub data_fields : Vec < BTreeMap < IPFixField , FieldValue > > ,
107
105
}
108
106
109
107
#[ derive( Debug , PartialEq , Clone , Serialize , Nom ) ]
110
108
#[ nom( ExtraArgs ( parser: & mut IPFixParser , set_id: u16 ) ) ]
111
109
pub struct OptionsData {
112
110
#[ nom(
113
- Parse = "{ |i| parse_fields::<OptionsTemplate>(i, parser.options_templates.get(&set_id).cloned() ) }"
111
+ Parse = "{ |i| parse_fields::<OptionsTemplate>(i, parser.options_templates.get(&set_id)) }"
114
112
) ]
115
113
pub data_fields : Vec < BTreeMap < IPFixField , FieldValue > > ,
116
114
}
@@ -209,27 +207,28 @@ impl CommonTemplateFields for OptionsTemplate {
209
207
/// Takes a byte stream and a cached template.
210
208
/// Fields get matched to static types.
211
209
/// Returns BTree of IPFix Types & Fields or IResult Error.
212
- fn parse_fields < T : CommonTemplateFields > (
213
- i : & [ u8 ] ,
214
- template : Option < T > ,
215
- ) -> IResult < & [ u8 ] , Vec < BTreeMap < IPFixField , FieldValue > > > {
210
+ fn parse_fields < ' a , T : CommonTemplateFields > (
211
+ i : & ' a [ u8 ] ,
212
+ template : Option < & T > ,
213
+ ) -> IResult < & ' a [ u8 ] , Vec < BTreeMap < IPFixField , FieldValue > > > {
216
214
let template = match template {
217
215
Some ( t) => t,
218
216
None => {
219
217
// dbg!("Could not fetch any v10 templates!");
220
218
return Err ( NomErr :: Error ( NomError :: new ( i, ErrorKind :: Fail ) ) ) ;
221
219
}
222
220
} ;
221
+ let template_fields = template. get_fields ( ) ;
223
222
// If no fields there are no fields to parse
224
- if template . get_fields ( ) . is_empty ( ) {
223
+ if template_fields . is_empty ( ) {
225
224
// dbg!("Template without fields!");
226
225
return Err ( NomErr :: Error ( NomError :: new ( i, ErrorKind :: Fail ) ) ) ;
227
226
} ;
228
227
let mut fields = vec ! [ ] ;
229
228
let mut remaining = i;
230
229
while !remaining. is_empty ( ) {
231
230
let mut data_field = BTreeMap :: new ( ) ;
232
- for template_field in template . get_fields ( ) . iter ( ) {
231
+ for template_field in template_fields . iter ( ) {
233
232
let field_type: FieldDataType = template_field. field_type . into ( ) ;
234
233
// Enterprise Number
235
234
if template_field. enterprise_number . is_some ( ) {
@@ -349,7 +348,7 @@ impl NetflowByteParserVariable for IPFixParser {
349
348
. checked_sub ( remaining. len ( ) )
350
349
. unwrap_or ( total_left) ;
351
350
total_left -= parsed;
352
- sets. push ( v10_set. clone ( ) ) ;
351
+ sets. push ( v10_set) ;
353
352
}
354
353
355
354
let v10_parsed = IPFix {
0 commit comments