diff --git a/rust/src/applayertemplate/parser.rs b/rust/src/applayertemplate/parser.rs index dc096eb0c6..52d90cded7 100644 --- a/rust/src/applayertemplate/parser.rs +++ b/rust/src/applayertemplate/parser.rs @@ -15,10 +15,10 @@ * 02110-1301, USA. */ -use nom7::{ +use nom8::{ bytes::streaming::{take, take_until}, combinator::map_res, - IResult, + IResult, Parser, }; use std; @@ -27,9 +27,9 @@ fn parse_len(input: &str) -> Result { } pub fn parse_message(i: &[u8]) -> IResult<&[u8], String> { - let (i, len) = map_res(map_res(take_until(":"), std::str::from_utf8), parse_len)(i)?; - let (i, _sep) = take(1_usize)(i)?; - let (i, msg) = map_res(take(len as usize), std::str::from_utf8)(i)?; + let (i, len) = map_res(map_res(take_until(":"), std::str::from_utf8), parse_len).parse(i)?; + let (i, _sep) = take(1_usize).parse(i)?; + let (i, msg) = map_res(take(len as usize), std::str::from_utf8).parse(i)?; let result = msg.to_string(); Ok((i, result)) } @@ -37,7 +37,7 @@ pub fn parse_message(i: &[u8]) -> IResult<&[u8], String> { #[cfg(test)] mod tests { use super::*; - use nom7::Err; + use nom8::Err; /// Simple test of some valid data. #[test] diff --git a/rust/src/applayertemplate/template.rs b/rust/src/applayertemplate/template.rs index 022343306a..fc59e723ae 100644 --- a/rust/src/applayertemplate/template.rs +++ b/rust/src/applayertemplate/template.rs @@ -20,7 +20,8 @@ use crate::applayer::*; use crate::conf::conf_get; use crate::core::{ALPROTO_UNKNOWN, IPPROTO_TCP}; use crate::flow::Flow; -use nom7 as nom; +use nom8 as nom; +use nom8::{AsChar, Parser}; use std; use std::collections::VecDeque; use std::ffi::CString; @@ -247,11 +248,11 @@ impl TemplateState { /// characters for that pattern. fn probe(input: &[u8]) -> nom::IResult<&[u8], ()> { let size = std::cmp::min(10, input.len()); - let (rem, prefix) = nom::bytes::complete::take(size)(input)?; + let (rem, prefix) = nom::bytes::complete::take(size).parse(input)?; nom::sequence::terminated( - nom::bytes::complete::take_while1(nom::character::is_digit), + nom::bytes::complete::take_while1(|c: u8| c.is_dec_digit()), nom::bytes::complete::tag(":"), - )(prefix)?; + ).parse(prefix)?; Ok((rem, ())) }