]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/conf: convert parser to nom7
authorPierre Chifflier <chifflier@wzdftpd.net>
Wed, 19 Jan 2022 13:26:57 +0000 (14:26 +0100)
committerVictor Julien <vjulien@oisf.net>
Thu, 29 Sep 2022 08:37:50 +0000 (10:37 +0200)
rust/src/conf.rs

index b3f996945c06103059ef1867473e3fc30da5d9c4..94a868566d51f472ce9de9f0fc89865c26f6ae75 100644 (file)
@@ -21,11 +21,12 @@ use std::os::raw::c_int;
 use std::ffi::{CString, CStr};
 use std::ptr;
 use std::str;
-use nom::{
+use nom7::{
     character::complete::{multispace0, not_line_ending},
     sequence::{preceded, tuple},
     number::complete::double,
     combinator::verify,
+    IResult,
 };
 
 extern {
@@ -86,9 +87,7 @@ pub struct ConfNode {
 impl ConfNode {
 
     pub fn wrap(conf: *const c_void) -> Self {
-        return Self {
-            conf: conf,
-        }
+        return Self { conf }
     }
 
     pub fn get_child_value(&self, key: &str) -> Option<&str> {
@@ -170,9 +169,9 @@ pub fn get_memval(arg: &str) -> Result<u64, &'static str> {
     let arg = arg.trim();
     let val: f64;
     let mut unit: &str;
-    let parser = tuple((preceded(multispace0, double),
+    let mut parser = tuple((preceded(multispace0, double),
                         preceded(multispace0, verify(not_line_ending, |c: &str| c.len() < 3))));
-    let r: nom::IResult<&str, (f64, &str)> = parser(arg);
+    let r: IResult<&str, (f64, &str)> = parser(arg);
     if let Ok(r) = r {
         val = (r.1).0;
         unit = (r.1).1;