/rust/registry/src/index.crates.io-1949cf8c6b5b557f/nom-7.1.3/src/bytes/streaming.rs
Line | Count | Source |
1 | | //! Parsers recognizing bytes streams, streaming version |
2 | | |
3 | | use crate::error::ErrorKind; |
4 | | use crate::error::ParseError; |
5 | | use crate::internal::{Err, IResult, Needed, Parser}; |
6 | | use crate::lib::std::ops::RangeFrom; |
7 | | use crate::lib::std::result::Result::*; |
8 | | use crate::traits::{ |
9 | | Compare, CompareResult, FindSubstring, FindToken, InputIter, InputLength, InputTake, |
10 | | InputTakeAtPosition, Slice, ToUsize, |
11 | | }; |
12 | | |
13 | | /// Recognizes a pattern. |
14 | | /// |
15 | | /// The input data will be compared to the tag combinator's argument and will return the part of |
16 | | /// the input that matches the argument. |
17 | | /// # Example |
18 | | /// ```rust |
19 | | /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult}; |
20 | | /// use nom::bytes::streaming::tag; |
21 | | /// |
22 | | /// fn parser(s: &str) -> IResult<&str, &str> { |
23 | | /// tag("Hello")(s) |
24 | | /// } |
25 | | /// |
26 | | /// assert_eq!(parser("Hello, World!"), Ok((", World!", "Hello"))); |
27 | | /// assert_eq!(parser("Something"), Err(Err::Error(Error::new("Something", ErrorKind::Tag)))); |
28 | | /// assert_eq!(parser("S"), Err(Err::Error(Error::new("S", ErrorKind::Tag)))); |
29 | | /// assert_eq!(parser("H"), Err(Err::Incomplete(Needed::new(4)))); |
30 | | /// ``` |
31 | 40.6M | pub fn tag<T, Input, Error: ParseError<Input>>( |
32 | 40.6M | tag: T, |
33 | 40.6M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> |
34 | 40.6M | where |
35 | 40.6M | Input: InputTake + InputLength + Compare<T>, |
36 | 40.6M | T: InputLength + Clone, |
37 | | { |
38 | 41.9M | move |i: Input| { |
39 | 41.9M | let tag_len = tag.input_len(); |
40 | 41.9M | let t = tag.clone(); |
41 | | |
42 | 41.9M | let res: IResult<_, _, Error> = match i.compare(t) { |
43 | 32.4M | CompareResult::Ok => Ok(i.take_split(tag_len)), |
44 | 554k | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), |
45 | | CompareResult::Error => { |
46 | 8.90M | let e: ErrorKind = ErrorKind::Tag; |
47 | 8.90M | Err(Err::Error(Error::from_error_kind(i, e))) |
48 | | } |
49 | | }; |
50 | 41.9M | res |
51 | 41.9M | } nom::bytes::streaming::tag::<&[u8; 4], &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 38 | 9.69k | move |i: Input| { | 39 | 9.69k | let tag_len = tag.input_len(); | 40 | 9.69k | let t = tag.clone(); | 41 | | | 42 | 9.69k | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | 4.85k | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | 831 | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | 4.01k | let e: ErrorKind = ErrorKind::Tag; | 47 | 4.01k | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | 9.69k | res | 51 | 9.69k | } |
Unexecuted instantiation: nom::bytes::streaming::tag::<[u8; 2], &[u8], nom::error::Error<&[u8]>>::{closure#0}Unexecuted instantiation: nom::bytes::streaming::tag::<_, _, _>::{closure#0}nom::bytes::streaming::tag::<&[u8; 8], &[u8], suricata::rdp::error::RdpError>::{closure#0}Line | Count | Source | 38 | 73.7k | move |i: Input| { | 39 | 73.7k | let tag_len = tag.input_len(); | 40 | 73.7k | let t = tag.clone(); | 41 | | | 42 | 73.7k | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | 1.21k | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | 1.50k | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | 71.0k | let e: ErrorKind = ErrorKind::Tag; | 47 | 71.0k | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | 73.7k | res | 51 | 73.7k | } |
nom::bytes::streaming::tag::<&[u8; 9], &[u8], suricata::rdp::error::RdpError>::{closure#0}Line | Count | Source | 38 | 1.21k | move |i: Input| { | 39 | 1.21k | let tag_len = tag.input_len(); | 40 | 1.21k | let t = tag.clone(); | 41 | | | 42 | 1.21k | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | 175 | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | 456 | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | 579 | let e: ErrorKind = ErrorKind::Tag; | 47 | 579 | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | 1.21k | res | 51 | 1.21k | } |
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::rdp::error::RdpError>::{closure#0}Line | Count | Source | 38 | 29.5k | move |i: Input| { | 39 | 29.5k | let tag_len = tag.input_len(); | 40 | 29.5k | let t = tag.clone(); | 41 | | | 42 | 29.5k | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | 29.5k | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | 0 | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | 0 | let e: ErrorKind = ErrorKind::Tag; | 47 | 0 | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | 29.5k | res | 51 | 29.5k | } |
nom::bytes::streaming::tag::<&str, &[u8], ()>::{closure#0}Line | Count | Source | 38 | 18.2k | move |i: Input| { | 39 | 18.2k | let tag_len = tag.input_len(); | 40 | 18.2k | let t = tag.clone(); | 41 | | | 42 | 18.2k | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | 9.68k | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | 912 | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | 7.64k | let e: ErrorKind = ErrorKind::Tag; | 47 | 7.64k | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | 18.2k | res | 51 | 18.2k | } |
nom::bytes::streaming::tag::<[u8; 1], &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 38 | 957k | move |i: Input| { | 39 | 957k | let tag_len = tag.input_len(); | 40 | 957k | let t = tag.clone(); | 41 | | | 42 | 957k | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | 957k | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | 0 | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | 61 | let e: ErrorKind = ErrorKind::Tag; | 47 | 61 | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | 957k | res | 51 | 957k | } |
nom::bytes::streaming::tag::<&[u8; 1], &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 38 | 200k | move |i: Input| { | 39 | 200k | let tag_len = tag.input_len(); | 40 | 200k | let t = tag.clone(); | 41 | | | 42 | 200k | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | 200k | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | 0 | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | 0 | let e: ErrorKind = ErrorKind::Tag; | 47 | 0 | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | 200k | res | 51 | 200k | } |
nom::bytes::streaming::tag::<&[u8; 3], &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 38 | 2.78M | move |i: Input| { | 39 | 2.78M | let tag_len = tag.input_len(); | 40 | 2.78M | let t = tag.clone(); | 41 | | | 42 | 2.78M | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | 2.76M | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | 5.72k | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | 15.8k | let e: ErrorKind = ErrorKind::Tag; | 47 | 15.8k | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | 2.78M | res | 51 | 2.78M | } |
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::smb::error::SmbError>::{closure#0}Line | Count | Source | 38 | 255k | move |i: Input| { | 39 | 255k | let tag_len = tag.input_len(); | 40 | 255k | let t = tag.clone(); | 41 | | | 42 | 255k | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | 255k | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | 0 | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | 0 | let e: ErrorKind = ErrorKind::Tag; | 47 | 0 | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | 255k | res | 51 | 255k | } |
nom::bytes::streaming::tag::<&[u8], &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 38 | 4.55M | move |i: Input| { | 39 | 4.55M | let tag_len = tag.input_len(); | 40 | 4.55M | let t = tag.clone(); | 41 | | | 42 | 4.55M | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | 4.55M | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | 0 | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | 0 | let e: ErrorKind = ErrorKind::Tag; | 47 | 0 | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | 4.55M | res | 51 | 4.55M | } |
nom::bytes::streaming::tag::<&str, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 38 | 30.2M | move |i: Input| { | 39 | 30.2M | let tag_len = tag.input_len(); | 40 | 30.2M | let t = tag.clone(); | 41 | | | 42 | 30.2M | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | 20.9M | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | 543k | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | 8.80M | let e: ErrorKind = ErrorKind::Tag; | 47 | 8.80M | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | 30.2M | res | 51 | 30.2M | } |
nom::bytes::streaming::tag::<&[u8; 4], &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 38 | 2.79M | move |i: Input| { | 39 | 2.79M | let tag_len = tag.input_len(); | 40 | 2.79M | let t = tag.clone(); | 41 | | | 42 | 2.79M | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | 2.79M | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | 875 | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | 6.80k | let e: ErrorKind = ErrorKind::Tag; | 47 | 6.80k | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | 2.79M | res | 51 | 2.79M | } |
Unexecuted instantiation: nom::bytes::streaming::tag::<[u8; 2], &[u8], nom::error::Error<&[u8]>>::{closure#0}Unexecuted instantiation: nom::bytes::streaming::tag::<_, _, _>::{closure#0} |
52 | 40.6M | } nom::bytes::streaming::tag::<&[u8; 4], &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 31 | 7.64k | pub fn tag<T, Input, Error: ParseError<Input>>( | 32 | 7.64k | tag: T, | 33 | 7.64k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 34 | 7.64k | where | 35 | 7.64k | Input: InputTake + InputLength + Compare<T>, | 36 | 7.64k | T: InputLength + Clone, | 37 | | { | 38 | | move |i: Input| { | 39 | | let tag_len = tag.input_len(); | 40 | | let t = tag.clone(); | 41 | | | 42 | | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | | let e: ErrorKind = ErrorKind::Tag; | 47 | | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | | res | 51 | | } | 52 | 7.64k | } |
Unexecuted instantiation: nom::bytes::streaming::tag::<[u8; 2], &[u8], nom::error::Error<&[u8]>> Unexecuted instantiation: nom::bytes::streaming::tag::<_, _, _> nom::bytes::streaming::tag::<&str, &[u8], ()> Line | Count | Source | 31 | 26.7k | pub fn tag<T, Input, Error: ParseError<Input>>( | 32 | 26.7k | tag: T, | 33 | 26.7k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 34 | 26.7k | where | 35 | 26.7k | Input: InputTake + InputLength + Compare<T>, | 36 | 26.7k | T: InputLength + Clone, | 37 | | { | 38 | | move |i: Input| { | 39 | | let tag_len = tag.input_len(); | 40 | | let t = tag.clone(); | 41 | | | 42 | | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | | let e: ErrorKind = ErrorKind::Tag; | 47 | | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | | res | 51 | | } | 52 | 26.7k | } |
nom::bytes::streaming::tag::<&[u8; 8], &[u8], suricata::rdp::error::RdpError> Line | Count | Source | 31 | 73.7k | pub fn tag<T, Input, Error: ParseError<Input>>( | 32 | 73.7k | tag: T, | 33 | 73.7k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 34 | 73.7k | where | 35 | 73.7k | Input: InputTake + InputLength + Compare<T>, | 36 | 73.7k | T: InputLength + Clone, | 37 | | { | 38 | | move |i: Input| { | 39 | | let tag_len = tag.input_len(); | 40 | | let t = tag.clone(); | 41 | | | 42 | | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | | let e: ErrorKind = ErrorKind::Tag; | 47 | | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | | res | 51 | | } | 52 | 73.7k | } |
nom::bytes::streaming::tag::<&[u8; 9], &[u8], suricata::rdp::error::RdpError> Line | Count | Source | 31 | 1.21k | pub fn tag<T, Input, Error: ParseError<Input>>( | 32 | 1.21k | tag: T, | 33 | 1.21k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 34 | 1.21k | where | 35 | 1.21k | Input: InputTake + InputLength + Compare<T>, | 36 | 1.21k | T: InputLength + Clone, | 37 | | { | 38 | | move |i: Input| { | 39 | | let tag_len = tag.input_len(); | 40 | | let t = tag.clone(); | 41 | | | 42 | | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | | let e: ErrorKind = ErrorKind::Tag; | 47 | | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | | res | 51 | | } | 52 | 1.21k | } |
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::rdp::error::RdpError> Line | Count | Source | 31 | 29.5k | pub fn tag<T, Input, Error: ParseError<Input>>( | 32 | 29.5k | tag: T, | 33 | 29.5k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 34 | 29.5k | where | 35 | 29.5k | Input: InputTake + InputLength + Compare<T>, | 36 | 29.5k | T: InputLength + Clone, | 37 | | { | 38 | | move |i: Input| { | 39 | | let tag_len = tag.input_len(); | 40 | | let t = tag.clone(); | 41 | | | 42 | | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | | let e: ErrorKind = ErrorKind::Tag; | 47 | | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | | res | 51 | | } | 52 | 29.5k | } |
nom::bytes::streaming::tag::<[u8; 1], &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 31 | 957k | pub fn tag<T, Input, Error: ParseError<Input>>( | 32 | 957k | tag: T, | 33 | 957k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 34 | 957k | where | 35 | 957k | Input: InputTake + InputLength + Compare<T>, | 36 | 957k | T: InputLength + Clone, | 37 | | { | 38 | | move |i: Input| { | 39 | | let tag_len = tag.input_len(); | 40 | | let t = tag.clone(); | 41 | | | 42 | | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | | let e: ErrorKind = ErrorKind::Tag; | 47 | | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | | res | 51 | | } | 52 | 957k | } |
nom::bytes::streaming::tag::<&[u8; 1], &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 31 | 200k | pub fn tag<T, Input, Error: ParseError<Input>>( | 32 | 200k | tag: T, | 33 | 200k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 34 | 200k | where | 35 | 200k | Input: InputTake + InputLength + Compare<T>, | 36 | 200k | T: InputLength + Clone, | 37 | | { | 38 | | move |i: Input| { | 39 | | let tag_len = tag.input_len(); | 40 | | let t = tag.clone(); | 41 | | | 42 | | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | | let e: ErrorKind = ErrorKind::Tag; | 47 | | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | | res | 51 | | } | 52 | 200k | } |
nom::bytes::streaming::tag::<&[u8; 3], &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 31 | 2.78M | pub fn tag<T, Input, Error: ParseError<Input>>( | 32 | 2.78M | tag: T, | 33 | 2.78M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 34 | 2.78M | where | 35 | 2.78M | Input: InputTake + InputLength + Compare<T>, | 36 | 2.78M | T: InputLength + Clone, | 37 | | { | 38 | | move |i: Input| { | 39 | | let tag_len = tag.input_len(); | 40 | | let t = tag.clone(); | 41 | | | 42 | | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | | let e: ErrorKind = ErrorKind::Tag; | 47 | | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | | res | 51 | | } | 52 | 2.78M | } |
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::smb::error::SmbError> Line | Count | Source | 31 | 255k | pub fn tag<T, Input, Error: ParseError<Input>>( | 32 | 255k | tag: T, | 33 | 255k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 34 | 255k | where | 35 | 255k | Input: InputTake + InputLength + Compare<T>, | 36 | 255k | T: InputLength + Clone, | 37 | | { | 38 | | move |i: Input| { | 39 | | let tag_len = tag.input_len(); | 40 | | let t = tag.clone(); | 41 | | | 42 | | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | | let e: ErrorKind = ErrorKind::Tag; | 47 | | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | | res | 51 | | } | 52 | 255k | } |
nom::bytes::streaming::tag::<&[u8], &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 31 | 4.55M | pub fn tag<T, Input, Error: ParseError<Input>>( | 32 | 4.55M | tag: T, | 33 | 4.55M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 34 | 4.55M | where | 35 | 4.55M | Input: InputTake + InputLength + Compare<T>, | 36 | 4.55M | T: InputLength + Clone, | 37 | | { | 38 | | move |i: Input| { | 39 | | let tag_len = tag.input_len(); | 40 | | let t = tag.clone(); | 41 | | | 42 | | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | | let e: ErrorKind = ErrorKind::Tag; | 47 | | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | | res | 51 | | } | 52 | 4.55M | } |
nom::bytes::streaming::tag::<&[u8; 4], &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 31 | 2.79M | pub fn tag<T, Input, Error: ParseError<Input>>( | 32 | 2.79M | tag: T, | 33 | 2.79M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 34 | 2.79M | where | 35 | 2.79M | Input: InputTake + InputLength + Compare<T>, | 36 | 2.79M | T: InputLength + Clone, | 37 | | { | 38 | | move |i: Input| { | 39 | | let tag_len = tag.input_len(); | 40 | | let t = tag.clone(); | 41 | | | 42 | | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | | let e: ErrorKind = ErrorKind::Tag; | 47 | | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | | res | 51 | | } | 52 | 2.79M | } |
nom::bytes::streaming::tag::<&str, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 31 | 28.9M | pub fn tag<T, Input, Error: ParseError<Input>>( | 32 | 28.9M | tag: T, | 33 | 28.9M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 34 | 28.9M | where | 35 | 28.9M | Input: InputTake + InputLength + Compare<T>, | 36 | 28.9M | T: InputLength + Clone, | 37 | | { | 38 | | move |i: Input| { | 39 | | let tag_len = tag.input_len(); | 40 | | let t = tag.clone(); | 41 | | | 42 | | let res: IResult<_, _, Error> = match i.compare(t) { | 43 | | CompareResult::Ok => Ok(i.take_split(tag_len)), | 44 | | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), | 45 | | CompareResult::Error => { | 46 | | let e: ErrorKind = ErrorKind::Tag; | 47 | | Err(Err::Error(Error::from_error_kind(i, e))) | 48 | | } | 49 | | }; | 50 | | res | 51 | | } | 52 | 28.9M | } |
Unexecuted instantiation: nom::bytes::streaming::tag::<[u8; 2], &[u8], nom::error::Error<&[u8]>> Unexecuted instantiation: nom::bytes::streaming::tag::<_, _, _> |
53 | | |
54 | | /// Recognizes a case insensitive pattern. |
55 | | /// |
56 | | /// The input data will be compared to the tag combinator's argument and will return the part of |
57 | | /// the input that matches the argument with no regard to case. |
58 | | /// # Example |
59 | | /// ```rust |
60 | | /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult}; |
61 | | /// use nom::bytes::streaming::tag_no_case; |
62 | | /// |
63 | | /// fn parser(s: &str) -> IResult<&str, &str> { |
64 | | /// tag_no_case("hello")(s) |
65 | | /// } |
66 | | /// |
67 | | /// assert_eq!(parser("Hello, World!"), Ok((", World!", "Hello"))); |
68 | | /// assert_eq!(parser("hello, World!"), Ok((", World!", "hello"))); |
69 | | /// assert_eq!(parser("HeLlO, World!"), Ok((", World!", "HeLlO"))); |
70 | | /// assert_eq!(parser("Something"), Err(Err::Error(Error::new("Something", ErrorKind::Tag)))); |
71 | | /// assert_eq!(parser(""), Err(Err::Incomplete(Needed::new(5)))); |
72 | | /// ``` |
73 | 0 | pub fn tag_no_case<T, Input, Error: ParseError<Input>>( |
74 | 0 | tag: T, |
75 | 0 | ) -> impl Fn(Input) -> IResult<Input, Input, Error> |
76 | 0 | where |
77 | 0 | Input: InputTake + InputLength + Compare<T>, |
78 | 0 | T: InputLength + Clone, |
79 | | { |
80 | 0 | move |i: Input| { |
81 | 0 | let tag_len = tag.input_len(); |
82 | 0 | let t = tag.clone(); |
83 | | |
84 | 0 | let res: IResult<_, _, Error> = match (i).compare_no_case(t) { |
85 | 0 | CompareResult::Ok => Ok(i.take_split(tag_len)), |
86 | 0 | CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))), |
87 | | CompareResult::Error => { |
88 | 0 | let e: ErrorKind = ErrorKind::Tag; |
89 | 0 | Err(Err::Error(Error::from_error_kind(i, e))) |
90 | | } |
91 | | }; |
92 | 0 | res |
93 | 0 | } Unexecuted instantiation: nom::bytes::streaming::tag_no_case::<_, _, _>::{closure#0}Unexecuted instantiation: nom::bytes::streaming::tag_no_case::<_, _, _>::{closure#0} |
94 | 0 | } Unexecuted instantiation: nom::bytes::streaming::tag_no_case::<_, _, _> Unexecuted instantiation: nom::bytes::streaming::tag_no_case::<_, _, _> |
95 | | |
96 | | /// Parse till certain characters are met. |
97 | | /// |
98 | | /// The parser will return the longest slice till one of the characters of the combinator's argument are met. |
99 | | /// |
100 | | /// It doesn't consume the matched character. |
101 | | /// |
102 | | /// It will return a `Err::Incomplete(Needed::new(1))` if the pattern wasn't met. |
103 | | /// # Example |
104 | | /// ```rust |
105 | | /// # use nom::{Err, error::ErrorKind, Needed, IResult}; |
106 | | /// use nom::bytes::streaming::is_not; |
107 | | /// |
108 | | /// fn not_space(s: &str) -> IResult<&str, &str> { |
109 | | /// is_not(" \t\r\n")(s) |
110 | | /// } |
111 | | /// |
112 | | /// assert_eq!(not_space("Hello, World!"), Ok((" World!", "Hello,"))); |
113 | | /// assert_eq!(not_space("Sometimes\t"), Ok(("\t", "Sometimes"))); |
114 | | /// assert_eq!(not_space("Nospace"), Err(Err::Incomplete(Needed::new(1)))); |
115 | | /// assert_eq!(not_space(""), Err(Err::Incomplete(Needed::new(1)))); |
116 | | /// ``` |
117 | 16.6k | pub fn is_not<T, Input, Error: ParseError<Input>>( |
118 | 16.6k | arr: T, |
119 | 16.6k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> |
120 | 16.6k | where |
121 | 16.6k | Input: InputTakeAtPosition, |
122 | 16.6k | T: FindToken<<Input as InputTakeAtPosition>::Item>, |
123 | | { |
124 | 16.6k | move |i: Input| { |
125 | 16.6k | let e: ErrorKind = ErrorKind::IsNot; |
126 | 22.7M | i.split_at_position1(|c| arr.find_token(c), e) Unexecuted instantiation: nom::bytes::streaming::is_not::<_, _, _>::{closure#0}::{closure#0}nom::bytes::streaming::is_not::<&str, &str, nom::error::Error<&str>>::{closure#0}::{closure#0}Line | Count | Source | 126 | 256k | i.split_at_position1(|c| arr.find_token(c), e) |
nom::bytes::streaming::is_not::<&str, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 126 | 22.4M | i.split_at_position1(|c| arr.find_token(c), e) |
Unexecuted instantiation: nom::bytes::streaming::is_not::<_, _, _>::{closure#0}::{closure#0} |
127 | 16.6k | } Unexecuted instantiation: nom::bytes::streaming::is_not::<_, _, _>::{closure#0}nom::bytes::streaming::is_not::<&str, &str, nom::error::Error<&str>>::{closure#0}Line | Count | Source | 124 | 9.49k | move |i: Input| { | 125 | 9.49k | let e: ErrorKind = ErrorKind::IsNot; | 126 | 9.49k | i.split_at_position1(|c| arr.find_token(c), e) | 127 | 9.49k | } |
nom::bytes::streaming::is_not::<&str, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 124 | 7.14k | move |i: Input| { | 125 | 7.14k | let e: ErrorKind = ErrorKind::IsNot; | 126 | 7.14k | i.split_at_position1(|c| arr.find_token(c), e) | 127 | 7.14k | } |
Unexecuted instantiation: nom::bytes::streaming::is_not::<_, _, _>::{closure#0} |
128 | 16.6k | } Unexecuted instantiation: nom::bytes::streaming::is_not::<_, _, _> nom::bytes::streaming::is_not::<&str, &str, nom::error::Error<&str>> Line | Count | Source | 117 | 9.49k | pub fn is_not<T, Input, Error: ParseError<Input>>( | 118 | 9.49k | arr: T, | 119 | 9.49k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 120 | 9.49k | where | 121 | 9.49k | Input: InputTakeAtPosition, | 122 | 9.49k | T: FindToken<<Input as InputTakeAtPosition>::Item>, | 123 | | { | 124 | | move |i: Input| { | 125 | | let e: ErrorKind = ErrorKind::IsNot; | 126 | | i.split_at_position1(|c| arr.find_token(c), e) | 127 | | } | 128 | 9.49k | } |
nom::bytes::streaming::is_not::<&str, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 117 | 7.14k | pub fn is_not<T, Input, Error: ParseError<Input>>( | 118 | 7.14k | arr: T, | 119 | 7.14k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 120 | 7.14k | where | 121 | 7.14k | Input: InputTakeAtPosition, | 122 | 7.14k | T: FindToken<<Input as InputTakeAtPosition>::Item>, | 123 | | { | 124 | | move |i: Input| { | 125 | | let e: ErrorKind = ErrorKind::IsNot; | 126 | | i.split_at_position1(|c| arr.find_token(c), e) | 127 | | } | 128 | 7.14k | } |
Unexecuted instantiation: nom::bytes::streaming::is_not::<_, _, _> |
129 | | |
130 | | /// Returns the longest slice of the matches the pattern. |
131 | | /// |
132 | | /// The parser will return the longest slice consisting of the characters in provided in the |
133 | | /// combinator's argument. |
134 | | /// |
135 | | /// # Streaming specific |
136 | | /// *Streaming version* will return a `Err::Incomplete(Needed::new(1))` if the pattern wasn't met |
137 | | /// or if the pattern reaches the end of the input. |
138 | | /// # Example |
139 | | /// ```rust |
140 | | /// # use nom::{Err, error::ErrorKind, Needed, IResult}; |
141 | | /// use nom::bytes::streaming::is_a; |
142 | | /// |
143 | | /// fn hex(s: &str) -> IResult<&str, &str> { |
144 | | /// is_a("1234567890ABCDEF")(s) |
145 | | /// } |
146 | | /// |
147 | | /// assert_eq!(hex("123 and voila"), Ok((" and voila", "123"))); |
148 | | /// assert_eq!(hex("DEADBEEF and others"), Ok((" and others", "DEADBEEF"))); |
149 | | /// assert_eq!(hex("BADBABEsomething"), Ok(("something", "BADBABE"))); |
150 | | /// assert_eq!(hex("D15EA5E"), Err(Err::Incomplete(Needed::new(1)))); |
151 | | /// assert_eq!(hex(""), Err(Err::Incomplete(Needed::new(1)))); |
152 | | /// ``` |
153 | 9.49k | pub fn is_a<T, Input, Error: ParseError<Input>>( |
154 | 9.49k | arr: T, |
155 | 9.49k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> |
156 | 9.49k | where |
157 | 9.49k | Input: InputTakeAtPosition, |
158 | 9.49k | T: FindToken<<Input as InputTakeAtPosition>::Item>, |
159 | | { |
160 | 9.49k | move |i: Input| { |
161 | 9.49k | let e: ErrorKind = ErrorKind::IsA; |
162 | 9.49k | i.split_at_position1(|c| !arr.find_token(c), e) Unexecuted instantiation: nom::bytes::streaming::is_a::<_, _, _>::{closure#0}::{closure#0}nom::bytes::streaming::is_a::<&str, &str, nom::error::Error<&str>>::{closure#0}::{closure#0}Line | Count | Source | 162 | 9.49k | i.split_at_position1(|c| !arr.find_token(c), e) |
Unexecuted instantiation: nom::bytes::streaming::is_a::<_, _, _>::{closure#0}::{closure#0} |
163 | 9.49k | } Unexecuted instantiation: nom::bytes::streaming::is_a::<_, _, _>::{closure#0}nom::bytes::streaming::is_a::<&str, &str, nom::error::Error<&str>>::{closure#0}Line | Count | Source | 160 | 9.49k | move |i: Input| { | 161 | 9.49k | let e: ErrorKind = ErrorKind::IsA; | 162 | 9.49k | i.split_at_position1(|c| !arr.find_token(c), e) | 163 | 9.49k | } |
Unexecuted instantiation: nom::bytes::streaming::is_a::<_, _, _>::{closure#0} |
164 | 9.49k | } Unexecuted instantiation: nom::bytes::streaming::is_a::<_, _, _> nom::bytes::streaming::is_a::<&str, &str, nom::error::Error<&str>> Line | Count | Source | 153 | 9.49k | pub fn is_a<T, Input, Error: ParseError<Input>>( | 154 | 9.49k | arr: T, | 155 | 9.49k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 156 | 9.49k | where | 157 | 9.49k | Input: InputTakeAtPosition, | 158 | 9.49k | T: FindToken<<Input as InputTakeAtPosition>::Item>, | 159 | | { | 160 | | move |i: Input| { | 161 | | let e: ErrorKind = ErrorKind::IsA; | 162 | | i.split_at_position1(|c| !arr.find_token(c), e) | 163 | | } | 164 | 9.49k | } |
Unexecuted instantiation: nom::bytes::streaming::is_a::<_, _, _> |
165 | | |
166 | | /// Returns the longest input slice (if any) that matches the predicate. |
167 | | /// |
168 | | /// The parser will return the longest slice that matches the given predicate *(a function that |
169 | | /// takes the input and returns a bool)*. |
170 | | /// |
171 | | /// # Streaming Specific |
172 | | /// *Streaming version* will return a `Err::Incomplete(Needed::new(1))` if the pattern reaches the end of the input. |
173 | | /// # Example |
174 | | /// ```rust |
175 | | /// # use nom::{Err, error::ErrorKind, Needed, IResult}; |
176 | | /// use nom::bytes::streaming::take_while; |
177 | | /// use nom::character::is_alphabetic; |
178 | | /// |
179 | | /// fn alpha(s: &[u8]) -> IResult<&[u8], &[u8]> { |
180 | | /// take_while(is_alphabetic)(s) |
181 | | /// } |
182 | | /// |
183 | | /// assert_eq!(alpha(b"latin123"), Ok((&b"123"[..], &b"latin"[..]))); |
184 | | /// assert_eq!(alpha(b"12345"), Ok((&b"12345"[..], &b""[..]))); |
185 | | /// assert_eq!(alpha(b"latin"), Err(Err::Incomplete(Needed::new(1)))); |
186 | | /// assert_eq!(alpha(b""), Err(Err::Incomplete(Needed::new(1)))); |
187 | | /// ``` |
188 | 13.2M | pub fn take_while<F, Input, Error: ParseError<Input>>( |
189 | 13.2M | cond: F, |
190 | 13.2M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> |
191 | 13.2M | where |
192 | 13.2M | Input: InputTakeAtPosition, |
193 | 13.2M | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, |
194 | | { |
195 | 96.7M | move |i: Input| i.split_at_position(|c| !cond(c)) nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 195 | 111k | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#2}, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 195 | 105k | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::http2::parser::http2_parse_var_uint::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 195 | 541k | move |i: Input| i.split_at_position(|c| !cond(c)) |
Unexecuted instantiation: nom::bytes::streaming::take_while::<_, _, _>::{closure#0}nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 195 | 28.6k | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#2}, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 195 | 26.5k | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::http2::parser::http2_parse_var_uint::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 195 | 434k | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::tftp::tftp::getstr::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 195 | 957k | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<nom::character::is_space, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 195 | 2.12M | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::sip::parser::is_header_name, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 195 | 1.06M | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::sip::parser::is_method_char, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 195 | 78.8k | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 195 | 93.2k | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::ssh::parser::is_not_lineend, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 195 | 48.5k | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::mime::mime_parse_header_token::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 195 | 7.65M | move |i: Input| i.split_at_position(|c| !cond(c)) |
Unexecuted instantiation: nom::bytes::streaming::take_while::<_, _, _>::{closure#0}nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 195 | 144k | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#2}, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 195 | 239k | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::http2::parser::http2_parse_var_uint::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 195 | 7.05M | move |i: Input| i.split_at_position(|c| !cond(c)) |
Unexecuted instantiation: nom::bytes::streaming::take_while::<_, _, _>::{closure#0}::{closure#0}nom::bytes::streaming::take_while::<suricata::mime::mime_parse_header_token::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 195 | 7.69M | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::tftp::tftp::getstr::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 195 | 8.78M | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 195 | 51.5k | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#2}, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 195 | 71.5k | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::http2::parser::http2_parse_var_uint::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 195 | 4.88M | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<nom::character::is_space, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 195 | 3.52M | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::sip::parser::is_header_name, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 195 | 20.1M | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::sip::parser::is_method_char, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 195 | 3.49M | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 195 | 11.1M | move |i: Input| i.split_at_position(|c| !cond(c)) |
nom::bytes::streaming::take_while::<suricata::ssh::parser::is_not_lineend, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 195 | 29.4M | move |i: Input| i.split_at_position(|c| !cond(c)) |
Unexecuted instantiation: nom::bytes::streaming::take_while::<_, _, _>::{closure#0}::{closure#0} |
196 | 13.2M | } nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#0}, &[u8], nom::error::Error<&[u8]>>Line | Count | Source | 188 | 111k | pub fn take_while<F, Input, Error: ParseError<Input>>( | 189 | 111k | cond: F, | 190 | 111k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 191 | 111k | where | 192 | 111k | Input: InputTakeAtPosition, | 193 | 111k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 194 | | { | 195 | | move |i: Input| i.split_at_position(|c| !cond(c)) | 196 | 111k | } |
nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#2}, &[u8], nom::error::Error<&[u8]>>Line | Count | Source | 188 | 105k | pub fn take_while<F, Input, Error: ParseError<Input>>( | 189 | 105k | cond: F, | 190 | 105k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 191 | 105k | where | 192 | 105k | Input: InputTakeAtPosition, | 193 | 105k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 194 | | { | 195 | | move |i: Input| i.split_at_position(|c| !cond(c)) | 196 | 105k | } |
nom::bytes::streaming::take_while::<suricata::http2::parser::http2_parse_var_uint::{closure#0}, &[u8], nom::error::Error<&[u8]>>Line | Count | Source | 188 | 541k | pub fn take_while<F, Input, Error: ParseError<Input>>( | 189 | 541k | cond: F, | 190 | 541k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 191 | 541k | where | 192 | 541k | Input: InputTakeAtPosition, | 193 | 541k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 194 | | { | 195 | | move |i: Input| i.split_at_position(|c| !cond(c)) | 196 | 541k | } |
Unexecuted instantiation: nom::bytes::streaming::take_while::<_, _, _> nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#0}, &[u8], nom::error::Error<&[u8]>>Line | Count | Source | 188 | 28.6k | pub fn take_while<F, Input, Error: ParseError<Input>>( | 189 | 28.6k | cond: F, | 190 | 28.6k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 191 | 28.6k | where | 192 | 28.6k | Input: InputTakeAtPosition, | 193 | 28.6k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 194 | | { | 195 | | move |i: Input| i.split_at_position(|c| !cond(c)) | 196 | 28.6k | } |
nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#2}, &[u8], nom::error::Error<&[u8]>>Line | Count | Source | 188 | 26.5k | pub fn take_while<F, Input, Error: ParseError<Input>>( | 189 | 26.5k | cond: F, | 190 | 26.5k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 191 | 26.5k | where | 192 | 26.5k | Input: InputTakeAtPosition, | 193 | 26.5k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 194 | | { | 195 | | move |i: Input| i.split_at_position(|c| !cond(c)) | 196 | 26.5k | } |
nom::bytes::streaming::take_while::<suricata::http2::parser::http2_parse_var_uint::{closure#0}, &[u8], nom::error::Error<&[u8]>>Line | Count | Source | 188 | 434k | pub fn take_while<F, Input, Error: ParseError<Input>>( | 189 | 434k | cond: F, | 190 | 434k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 191 | 434k | where | 192 | 434k | Input: InputTakeAtPosition, | 193 | 434k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 194 | | { | 195 | | move |i: Input| i.split_at_position(|c| !cond(c)) | 196 | 434k | } |
nom::bytes::streaming::take_while::<suricata::ssh::parser::is_not_lineend, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 188 | 48.5k | pub fn take_while<F, Input, Error: ParseError<Input>>( | 189 | 48.5k | cond: F, | 190 | 48.5k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 191 | 48.5k | where | 192 | 48.5k | Input: InputTakeAtPosition, | 193 | 48.5k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 194 | | { | 195 | | move |i: Input| i.split_at_position(|c| !cond(c)) | 196 | 48.5k | } |
nom::bytes::streaming::take_while::<nom::character::is_space, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 188 | 2.12M | pub fn take_while<F, Input, Error: ParseError<Input>>( | 189 | 2.12M | cond: F, | 190 | 2.12M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 191 | 2.12M | where | 192 | 2.12M | Input: InputTakeAtPosition, | 193 | 2.12M | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 194 | | { | 195 | | move |i: Input| i.split_at_position(|c| !cond(c)) | 196 | 2.12M | } |
nom::bytes::streaming::take_while::<suricata::sip::parser::is_header_name, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 188 | 1.06M | pub fn take_while<F, Input, Error: ParseError<Input>>( | 189 | 1.06M | cond: F, | 190 | 1.06M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 191 | 1.06M | where | 192 | 1.06M | Input: InputTakeAtPosition, | 193 | 1.06M | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 194 | | { | 195 | | move |i: Input| i.split_at_position(|c| !cond(c)) | 196 | 1.06M | } |
nom::bytes::streaming::take_while::<suricata::sip::parser::is_method_char, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 188 | 78.8k | pub fn take_while<F, Input, Error: ParseError<Input>>( | 189 | 78.8k | cond: F, | 190 | 78.8k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 191 | 78.8k | where | 192 | 78.8k | Input: InputTakeAtPosition, | 193 | 78.8k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 194 | | { | 195 | | move |i: Input| i.split_at_position(|c| !cond(c)) | 196 | 78.8k | } |
nom::bytes::streaming::take_while::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 188 | 93.2k | pub fn take_while<F, Input, Error: ParseError<Input>>( | 189 | 93.2k | cond: F, | 190 | 93.2k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 191 | 93.2k | where | 192 | 93.2k | Input: InputTakeAtPosition, | 193 | 93.2k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 194 | | { | 195 | | move |i: Input| i.split_at_position(|c| !cond(c)) | 196 | 93.2k | } |
nom::bytes::streaming::take_while::<suricata::tftp::tftp::getstr::{closure#0}, &[u8], nom::error::Error<&[u8]>>Line | Count | Source | 188 | 957k | pub fn take_while<F, Input, Error: ParseError<Input>>( | 189 | 957k | cond: F, | 190 | 957k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 191 | 957k | where | 192 | 957k | Input: InputTakeAtPosition, | 193 | 957k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 194 | | { | 195 | | move |i: Input| i.split_at_position(|c| !cond(c)) | 196 | 957k | } |
nom::bytes::streaming::take_while::<suricata::mime::mime_parse_header_token::{closure#0}, &[u8], nom::error::Error<&[u8]>>Line | Count | Source | 188 | 7.65M | pub fn take_while<F, Input, Error: ParseError<Input>>( | 189 | 7.65M | cond: F, | 190 | 7.65M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 191 | 7.65M | where | 192 | 7.65M | Input: InputTakeAtPosition, | 193 | 7.65M | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 194 | | { | 195 | | move |i: Input| i.split_at_position(|c| !cond(c)) | 196 | 7.65M | } |
Unexecuted instantiation: nom::bytes::streaming::take_while::<_, _, _> |
197 | | |
198 | | /// Returns the longest (at least 1) input slice that matches the predicate. |
199 | | /// |
200 | | /// The parser will return the longest slice that matches the given predicate *(a function that |
201 | | /// takes the input and returns a bool)*. |
202 | | /// |
203 | | /// It will return an `Err(Err::Error((_, ErrorKind::TakeWhile1)))` if the pattern wasn't met. |
204 | | /// |
205 | | /// # Streaming Specific |
206 | | /// *Streaming version* will return a `Err::Incomplete(Needed::new(1))` or if the pattern reaches the end of the input. |
207 | | /// |
208 | | /// # Example |
209 | | /// ```rust |
210 | | /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult}; |
211 | | /// use nom::bytes::streaming::take_while1; |
212 | | /// use nom::character::is_alphabetic; |
213 | | /// |
214 | | /// fn alpha(s: &[u8]) -> IResult<&[u8], &[u8]> { |
215 | | /// take_while1(is_alphabetic)(s) |
216 | | /// } |
217 | | /// |
218 | | /// assert_eq!(alpha(b"latin123"), Ok((&b"123"[..], &b"latin"[..]))); |
219 | | /// assert_eq!(alpha(b"latin"), Err(Err::Incomplete(Needed::new(1)))); |
220 | | /// assert_eq!(alpha(b"12345"), Err(Err::Error(Error::new(&b"12345"[..], ErrorKind::TakeWhile1)))); |
221 | | /// ``` |
222 | 415k | pub fn take_while1<F, Input, Error: ParseError<Input>>( |
223 | 415k | cond: F, |
224 | 415k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> |
225 | 415k | where |
226 | 415k | Input: InputTakeAtPosition, |
227 | 415k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, |
228 | | { |
229 | 415k | move |i: Input| { |
230 | 415k | let e: ErrorKind = ErrorKind::TakeWhile1; |
231 | 29.9M | i.split_at_position1(|c| !cond(c), e) Unexecuted instantiation: nom::bytes::streaming::take_while1::<_, _, _>::{closure#0}::{closure#0}nom::bytes::streaming::take_while1::<suricata::sip::parser::is_version_char, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 231 | 5.47M | i.split_at_position1(|c| !cond(c), e) |
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 231 | 14.1M | i.split_at_position1(|c| !cond(c), e) |
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_request_uri_char, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 231 | 10.2M | i.split_at_position1(|c| !cond(c), e) |
Unexecuted instantiation: nom::bytes::streaming::take_while1::<_, _, _>::{closure#0}::{closure#0} |
232 | 415k | } Unexecuted instantiation: nom::bytes::streaming::take_while1::<_, _, _>::{closure#0}nom::bytes::streaming::take_while1::<suricata::sip::parser::is_version_char, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 229 | 170k | move |i: Input| { | 230 | 170k | let e: ErrorKind = ErrorKind::TakeWhile1; | 231 | 170k | i.split_at_position1(|c| !cond(c), e) | 232 | 170k | } |
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 229 | 166k | move |i: Input| { | 230 | 166k | let e: ErrorKind = ErrorKind::TakeWhile1; | 231 | 166k | i.split_at_position1(|c| !cond(c), e) | 232 | 166k | } |
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_request_uri_char, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 229 | 78.7k | move |i: Input| { | 230 | 78.7k | let e: ErrorKind = ErrorKind::TakeWhile1; | 231 | 78.7k | i.split_at_position1(|c| !cond(c), e) | 232 | 78.7k | } |
Unexecuted instantiation: nom::bytes::streaming::take_while1::<_, _, _>::{closure#0} |
233 | 415k | } Unexecuted instantiation: nom::bytes::streaming::take_while1::<_, _, _> nom::bytes::streaming::take_while1::<suricata::sip::parser::is_version_char, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 222 | 170k | pub fn take_while1<F, Input, Error: ParseError<Input>>( | 223 | 170k | cond: F, | 224 | 170k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 225 | 170k | where | 226 | 170k | Input: InputTakeAtPosition, | 227 | 170k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 228 | | { | 229 | | move |i: Input| { | 230 | | let e: ErrorKind = ErrorKind::TakeWhile1; | 231 | | i.split_at_position1(|c| !cond(c), e) | 232 | | } | 233 | 170k | } |
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 222 | 166k | pub fn take_while1<F, Input, Error: ParseError<Input>>( | 223 | 166k | cond: F, | 224 | 166k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 225 | 166k | where | 226 | 166k | Input: InputTakeAtPosition, | 227 | 166k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 228 | | { | 229 | | move |i: Input| { | 230 | | let e: ErrorKind = ErrorKind::TakeWhile1; | 231 | | i.split_at_position1(|c| !cond(c), e) | 232 | | } | 233 | 166k | } |
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_request_uri_char, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 222 | 78.7k | pub fn take_while1<F, Input, Error: ParseError<Input>>( | 223 | 78.7k | cond: F, | 224 | 78.7k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 225 | 78.7k | where | 226 | 78.7k | Input: InputTakeAtPosition, | 227 | 78.7k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 228 | | { | 229 | | move |i: Input| { | 230 | | let e: ErrorKind = ErrorKind::TakeWhile1; | 231 | | i.split_at_position1(|c| !cond(c), e) | 232 | | } | 233 | 78.7k | } |
Unexecuted instantiation: nom::bytes::streaming::take_while1::<_, _, _> |
234 | | |
235 | | /// Returns the longest (m <= len <= n) input slice that matches the predicate. |
236 | | /// |
237 | | /// The parser will return the longest slice that matches the given predicate *(a function that |
238 | | /// takes the input and returns a bool)*. |
239 | | /// |
240 | | /// It will return an `Err::Error((_, ErrorKind::TakeWhileMN))` if the pattern wasn't met. |
241 | | /// # Streaming Specific |
242 | | /// *Streaming version* will return a `Err::Incomplete(Needed::new(1))` if the pattern reaches the end of the input or is too short. |
243 | | /// |
244 | | /// # Example |
245 | | /// ```rust |
246 | | /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult}; |
247 | | /// use nom::bytes::streaming::take_while_m_n; |
248 | | /// use nom::character::is_alphabetic; |
249 | | /// |
250 | | /// fn short_alpha(s: &[u8]) -> IResult<&[u8], &[u8]> { |
251 | | /// take_while_m_n(3, 6, is_alphabetic)(s) |
252 | | /// } |
253 | | /// |
254 | | /// assert_eq!(short_alpha(b"latin123"), Ok((&b"123"[..], &b"latin"[..]))); |
255 | | /// assert_eq!(short_alpha(b"lengthy"), Ok((&b"y"[..], &b"length"[..]))); |
256 | | /// assert_eq!(short_alpha(b"latin"), Err(Err::Incomplete(Needed::new(1)))); |
257 | | /// assert_eq!(short_alpha(b"ed"), Err(Err::Incomplete(Needed::new(1)))); |
258 | | /// assert_eq!(short_alpha(b"12345"), Err(Err::Error(Error::new(&b"12345"[..], ErrorKind::TakeWhileMN)))); |
259 | | /// ``` |
260 | 41.1M | pub fn take_while_m_n<F, Input, Error: ParseError<Input>>( |
261 | 41.1M | m: usize, |
262 | 41.1M | n: usize, |
263 | 41.1M | cond: F, |
264 | 41.1M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> |
265 | 41.1M | where |
266 | 41.1M | Input: InputTake + InputIter + InputLength, |
267 | 41.1M | F: Fn(<Input as InputIter>::Item) -> bool, |
268 | | { |
269 | 41.1M | move |i: Input| { |
270 | 41.1M | let input = i; |
271 | | |
272 | 56.4M | match input.position(|c| !cond(c)) {Unexecuted instantiation: nom::bytes::streaming::take_while_m_n::<_, _, _>::{closure#0}::{closure#0}nom::bytes::streaming::take_while_m_n::<suricata::mqtt::parser::is_continuation_bit_set, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 272 | 56.4M | match input.position(|c| !cond(c)) { |
Unexecuted instantiation: nom::bytes::streaming::take_while_m_n::<_, _, _>::{closure#0}::{closure#0} |
273 | 41.0M | Some(idx) => { |
274 | 41.0M | if idx >= m { |
275 | 41.0M | if idx <= n { |
276 | 41.0M | let res: IResult<_, _, Error> = if let Ok(index) = input.slice_index(idx) { |
277 | 41.0M | Ok(input.take_split(index)) |
278 | | } else { |
279 | 0 | Err(Err::Error(Error::from_error_kind( |
280 | 0 | input, |
281 | 0 | ErrorKind::TakeWhileMN, |
282 | 0 | ))) |
283 | | }; |
284 | 41.0M | res |
285 | | } else { |
286 | 482 | let res: IResult<_, _, Error> = if let Ok(index) = input.slice_index(n) { |
287 | 482 | Ok(input.take_split(index)) |
288 | | } else { |
289 | 0 | Err(Err::Error(Error::from_error_kind( |
290 | 0 | input, |
291 | 0 | ErrorKind::TakeWhileMN, |
292 | 0 | ))) |
293 | | }; |
294 | 482 | res |
295 | | } |
296 | | } else { |
297 | 0 | let e = ErrorKind::TakeWhileMN; |
298 | 0 | Err(Err::Error(Error::from_error_kind(input, e))) |
299 | | } |
300 | | } |
301 | | None => { |
302 | 26.4k | let len = input.input_len(); |
303 | 26.4k | if len >= n { |
304 | 831 | match input.slice_index(n) { |
305 | 831 | Ok(index) => Ok(input.take_split(index)), |
306 | 0 | Err(_needed) => Err(Err::Error(Error::from_error_kind( |
307 | 0 | input, |
308 | 0 | ErrorKind::TakeWhileMN, |
309 | 0 | ))), |
310 | | } |
311 | | } else { |
312 | 25.5k | let needed = if m > len { m - len } else { 1 }; |
313 | 25.5k | Err(Err::Incomplete(Needed::new(needed))) |
314 | | } |
315 | | } |
316 | | } |
317 | 41.1M | } Unexecuted instantiation: nom::bytes::streaming::take_while_m_n::<_, _, _>::{closure#0}nom::bytes::streaming::take_while_m_n::<suricata::mqtt::parser::is_continuation_bit_set, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 269 | 41.1M | move |i: Input| { | 270 | 41.1M | let input = i; | 271 | | | 272 | 41.1M | match input.position(|c| !cond(c)) { | 273 | 41.0M | Some(idx) => { | 274 | 41.0M | if idx >= m { | 275 | 41.0M | if idx <= n { | 276 | 41.0M | let res: IResult<_, _, Error> = if let Ok(index) = input.slice_index(idx) { | 277 | 41.0M | Ok(input.take_split(index)) | 278 | | } else { | 279 | 0 | Err(Err::Error(Error::from_error_kind( | 280 | 0 | input, | 281 | 0 | ErrorKind::TakeWhileMN, | 282 | 0 | ))) | 283 | | }; | 284 | 41.0M | res | 285 | | } else { | 286 | 482 | let res: IResult<_, _, Error> = if let Ok(index) = input.slice_index(n) { | 287 | 482 | Ok(input.take_split(index)) | 288 | | } else { | 289 | 0 | Err(Err::Error(Error::from_error_kind( | 290 | 0 | input, | 291 | 0 | ErrorKind::TakeWhileMN, | 292 | 0 | ))) | 293 | | }; | 294 | 482 | res | 295 | | } | 296 | | } else { | 297 | 0 | let e = ErrorKind::TakeWhileMN; | 298 | 0 | Err(Err::Error(Error::from_error_kind(input, e))) | 299 | | } | 300 | | } | 301 | | None => { | 302 | 26.4k | let len = input.input_len(); | 303 | 26.4k | if len >= n { | 304 | 831 | match input.slice_index(n) { | 305 | 831 | Ok(index) => Ok(input.take_split(index)), | 306 | 0 | Err(_needed) => Err(Err::Error(Error::from_error_kind( | 307 | 0 | input, | 308 | 0 | ErrorKind::TakeWhileMN, | 309 | 0 | ))), | 310 | | } | 311 | | } else { | 312 | 25.5k | let needed = if m > len { m - len } else { 1 }; | 313 | 25.5k | Err(Err::Incomplete(Needed::new(needed))) | 314 | | } | 315 | | } | 316 | | } | 317 | 41.1M | } |
Unexecuted instantiation: nom::bytes::streaming::take_while_m_n::<_, _, _>::{closure#0} |
318 | 41.1M | } Unexecuted instantiation: nom::bytes::streaming::take_while_m_n::<_, _, _> nom::bytes::streaming::take_while_m_n::<suricata::mqtt::parser::is_continuation_bit_set, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 260 | 41.1M | pub fn take_while_m_n<F, Input, Error: ParseError<Input>>( | 261 | 41.1M | m: usize, | 262 | 41.1M | n: usize, | 263 | 41.1M | cond: F, | 264 | 41.1M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 265 | 41.1M | where | 266 | 41.1M | Input: InputTake + InputIter + InputLength, | 267 | 41.1M | F: Fn(<Input as InputIter>::Item) -> bool, | 268 | | { | 269 | | move |i: Input| { | 270 | | let input = i; | 271 | | | 272 | | match input.position(|c| !cond(c)) { | 273 | | Some(idx) => { | 274 | | if idx >= m { | 275 | | if idx <= n { | 276 | | let res: IResult<_, _, Error> = if let Ok(index) = input.slice_index(idx) { | 277 | | Ok(input.take_split(index)) | 278 | | } else { | 279 | | Err(Err::Error(Error::from_error_kind( | 280 | | input, | 281 | | ErrorKind::TakeWhileMN, | 282 | | ))) | 283 | | }; | 284 | | res | 285 | | } else { | 286 | | let res: IResult<_, _, Error> = if let Ok(index) = input.slice_index(n) { | 287 | | Ok(input.take_split(index)) | 288 | | } else { | 289 | | Err(Err::Error(Error::from_error_kind( | 290 | | input, | 291 | | ErrorKind::TakeWhileMN, | 292 | | ))) | 293 | | }; | 294 | | res | 295 | | } | 296 | | } else { | 297 | | let e = ErrorKind::TakeWhileMN; | 298 | | Err(Err::Error(Error::from_error_kind(input, e))) | 299 | | } | 300 | | } | 301 | | None => { | 302 | | let len = input.input_len(); | 303 | | if len >= n { | 304 | | match input.slice_index(n) { | 305 | | Ok(index) => Ok(input.take_split(index)), | 306 | | Err(_needed) => Err(Err::Error(Error::from_error_kind( | 307 | | input, | 308 | | ErrorKind::TakeWhileMN, | 309 | | ))), | 310 | | } | 311 | | } else { | 312 | | let needed = if m > len { m - len } else { 1 }; | 313 | | Err(Err::Incomplete(Needed::new(needed))) | 314 | | } | 315 | | } | 316 | | } | 317 | | } | 318 | 41.1M | } |
Unexecuted instantiation: nom::bytes::streaming::take_while_m_n::<_, _, _> |
319 | | |
320 | | /// Returns the longest input slice (if any) till a predicate is met. |
321 | | /// |
322 | | /// The parser will return the longest slice till the given predicate *(a function that |
323 | | /// takes the input and returns a bool)*. |
324 | | /// |
325 | | /// # Streaming Specific |
326 | | /// *Streaming version* will return a `Err::Incomplete(Needed::new(1))` if the match reaches the |
327 | | /// end of input or if there was not match. |
328 | | /// |
329 | | /// # Example |
330 | | /// ```rust |
331 | | /// # use nom::{Err, error::ErrorKind, Needed, IResult}; |
332 | | /// use nom::bytes::streaming::take_till; |
333 | | /// |
334 | | /// fn till_colon(s: &str) -> IResult<&str, &str> { |
335 | | /// take_till(|c| c == ':')(s) |
336 | | /// } |
337 | | /// |
338 | | /// assert_eq!(till_colon("latin:123"), Ok((":123", "latin"))); |
339 | | /// assert_eq!(till_colon(":empty matched"), Ok((":empty matched", ""))); //allowed |
340 | | /// assert_eq!(till_colon("12345"), Err(Err::Incomplete(Needed::new(1)))); |
341 | | /// assert_eq!(till_colon(""), Err(Err::Incomplete(Needed::new(1)))); |
342 | | /// ``` |
343 | 137k | pub fn take_till<F, Input, Error: ParseError<Input>>( |
344 | 137k | cond: F, |
345 | 137k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> |
346 | 137k | where |
347 | 137k | Input: InputTakeAtPosition, |
348 | 137k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, |
349 | | { |
350 | 3.11M | move |i: Input| i.split_at_position(|c| cond(c)) nom::bytes::streaming::take_till::<suricata::http2::range::http2_parse_content_range::{closure#1}, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 350 | 109k | move |i: Input| i.split_at_position(|c| cond(c)) |
Unexecuted instantiation: nom::bytes::streaming::take_till::<_, _, _>::{closure#0}nom::bytes::streaming::take_till::<suricata::http2::range::http2_parse_content_range::{closure#1}, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 350 | 28.2k | move |i: Input| i.split_at_position(|c| cond(c)) |
Unexecuted instantiation: nom::bytes::streaming::take_till::<_, _, _>::{closure#0}nom::bytes::streaming::take_till::<suricata::http2::range::http2_parse_content_range::{closure#1}, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 350 | 2.02M | move |i: Input| i.split_at_position(|c| cond(c)) |
Unexecuted instantiation: nom::bytes::streaming::take_till::<_, _, _>::{closure#0}::{closure#0}nom::bytes::streaming::take_till::<suricata::http2::range::http2_parse_content_range::{closure#1}, &[u8], nom::error::Error<&[u8]>>::{closure#0}::{closure#0}Line | Count | Source | 350 | 1.09M | move |i: Input| i.split_at_position(|c| cond(c)) |
Unexecuted instantiation: nom::bytes::streaming::take_till::<_, _, _>::{closure#0}::{closure#0} |
351 | 137k | } nom::bytes::streaming::take_till::<suricata::http2::range::http2_parse_content_range::{closure#1}, &[u8], nom::error::Error<&[u8]>>Line | Count | Source | 343 | 109k | pub fn take_till<F, Input, Error: ParseError<Input>>( | 344 | 109k | cond: F, | 345 | 109k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 346 | 109k | where | 347 | 109k | Input: InputTakeAtPosition, | 348 | 109k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 349 | | { | 350 | | move |i: Input| i.split_at_position(|c| cond(c)) | 351 | 109k | } |
Unexecuted instantiation: nom::bytes::streaming::take_till::<_, _, _> nom::bytes::streaming::take_till::<suricata::http2::range::http2_parse_content_range::{closure#1}, &[u8], nom::error::Error<&[u8]>>Line | Count | Source | 343 | 28.2k | pub fn take_till<F, Input, Error: ParseError<Input>>( | 344 | 28.2k | cond: F, | 345 | 28.2k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 346 | 28.2k | where | 347 | 28.2k | Input: InputTakeAtPosition, | 348 | 28.2k | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, | 349 | | { | 350 | | move |i: Input| i.split_at_position(|c| cond(c)) | 351 | 28.2k | } |
Unexecuted instantiation: nom::bytes::streaming::take_till::<_, _, _> |
352 | | |
353 | | /// Returns the longest (at least 1) input slice till a predicate is met. |
354 | | /// |
355 | | /// The parser will return the longest slice till the given predicate *(a function that |
356 | | /// takes the input and returns a bool)*. |
357 | | /// |
358 | | /// # Streaming Specific |
359 | | /// *Streaming version* will return a `Err::Incomplete(Needed::new(1))` if the match reaches the |
360 | | /// end of input or if there was not match. |
361 | | /// # Example |
362 | | /// ```rust |
363 | | /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult}; |
364 | | /// use nom::bytes::streaming::take_till1; |
365 | | /// |
366 | | /// fn till_colon(s: &str) -> IResult<&str, &str> { |
367 | | /// take_till1(|c| c == ':')(s) |
368 | | /// } |
369 | | /// |
370 | | /// assert_eq!(till_colon("latin:123"), Ok((":123", "latin"))); |
371 | | /// assert_eq!(till_colon(":empty matched"), Err(Err::Error(Error::new(":empty matched", ErrorKind::TakeTill1)))); |
372 | | /// assert_eq!(till_colon("12345"), Err(Err::Incomplete(Needed::new(1)))); |
373 | | /// assert_eq!(till_colon(""), Err(Err::Incomplete(Needed::new(1)))); |
374 | | /// ``` |
375 | 0 | pub fn take_till1<F, Input, Error: ParseError<Input>>( |
376 | 0 | cond: F, |
377 | 0 | ) -> impl Fn(Input) -> IResult<Input, Input, Error> |
378 | 0 | where |
379 | 0 | Input: InputTakeAtPosition, |
380 | 0 | F: Fn(<Input as InputTakeAtPosition>::Item) -> bool, |
381 | | { |
382 | 0 | move |i: Input| { |
383 | 0 | let e: ErrorKind = ErrorKind::TakeTill1; |
384 | 0 | i.split_at_position1(|c| cond(c), e) Unexecuted instantiation: nom::bytes::streaming::take_till1::<_, _, _>::{closure#0}::{closure#0}Unexecuted instantiation: nom::bytes::streaming::take_till1::<_, _, _>::{closure#0}::{closure#0} |
385 | 0 | } Unexecuted instantiation: nom::bytes::streaming::take_till1::<_, _, _>::{closure#0}Unexecuted instantiation: nom::bytes::streaming::take_till1::<_, _, _>::{closure#0} |
386 | 0 | } Unexecuted instantiation: nom::bytes::streaming::take_till1::<_, _, _> Unexecuted instantiation: nom::bytes::streaming::take_till1::<_, _, _> |
387 | | |
388 | | /// Returns an input slice containing the first N input elements (Input[..N]). |
389 | | /// |
390 | | /// # Streaming Specific |
391 | | /// *Streaming version* if the input has less than N elements, `take` will |
392 | | /// return a `Err::Incomplete(Needed::new(M))` where M is the number of |
393 | | /// additional bytes the parser would need to succeed. |
394 | | /// It is well defined for `&[u8]` as the number of elements is the byte size, |
395 | | /// but for types like `&str`, we cannot know how many bytes correspond for |
396 | | /// the next few chars, so the result will be `Err::Incomplete(Needed::Unknown)` |
397 | | /// |
398 | | /// # Example |
399 | | /// ```rust |
400 | | /// # use nom::{Err, error::ErrorKind, Needed, IResult}; |
401 | | /// use nom::bytes::streaming::take; |
402 | | /// |
403 | | /// fn take6(s: &str) -> IResult<&str, &str> { |
404 | | /// take(6usize)(s) |
405 | | /// } |
406 | | /// |
407 | | /// assert_eq!(take6("1234567"), Ok(("7", "123456"))); |
408 | | /// assert_eq!(take6("things"), Ok(("", "things"))); |
409 | | /// assert_eq!(take6("short"), Err(Err::Incomplete(Needed::Unknown))); |
410 | | /// ``` |
411 | 128M | pub fn take<C, Input, Error: ParseError<Input>>( |
412 | 128M | count: C, |
413 | 128M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> |
414 | 128M | where |
415 | 128M | Input: InputIter + InputTake + InputLength, |
416 | 128M | C: ToUsize, |
417 | | { |
418 | 128M | let c = count.to_usize(); |
419 | 126M | move |i: Input| match i.slice_index(c) { |
420 | 6.20M | Err(i) => Err(Err::Incomplete(i)), |
421 | 120M | Ok(index) => Ok(i.take_split(index)), |
422 | 126M | } nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 15.9M | move |i: Input| match i.slice_index(c) { | 420 | 324k | Err(i) => Err(Err::Incomplete(i)), | 421 | 15.5M | Ok(index) => Ok(i.take_split(index)), | 422 | 15.9M | } |
nom::bytes::streaming::take::<usize, &[u8], suricata::kerberos::SecBlobError>::{closure#0}Line | Count | Source | 419 | 71.7k | move |i: Input| match i.slice_index(c) { | 420 | 949 | Err(i) => Err(Err::Incomplete(i)), | 421 | 70.7k | Ok(index) => Ok(i.take_split(index)), | 422 | 71.7k | } |
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 345k | move |i: Input| match i.slice_index(c) { | 420 | 4.38k | Err(i) => Err(Err::Incomplete(i)), | 421 | 341k | Ok(index) => Ok(i.take_split(index)), | 422 | 345k | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 351k | move |i: Input| match i.slice_index(c) { | 420 | 17.3k | Err(i) => Err(Err::Incomplete(i)), | 421 | 334k | Ok(index) => Ok(i.take_split(index)), | 422 | 351k | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 2.62M | move |i: Input| match i.slice_index(c) { | 420 | 2.92k | Err(i) => Err(Err::Incomplete(i)), | 421 | 2.62M | Ok(index) => Ok(i.take_split(index)), | 422 | 2.62M | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 50.3k | move |i: Input| match i.slice_index(c) { | 420 | 36.3k | Err(i) => Err(Err::Incomplete(i)), | 421 | 13.9k | Ok(index) => Ok(i.take_split(index)), | 422 | 50.3k | } |
nom::bytes::streaming::take::<u8, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 16.2k | move |i: Input| match i.slice_index(c) { | 420 | 7.23k | Err(i) => Err(Err::Incomplete(i)), | 421 | 8.99k | Ok(index) => Ok(i.take_split(index)), | 422 | 16.2k | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 39.7k | move |i: Input| match i.slice_index(c) { | 420 | 1.35k | Err(i) => Err(Err::Incomplete(i)), | 421 | 38.3k | Ok(index) => Ok(i.take_split(index)), | 422 | 39.7k | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 5.44M | move |i: Input| match i.slice_index(c) { | 420 | 32.5k | Err(i) => Err(Err::Incomplete(i)), | 421 | 5.41M | Ok(index) => Ok(i.take_split(index)), | 422 | 5.44M | } |
Unexecuted instantiation: nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>::{closure#0}nom::bytes::streaming::take::<usize, &[u8], ldap_parser::error::LdapError>::{closure#0}Line | Count | Source | 419 | 1.43k | move |i: Input| match i.slice_index(c) { | 420 | 421 | Err(i) => Err(Err::Incomplete(i)), | 421 | 1.01k | Ok(index) => Ok(i.take_split(index)), | 422 | 1.43k | } |
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>::{closure#0}Line | Count | Source | 419 | 5.50M | move |i: Input| match i.slice_index(c) { | 420 | 88.4k | Err(i) => Err(Err::Incomplete(i)), | 421 | 5.41M | Ok(index) => Ok(i.take_split(index)), | 422 | 5.50M | } |
nom::bytes::streaming::take::<u8, &[u8], asn1_rs::error::Error>::{closure#0}Line | Count | Source | 419 | 370k | move |i: Input| match i.slice_index(c) { | 420 | 18.9k | Err(i) => Err(Err::Incomplete(i)), | 421 | 351k | Ok(index) => Ok(i.take_split(index)), | 422 | 370k | } |
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>::{closure#0}Line | Count | Source | 419 | 7.16k | move |i: Input| match i.slice_index(c) { | 420 | 7 | Err(i) => Err(Err::Incomplete(i)), | 421 | 7.15k | Ok(index) => Ok(i.take_split(index)), | 422 | 7.16k | } |
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 440k | move |i: Input| match i.slice_index(c) { | 420 | 14.5k | Err(i) => Err(Err::Incomplete(i)), | 421 | 426k | Ok(index) => Ok(i.take_split(index)), | 422 | 440k | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 627k | move |i: Input| match i.slice_index(c) { | 420 | 35.5k | Err(i) => Err(Err::Incomplete(i)), | 421 | 591k | Ok(index) => Ok(i.take_split(index)), | 422 | 627k | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 15.1k | move |i: Input| match i.slice_index(c) { | 420 | 297 | Err(i) => Err(Err::Incomplete(i)), | 421 | 14.8k | Ok(index) => Ok(i.take_split(index)), | 422 | 15.1k | } |
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>::{closure#0}Line | Count | Source | 419 | 384k | move |i: Input| match i.slice_index(c) { | 420 | 11.0k | Err(i) => Err(Err::Incomplete(i)), | 421 | 373k | Ok(index) => Ok(i.take_split(index)), | 422 | 384k | } |
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>::{closure#0}Line | Count | Source | 419 | 16.7M | move |i: Input| match i.slice_index(c) { | 420 | 61.3k | Err(i) => Err(Err::Incomplete(i)), | 421 | 16.7M | Ok(index) => Ok(i.take_split(index)), | 422 | 16.7M | } |
nom::bytes::streaming::take::<u8, &[u8], asn1_rs::error::Error>::{closure#0}Line | Count | Source | 419 | 218k | move |i: Input| match i.slice_index(c) { | 420 | 52.9k | Err(i) => Err(Err::Incomplete(i)), | 421 | 165k | Ok(index) => Ok(i.take_split(index)), | 422 | 218k | } |
Unexecuted instantiation: nom::bytes::streaming::take::<_, _, _>::{closure#0}nom::bytes::streaming::take::<u8, &[u8], suricata::rdp::error::RdpError>::{closure#0}Line | Count | Source | 419 | 82.0k | move |i: Input| match i.slice_index(c) { | 420 | 738 | Err(i) => Err(Err::Incomplete(i)), | 421 | 81.3k | Ok(index) => Ok(i.take_split(index)), | 422 | 82.0k | } |
nom::bytes::streaming::take::<usize, &[u8], suricata::kerberos::SecBlobError>::{closure#0}Line | Count | Source | 419 | 58.2k | move |i: Input| match i.slice_index(c) { | 420 | 661 | Err(i) => Err(Err::Incomplete(i)), | 421 | 57.5k | Ok(index) => Ok(i.take_split(index)), | 422 | 58.2k | } |
nom::bytes::streaming::take::<u16, &[u8], suricata::rdp::error::RdpError>::{closure#0}Line | Count | Source | 419 | 2.24M | move |i: Input| match i.slice_index(c) { | 420 | 12.8k | Err(i) => Err(Err::Incomplete(i)), | 421 | 2.22M | Ok(index) => Ok(i.take_split(index)), | 422 | 2.24M | } |
nom::bytes::streaming::take::<u8, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 4.91M | move |i: Input| match i.slice_index(c) { | 420 | 6.21k | Err(i) => Err(Err::Incomplete(i)), | 421 | 4.90M | Ok(index) => Ok(i.take_split(index)), | 422 | 4.91M | } |
nom::bytes::streaming::take::<usize, &[u8], suricata::smb::error::SmbError>::{closure#0}Line | Count | Source | 419 | 1.02M | move |i: Input| match i.slice_index(c) { | 420 | 109k | Err(i) => Err(Err::Incomplete(i)), | 421 | 914k | Ok(index) => Ok(i.take_split(index)), | 422 | 1.02M | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 3.78M | move |i: Input| match i.slice_index(c) { | 420 | 186k | Err(i) => Err(Err::Incomplete(i)), | 421 | 3.60M | Ok(index) => Ok(i.take_split(index)), | 422 | 3.78M | } |
nom::bytes::streaming::take::<u16, &[u8], suricata::smb::error::SmbError>::{closure#0}Line | Count | Source | 419 | 283k | move |i: Input| match i.slice_index(c) { | 420 | 198k | Err(i) => Err(Err::Incomplete(i)), | 421 | 85.6k | Ok(index) => Ok(i.take_split(index)), | 422 | 283k | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 34.1M | move |i: Input| match i.slice_index(c) { | 420 | 3.94M | Err(i) => Err(Err::Incomplete(i)), | 421 | 30.2M | Ok(index) => Ok(i.take_split(index)), | 422 | 34.1M | } |
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 2.71M | move |i: Input| match i.slice_index(c) { | 420 | 631k | Err(i) => Err(Err::Incomplete(i)), | 421 | 2.08M | Ok(index) => Ok(i.take_split(index)), | 422 | 2.71M | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 650k | move |i: Input| match i.slice_index(c) { | 420 | 39.5k | Err(i) => Err(Err::Incomplete(i)), | 421 | 610k | Ok(index) => Ok(i.take_split(index)), | 422 | 650k | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 3.01M | move |i: Input| match i.slice_index(c) { | 420 | 2.96k | Err(i) => Err(Err::Incomplete(i)), | 421 | 3.00M | Ok(index) => Ok(i.take_split(index)), | 422 | 3.01M | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 52.0k | move |i: Input| match i.slice_index(c) { | 420 | 38.9k | Err(i) => Err(Err::Incomplete(i)), | 421 | 13.0k | Ok(index) => Ok(i.take_split(index)), | 422 | 52.0k | } |
nom::bytes::streaming::take::<u8, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 22.2k | move |i: Input| match i.slice_index(c) { | 420 | 3.66k | Err(i) => Err(Err::Incomplete(i)), | 421 | 18.5k | Ok(index) => Ok(i.take_split(index)), | 422 | 22.2k | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 38.3k | move |i: Input| match i.slice_index(c) { | 420 | 2.97k | Err(i) => Err(Err::Incomplete(i)), | 421 | 35.3k | Ok(index) => Ok(i.take_split(index)), | 422 | 38.3k | } |
Unexecuted instantiation: nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>::{closure#0}nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 6.01M | move |i: Input| match i.slice_index(c) { | 420 | 57.0k | Err(i) => Err(Err::Incomplete(i)), | 421 | 5.95M | Ok(index) => Ok(i.take_split(index)), | 422 | 6.01M | } |
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>::{closure#0}Line | Count | Source | 419 | 7.64k | move |i: Input| match i.slice_index(c) { | 420 | 12 | Err(i) => Err(Err::Incomplete(i)), | 421 | 7.63k | Ok(index) => Ok(i.take_split(index)), | 422 | 7.64k | } |
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 393k | move |i: Input| match i.slice_index(c) { | 420 | 25.6k | Err(i) => Err(Err::Incomplete(i)), | 421 | 368k | Ok(index) => Ok(i.take_split(index)), | 422 | 393k | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 577k | move |i: Input| match i.slice_index(c) { | 420 | 28.4k | Err(i) => Err(Err::Incomplete(i)), | 421 | 548k | Ok(index) => Ok(i.take_split(index)), | 422 | 577k | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 16.3k | move |i: Input| match i.slice_index(c) { | 420 | 343 | Err(i) => Err(Err::Incomplete(i)), | 421 | 16.0k | Ok(index) => Ok(i.take_split(index)), | 422 | 16.3k | } |
nom::bytes::streaming::take::<usize, &[u8], der_parser::error::BerError>::{closure#0}Line | Count | Source | 419 | 2.14M | move |i: Input| match i.slice_index(c) { | 420 | 104k | Err(i) => Err(Err::Incomplete(i)), | 421 | 2.04M | Ok(index) => Ok(i.take_split(index)), | 422 | 2.14M | } |
nom::bytes::streaming::take::<u8, &[u8], der_parser::error::BerError>::{closure#0}Line | Count | Source | 419 | 94.4k | move |i: Input| match i.slice_index(c) { | 420 | 45.7k | Err(i) => Err(Err::Incomplete(i)), | 421 | 48.6k | Ok(index) => Ok(i.take_split(index)), | 422 | 94.4k | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 419 | 11.7k | move |i: Input| match i.slice_index(c) { | 420 | 0 | Err(i) => Err(Err::Incomplete(i)), | 421 | 11.7k | Ok(index) => Ok(i.take_split(index)), | 422 | 11.7k | } |
nom::bytes::streaming::take::<usize, &[u8], der_parser::error::BerError>::{closure#0}Line | Count | Source | 419 | 1.13M | move |i: Input| match i.slice_index(c) { | 420 | 32.3k | Err(i) => Err(Err::Incomplete(i)), | 421 | 1.10M | Ok(index) => Ok(i.take_split(index)), | 422 | 1.13M | } |
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>::{closure#0}Line | Count | Source | 419 | 199k | move |i: Input| match i.slice_index(c) { | 420 | 0 | Err(i) => Err(Err::Incomplete(i)), | 421 | 199k | Ok(index) => Ok(i.take_split(index)), | 422 | 199k | } |
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>::{closure#0}Line | Count | Source | 419 | 13.2M | move |i: Input| match i.slice_index(c) { | 420 | 19.5k | Err(i) => Err(Err::Incomplete(i)), | 421 | 13.2M | Ok(index) => Ok(i.take_split(index)), | 422 | 13.2M | } |
nom::bytes::streaming::take::<u8, &[u8], asn1_rs::error::Error>::{closure#0}Line | Count | Source | 419 | 85.2k | move |i: Input| match i.slice_index(c) { | 420 | 5.57k | Err(i) => Err(Err::Incomplete(i)), | 421 | 79.7k | Ok(index) => Ok(i.take_split(index)), | 422 | 85.2k | } |
Unexecuted instantiation: nom::bytes::streaming::take::<_, _, _>::{closure#0} |
423 | 128M | } nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 16.4M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 16.4M | count: C, | 413 | 16.4M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 16.4M | where | 415 | 16.4M | Input: InputIter + InputTake + InputLength, | 416 | 16.4M | C: ToUsize, | 417 | | { | 418 | 16.4M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 16.4M | } |
nom::bytes::streaming::take::<usize, &[u8], suricata::kerberos::SecBlobError> Line | Count | Source | 411 | 71.7k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 71.7k | count: C, | 413 | 71.7k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 71.7k | where | 415 | 71.7k | Input: InputIter + InputTake + InputLength, | 416 | 71.7k | C: ToUsize, | 417 | | { | 418 | 71.7k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 71.7k | } |
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 408k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 408k | count: C, | 413 | 408k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 408k | where | 415 | 408k | Input: InputIter + InputTake + InputLength, | 416 | 408k | C: ToUsize, | 417 | | { | 418 | 408k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 408k | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 351k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 351k | count: C, | 413 | 351k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 351k | where | 415 | 351k | Input: InputIter + InputTake + InputLength, | 416 | 351k | C: ToUsize, | 417 | | { | 418 | 351k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 351k | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 50.3k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 50.3k | count: C, | 413 | 50.3k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 50.3k | where | 415 | 50.3k | Input: InputIter + InputTake + InputLength, | 416 | 50.3k | C: ToUsize, | 417 | | { | 418 | 50.3k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 50.3k | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 2.62M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 2.62M | count: C, | 413 | 2.62M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 2.62M | where | 415 | 2.62M | Input: InputIter + InputTake + InputLength, | 416 | 2.62M | C: ToUsize, | 417 | | { | 418 | 2.62M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 2.62M | } |
nom::bytes::streaming::take::<u8, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 581k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 581k | count: C, | 413 | 581k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 581k | where | 415 | 581k | Input: InputIter + InputTake + InputLength, | 416 | 581k | C: ToUsize, | 417 | | { | 418 | 581k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 581k | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 39.7k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 39.7k | count: C, | 413 | 39.7k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 39.7k | where | 415 | 39.7k | Input: InputIter + InputTake + InputLength, | 416 | 39.7k | C: ToUsize, | 417 | | { | 418 | 39.7k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 39.7k | } |
Unexecuted instantiation: nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>> nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 5.44M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 5.44M | count: C, | 413 | 5.44M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 5.44M | where | 415 | 5.44M | Input: InputIter + InputTake + InputLength, | 416 | 5.44M | C: ToUsize, | 417 | | { | 418 | 5.44M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 5.44M | } |
nom::bytes::streaming::take::<usize, &[u8], ldap_parser::error::LdapError> Line | Count | Source | 411 | 1.43k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 1.43k | count: C, | 413 | 1.43k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 1.43k | where | 415 | 1.43k | Input: InputIter + InputTake + InputLength, | 416 | 1.43k | C: ToUsize, | 417 | | { | 418 | 1.43k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 1.43k | } |
nom::bytes::streaming::take::<u8, &[u8], asn1_rs::error::Error> Line | Count | Source | 411 | 370k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 370k | count: C, | 413 | 370k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 370k | where | 415 | 370k | Input: InputIter + InputTake + InputLength, | 416 | 370k | C: ToUsize, | 417 | | { | 418 | 370k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 370k | } |
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error> Line | Count | Source | 411 | 5.50M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 5.50M | count: C, | 413 | 5.50M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 5.50M | where | 415 | 5.50M | Input: InputIter + InputTake + InputLength, | 416 | 5.50M | C: ToUsize, | 417 | | { | 418 | 5.50M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 5.50M | } |
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error> Line | Count | Source | 411 | 7.16k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 7.16k | count: C, | 413 | 7.16k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 7.16k | where | 415 | 7.16k | Input: InputIter + InputTake + InputLength, | 416 | 7.16k | C: ToUsize, | 417 | | { | 418 | 7.16k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 7.16k | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 670k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 670k | count: C, | 413 | 670k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 670k | where | 415 | 670k | Input: InputIter + InputTake + InputLength, | 416 | 670k | C: ToUsize, | 417 | | { | 418 | 670k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 670k | } |
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 440k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 440k | count: C, | 413 | 440k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 440k | where | 415 | 440k | Input: InputIter + InputTake + InputLength, | 416 | 440k | C: ToUsize, | 417 | | { | 418 | 440k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 440k | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 15.1k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 15.1k | count: C, | 413 | 15.1k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 15.1k | where | 415 | 15.1k | Input: InputIter + InputTake + InputLength, | 416 | 15.1k | C: ToUsize, | 417 | | { | 418 | 15.1k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 15.1k | } |
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error> Line | Count | Source | 411 | 384k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 384k | count: C, | 413 | 384k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 384k | where | 415 | 384k | Input: InputIter + InputTake + InputLength, | 416 | 384k | C: ToUsize, | 417 | | { | 418 | 384k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 384k | } |
nom::bytes::streaming::take::<u8, &[u8], asn1_rs::error::Error> Line | Count | Source | 411 | 218k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 218k | count: C, | 413 | 218k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 218k | where | 415 | 218k | Input: InputIter + InputTake + InputLength, | 416 | 218k | C: ToUsize, | 417 | | { | 418 | 218k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 218k | } |
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error> Line | Count | Source | 411 | 16.7M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 16.7M | count: C, | 413 | 16.7M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 16.7M | where | 415 | 16.7M | Input: InputIter + InputTake + InputLength, | 416 | 16.7M | C: ToUsize, | 417 | | { | 418 | 16.7M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 16.7M | } |
Unexecuted instantiation: nom::bytes::streaming::take::<_, _, _> nom::bytes::streaming::take::<u8, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 4.91M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 4.91M | count: C, | 413 | 4.91M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 4.91M | where | 415 | 4.91M | Input: InputIter + InputTake + InputLength, | 416 | 4.91M | C: ToUsize, | 417 | | { | 418 | 4.91M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 4.91M | } |
nom::bytes::streaming::take::<u8, &[u8], suricata::rdp::error::RdpError> Line | Count | Source | 411 | 82.0k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 82.0k | count: C, | 413 | 82.0k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 82.0k | where | 415 | 82.0k | Input: InputIter + InputTake + InputLength, | 416 | 82.0k | C: ToUsize, | 417 | | { | 418 | 82.0k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 82.0k | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 35.2M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 35.2M | count: C, | 413 | 35.2M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 35.2M | where | 415 | 35.2M | Input: InputIter + InputTake + InputLength, | 416 | 35.2M | C: ToUsize, | 417 | | { | 418 | 35.2M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 35.2M | } |
nom::bytes::streaming::take::<usize, &[u8], suricata::kerberos::SecBlobError> Line | Count | Source | 411 | 58.2k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 58.2k | count: C, | 413 | 58.2k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 58.2k | where | 415 | 58.2k | Input: InputIter + InputTake + InputLength, | 416 | 58.2k | C: ToUsize, | 417 | | { | 418 | 58.2k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 58.2k | } |
nom::bytes::streaming::take::<usize, &[u8], suricata::smb::error::SmbError> Line | Count | Source | 411 | 1.03M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 1.03M | count: C, | 413 | 1.03M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 1.03M | where | 415 | 1.03M | Input: InputIter + InputTake + InputLength, | 416 | 1.03M | C: ToUsize, | 417 | | { | 418 | 1.03M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 1.03M | } |
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 2.79M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 2.79M | count: C, | 413 | 2.79M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 2.79M | where | 415 | 2.79M | Input: InputIter + InputTake + InputLength, | 416 | 2.79M | C: ToUsize, | 417 | | { | 418 | 2.79M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 2.79M | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 3.86M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 3.86M | count: C, | 413 | 3.86M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 3.86M | where | 415 | 3.86M | Input: InputIter + InputTake + InputLength, | 416 | 3.86M | C: ToUsize, | 417 | | { | 418 | 3.86M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 3.86M | } |
nom::bytes::streaming::take::<u16, &[u8], suricata::rdp::error::RdpError> Line | Count | Source | 411 | 2.24M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 2.24M | count: C, | 413 | 2.24M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 2.24M | where | 415 | 2.24M | Input: InputIter + InputTake + InputLength, | 416 | 2.24M | C: ToUsize, | 417 | | { | 418 | 2.24M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 2.24M | } |
nom::bytes::streaming::take::<u16, &[u8], suricata::smb::error::SmbError> Line | Count | Source | 411 | 283k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 283k | count: C, | 413 | 283k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 283k | where | 415 | 283k | Input: InputIter + InputTake + InputLength, | 416 | 283k | C: ToUsize, | 417 | | { | 418 | 283k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 283k | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 650k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 650k | count: C, | 413 | 650k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 650k | where | 415 | 650k | Input: InputIter + InputTake + InputLength, | 416 | 650k | C: ToUsize, | 417 | | { | 418 | 650k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 650k | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 52.0k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 52.0k | count: C, | 413 | 52.0k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 52.0k | where | 415 | 52.0k | Input: InputIter + InputTake + InputLength, | 416 | 52.0k | C: ToUsize, | 417 | | { | 418 | 52.0k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 52.0k | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 3.01M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 3.01M | count: C, | 413 | 3.01M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 3.01M | where | 415 | 3.01M | Input: InputIter + InputTake + InputLength, | 416 | 3.01M | C: ToUsize, | 417 | | { | 418 | 3.01M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 3.01M | } |
nom::bytes::streaming::take::<u8, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 208k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 208k | count: C, | 413 | 208k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 208k | where | 415 | 208k | Input: InputIter + InputTake + InputLength, | 416 | 208k | C: ToUsize, | 417 | | { | 418 | 208k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 208k | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 38.3k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 38.3k | count: C, | 413 | 38.3k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 38.3k | where | 415 | 38.3k | Input: InputIter + InputTake + InputLength, | 416 | 38.3k | C: ToUsize, | 417 | | { | 418 | 38.3k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 38.3k | } |
Unexecuted instantiation: nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>> nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 6.01M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 6.01M | count: C, | 413 | 6.01M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 6.01M | where | 415 | 6.01M | Input: InputIter + InputTake + InputLength, | 416 | 6.01M | C: ToUsize, | 417 | | { | 418 | 6.01M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 6.01M | } |
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error> Line | Count | Source | 411 | 7.64k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 7.64k | count: C, | 413 | 7.64k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 7.64k | where | 415 | 7.64k | Input: InputIter + InputTake + InputLength, | 416 | 7.64k | C: ToUsize, | 417 | | { | 418 | 7.64k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 7.64k | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 629k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 629k | count: C, | 413 | 629k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 629k | where | 415 | 629k | Input: InputIter + InputTake + InputLength, | 416 | 629k | C: ToUsize, | 417 | | { | 418 | 629k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 629k | } |
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 393k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 393k | count: C, | 413 | 393k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 393k | where | 415 | 393k | Input: InputIter + InputTake + InputLength, | 416 | 393k | C: ToUsize, | 417 | | { | 418 | 393k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 393k | } |
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 16.3k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 16.3k | count: C, | 413 | 16.3k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 16.3k | where | 415 | 16.3k | Input: InputIter + InputTake + InputLength, | 416 | 16.3k | C: ToUsize, | 417 | | { | 418 | 16.3k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 16.3k | } |
nom::bytes::streaming::take::<usize, &[u8], der_parser::error::BerError> Line | Count | Source | 411 | 2.14M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 2.14M | count: C, | 413 | 2.14M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 2.14M | where | 415 | 2.14M | Input: InputIter + InputTake + InputLength, | 416 | 2.14M | C: ToUsize, | 417 | | { | 418 | 2.14M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 2.14M | } |
nom::bytes::streaming::take::<u8, &[u8], der_parser::error::BerError> Line | Count | Source | 411 | 94.4k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 94.4k | count: C, | 413 | 94.4k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 94.4k | where | 415 | 94.4k | Input: InputIter + InputTake + InputLength, | 416 | 94.4k | C: ToUsize, | 417 | | { | 418 | 94.4k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 94.4k | } |
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 411 | 11.7k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 11.7k | count: C, | 413 | 11.7k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 11.7k | where | 415 | 11.7k | Input: InputIter + InputTake + InputLength, | 416 | 11.7k | C: ToUsize, | 417 | | { | 418 | 11.7k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 11.7k | } |
nom::bytes::streaming::take::<usize, &[u8], der_parser::error::BerError> Line | Count | Source | 411 | 1.13M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 1.13M | count: C, | 413 | 1.13M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 1.13M | where | 415 | 1.13M | Input: InputIter + InputTake + InputLength, | 416 | 1.13M | C: ToUsize, | 417 | | { | 418 | 1.13M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 1.13M | } |
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error> Line | Count | Source | 411 | 199k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 199k | count: C, | 413 | 199k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 199k | where | 415 | 199k | Input: InputIter + InputTake + InputLength, | 416 | 199k | C: ToUsize, | 417 | | { | 418 | 199k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 199k | } |
nom::bytes::streaming::take::<u8, &[u8], asn1_rs::error::Error> Line | Count | Source | 411 | 85.2k | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 85.2k | count: C, | 413 | 85.2k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 85.2k | where | 415 | 85.2k | Input: InputIter + InputTake + InputLength, | 416 | 85.2k | C: ToUsize, | 417 | | { | 418 | 85.2k | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 85.2k | } |
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error> Line | Count | Source | 411 | 13.2M | pub fn take<C, Input, Error: ParseError<Input>>( | 412 | 13.2M | count: C, | 413 | 13.2M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 414 | 13.2M | where | 415 | 13.2M | Input: InputIter + InputTake + InputLength, | 416 | 13.2M | C: ToUsize, | 417 | | { | 418 | 13.2M | let c = count.to_usize(); | 419 | | move |i: Input| match i.slice_index(c) { | 420 | | Err(i) => Err(Err::Incomplete(i)), | 421 | | Ok(index) => Ok(i.take_split(index)), | 422 | | } | 423 | 13.2M | } |
Unexecuted instantiation: nom::bytes::streaming::take::<_, _, _> |
424 | | |
425 | | /// Returns the input slice up to the first occurrence of the pattern. |
426 | | /// |
427 | | /// It doesn't consume the pattern. |
428 | | /// |
429 | | /// # Streaming Specific |
430 | | /// *Streaming version* will return a `Err::Incomplete(Needed::new(N))` if the input doesn't |
431 | | /// contain the pattern or if the input is smaller than the pattern. |
432 | | /// # Example |
433 | | /// ```rust |
434 | | /// # use nom::{Err, error::ErrorKind, Needed, IResult}; |
435 | | /// use nom::bytes::streaming::take_until; |
436 | | /// |
437 | | /// fn until_eof(s: &str) -> IResult<&str, &str> { |
438 | | /// take_until("eof")(s) |
439 | | /// } |
440 | | /// |
441 | | /// assert_eq!(until_eof("hello, worldeof"), Ok(("eof", "hello, world"))); |
442 | | /// assert_eq!(until_eof("hello, world"), Err(Err::Incomplete(Needed::Unknown))); |
443 | | /// assert_eq!(until_eof("hello, worldeo"), Err(Err::Incomplete(Needed::Unknown))); |
444 | | /// assert_eq!(until_eof("1eof2eof"), Ok(("eof2eof", "1"))); |
445 | | /// ``` |
446 | 24.8M | pub fn take_until<T, Input, Error: ParseError<Input>>( |
447 | 24.8M | tag: T, |
448 | 24.8M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> |
449 | 24.8M | where |
450 | 24.8M | Input: InputTake + InputLength + FindSubstring<T>, |
451 | 24.8M | T: Clone, |
452 | | { |
453 | 23.9M | move |i: Input| { |
454 | 23.9M | let t = tag.clone(); |
455 | | |
456 | 23.9M | let res: IResult<_, _, Error> = match i.find_substring(t) { |
457 | 1.23M | None => Err(Err::Incomplete(Needed::Unknown)), |
458 | 22.6M | Some(index) => Ok(i.take_split(index)), |
459 | | }; |
460 | 23.9M | res |
461 | 23.9M | } Unexecuted instantiation: nom::bytes::streaming::take_until::<_, _, _>::{closure#0}nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::rdp::error::RdpError>::{closure#0}Line | Count | Source | 453 | 33.2k | move |i: Input| { | 454 | 33.2k | let t = tag.clone(); | 455 | | | 456 | 33.2k | let res: IResult<_, _, Error> = match i.find_substring(t) { | 457 | 3.78k | None => Err(Err::Incomplete(Needed::Unknown)), | 458 | 29.5k | Some(index) => Ok(i.take_split(index)), | 459 | | }; | 460 | 33.2k | res | 461 | 33.2k | } |
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::smb::error::SmbError>::{closure#0}Line | Count | Source | 453 | 320k | move |i: Input| { | 454 | 320k | let t = tag.clone(); | 455 | | | 456 | 320k | let res: IResult<_, _, Error> = match i.find_substring(t) { | 457 | 65.2k | None => Err(Err::Incomplete(Needed::Unknown)), | 458 | 255k | Some(index) => Ok(i.take_split(index)), | 459 | | }; | 460 | 320k | res | 461 | 320k | } |
nom::bytes::streaming::take_until::<&[u8], &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 453 | 4.85M | move |i: Input| { | 454 | 4.85M | let t = tag.clone(); | 455 | | | 456 | 4.85M | let res: IResult<_, _, Error> = match i.find_substring(t) { | 457 | 295k | None => Err(Err::Incomplete(Needed::Unknown)), | 458 | 4.55M | Some(index) => Ok(i.take_split(index)), | 459 | | }; | 460 | 4.85M | res | 461 | 4.85M | } |
nom::bytes::streaming::take_until::<&str, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 453 | 18.7M | move |i: Input| { | 454 | 18.7M | let t = tag.clone(); | 455 | | | 456 | 18.7M | let res: IResult<_, _, Error> = match i.find_substring(t) { | 457 | 874k | None => Err(Err::Incomplete(Needed::Unknown)), | 458 | 17.8M | Some(index) => Ok(i.take_split(index)), | 459 | | }; | 460 | 18.7M | res | 461 | 18.7M | } |
Unexecuted instantiation: nom::bytes::streaming::take_until::<_, _, _>::{closure#0} |
462 | 24.8M | } Unexecuted instantiation: nom::bytes::streaming::take_until::<_, _, _> nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::rdp::error::RdpError> Line | Count | Source | 446 | 33.2k | pub fn take_until<T, Input, Error: ParseError<Input>>( | 447 | 33.2k | tag: T, | 448 | 33.2k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 449 | 33.2k | where | 450 | 33.2k | Input: InputTake + InputLength + FindSubstring<T>, | 451 | 33.2k | T: Clone, | 452 | | { | 453 | | move |i: Input| { | 454 | | let t = tag.clone(); | 455 | | | 456 | | let res: IResult<_, _, Error> = match i.find_substring(t) { | 457 | | None => Err(Err::Incomplete(Needed::Unknown)), | 458 | | Some(index) => Ok(i.take_split(index)), | 459 | | }; | 460 | | res | 461 | | } | 462 | 33.2k | } |
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::smb::error::SmbError> Line | Count | Source | 446 | 320k | pub fn take_until<T, Input, Error: ParseError<Input>>( | 447 | 320k | tag: T, | 448 | 320k | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 449 | 320k | where | 450 | 320k | Input: InputTake + InputLength + FindSubstring<T>, | 451 | 320k | T: Clone, | 452 | | { | 453 | | move |i: Input| { | 454 | | let t = tag.clone(); | 455 | | | 456 | | let res: IResult<_, _, Error> = match i.find_substring(t) { | 457 | | None => Err(Err::Incomplete(Needed::Unknown)), | 458 | | Some(index) => Ok(i.take_split(index)), | 459 | | }; | 460 | | res | 461 | | } | 462 | 320k | } |
nom::bytes::streaming::take_until::<&str, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 446 | 19.6M | pub fn take_until<T, Input, Error: ParseError<Input>>( | 447 | 19.6M | tag: T, | 448 | 19.6M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 449 | 19.6M | where | 450 | 19.6M | Input: InputTake + InputLength + FindSubstring<T>, | 451 | 19.6M | T: Clone, | 452 | | { | 453 | | move |i: Input| { | 454 | | let t = tag.clone(); | 455 | | | 456 | | let res: IResult<_, _, Error> = match i.find_substring(t) { | 457 | | None => Err(Err::Incomplete(Needed::Unknown)), | 458 | | Some(index) => Ok(i.take_split(index)), | 459 | | }; | 460 | | res | 461 | | } | 462 | 19.6M | } |
nom::bytes::streaming::take_until::<&[u8], &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 446 | 4.85M | pub fn take_until<T, Input, Error: ParseError<Input>>( | 447 | 4.85M | tag: T, | 448 | 4.85M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 449 | 4.85M | where | 450 | 4.85M | Input: InputTake + InputLength + FindSubstring<T>, | 451 | 4.85M | T: Clone, | 452 | | { | 453 | | move |i: Input| { | 454 | | let t = tag.clone(); | 455 | | | 456 | | let res: IResult<_, _, Error> = match i.find_substring(t) { | 457 | | None => Err(Err::Incomplete(Needed::Unknown)), | 458 | | Some(index) => Ok(i.take_split(index)), | 459 | | }; | 460 | | res | 461 | | } | 462 | 4.85M | } |
Unexecuted instantiation: nom::bytes::streaming::take_until::<_, _, _> |
463 | | |
464 | | /// Returns the non empty input slice up to the first occurrence of the pattern. |
465 | | /// |
466 | | /// It doesn't consume the pattern. |
467 | | /// |
468 | | /// # Streaming Specific |
469 | | /// *Streaming version* will return a `Err::Incomplete(Needed::new(N))` if the input doesn't |
470 | | /// contain the pattern or if the input is smaller than the pattern. |
471 | | /// # Example |
472 | | /// ```rust |
473 | | /// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult}; |
474 | | /// use nom::bytes::streaming::take_until1; |
475 | | /// |
476 | | /// fn until_eof(s: &str) -> IResult<&str, &str> { |
477 | | /// take_until1("eof")(s) |
478 | | /// } |
479 | | /// |
480 | | /// assert_eq!(until_eof("hello, worldeof"), Ok(("eof", "hello, world"))); |
481 | | /// assert_eq!(until_eof("hello, world"), Err(Err::Incomplete(Needed::Unknown))); |
482 | | /// assert_eq!(until_eof("hello, worldeo"), Err(Err::Incomplete(Needed::Unknown))); |
483 | | /// assert_eq!(until_eof("1eof2eof"), Ok(("eof2eof", "1"))); |
484 | | /// assert_eq!(until_eof("eof"), Err(Err::Error(Error::new("eof", ErrorKind::TakeUntil)))); |
485 | | /// ``` |
486 | 2.30M | pub fn take_until1<T, Input, Error: ParseError<Input>>( |
487 | 2.30M | tag: T, |
488 | 2.30M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> |
489 | 2.30M | where |
490 | 2.30M | Input: InputTake + InputLength + FindSubstring<T>, |
491 | 2.30M | T: Clone, |
492 | | { |
493 | 2.27M | move |i: Input| { |
494 | 2.27M | let t = tag.clone(); |
495 | | |
496 | 2.27M | let res: IResult<_, _, Error> = match i.find_substring(t) { |
497 | 39.1k | None => Err(Err::Incomplete(Needed::Unknown)), |
498 | 68.3k | Some(0) => Err(Err::Error(Error::from_error_kind(i, ErrorKind::TakeUntil))), |
499 | 2.16M | Some(index) => Ok(i.take_split(index)), |
500 | | }; |
501 | 2.27M | res |
502 | 2.27M | } Unexecuted instantiation: nom::bytes::streaming::take_until1::<_, _, _>::{closure#0}nom::bytes::streaming::take_until1::<&str, &[u8], nom::error::Error<&[u8]>>::{closure#0}Line | Count | Source | 493 | 2.27M | move |i: Input| { | 494 | 2.27M | let t = tag.clone(); | 495 | | | 496 | 2.27M | let res: IResult<_, _, Error> = match i.find_substring(t) { | 497 | 39.1k | None => Err(Err::Incomplete(Needed::Unknown)), | 498 | 68.3k | Some(0) => Err(Err::Error(Error::from_error_kind(i, ErrorKind::TakeUntil))), | 499 | 2.16M | Some(index) => Ok(i.take_split(index)), | 500 | | }; | 501 | 2.27M | res | 502 | 2.27M | } |
Unexecuted instantiation: nom::bytes::streaming::take_until1::<_, _, _>::{closure#0} |
503 | 2.30M | } Unexecuted instantiation: nom::bytes::streaming::take_until1::<_, _, _> nom::bytes::streaming::take_until1::<&str, &[u8], nom::error::Error<&[u8]>> Line | Count | Source | 486 | 2.30M | pub fn take_until1<T, Input, Error: ParseError<Input>>( | 487 | 2.30M | tag: T, | 488 | 2.30M | ) -> impl Fn(Input) -> IResult<Input, Input, Error> | 489 | 2.30M | where | 490 | 2.30M | Input: InputTake + InputLength + FindSubstring<T>, | 491 | 2.30M | T: Clone, | 492 | | { | 493 | | move |i: Input| { | 494 | | let t = tag.clone(); | 495 | | | 496 | | let res: IResult<_, _, Error> = match i.find_substring(t) { | 497 | | None => Err(Err::Incomplete(Needed::Unknown)), | 498 | | Some(0) => Err(Err::Error(Error::from_error_kind(i, ErrorKind::TakeUntil))), | 499 | | Some(index) => Ok(i.take_split(index)), | 500 | | }; | 501 | | res | 502 | | } | 503 | 2.30M | } |
Unexecuted instantiation: nom::bytes::streaming::take_until1::<_, _, _> |
504 | | |
505 | | /// Matches a byte string with escaped characters. |
506 | | /// |
507 | | /// * The first argument matches the normal characters (it must not accept the control character) |
508 | | /// * The second argument is the control character (like `\` in most languages) |
509 | | /// * The third argument matches the escaped characters |
510 | | /// # Example |
511 | | /// ``` |
512 | | /// # use nom::{Err, error::ErrorKind, Needed, IResult}; |
513 | | /// # use nom::character::complete::digit1; |
514 | | /// use nom::bytes::streaming::escaped; |
515 | | /// use nom::character::streaming::one_of; |
516 | | /// |
517 | | /// fn esc(s: &str) -> IResult<&str, &str> { |
518 | | /// escaped(digit1, '\\', one_of("\"n\\"))(s) |
519 | | /// } |
520 | | /// |
521 | | /// assert_eq!(esc("123;"), Ok((";", "123"))); |
522 | | /// assert_eq!(esc("12\\\"34;"), Ok((";", "12\\\"34"))); |
523 | | /// ``` |
524 | | /// |
525 | 0 | pub fn escaped<Input, Error, F, G, O1, O2>( |
526 | 0 | mut normal: F, |
527 | 0 | control_char: char, |
528 | 0 | mut escapable: G, |
529 | 0 | ) -> impl FnMut(Input) -> IResult<Input, Input, Error> |
530 | 0 | where |
531 | 0 | Input: Clone |
532 | 0 | + crate::traits::Offset |
533 | 0 | + InputLength |
534 | 0 | + InputTake |
535 | 0 | + InputTakeAtPosition |
536 | 0 | + Slice<RangeFrom<usize>> |
537 | 0 | + InputIter, |
538 | 0 | <Input as InputIter>::Item: crate::traits::AsChar, |
539 | 0 | F: Parser<Input, O1, Error>, |
540 | 0 | G: Parser<Input, O2, Error>, |
541 | 0 | Error: ParseError<Input>, |
542 | | { |
543 | | use crate::traits::AsChar; |
544 | | |
545 | 0 | move |input: Input| { |
546 | 0 | let mut i = input.clone(); |
547 | | |
548 | 0 | while i.input_len() > 0 { |
549 | 0 | let current_len = i.input_len(); |
550 | | |
551 | 0 | match normal.parse(i.clone()) { |
552 | 0 | Ok((i2, _)) => { |
553 | 0 | if i2.input_len() == 0 { |
554 | 0 | return Err(Err::Incomplete(Needed::Unknown)); |
555 | 0 | } else if i2.input_len() == current_len { |
556 | 0 | let index = input.offset(&i2); |
557 | 0 | return Ok(input.take_split(index)); |
558 | 0 | } else { |
559 | 0 | i = i2; |
560 | 0 | } |
561 | | } |
562 | | Err(Err::Error(_)) => { |
563 | | // unwrap() should be safe here since index < $i.input_len() |
564 | 0 | if i.iter_elements().next().unwrap().as_char() == control_char { |
565 | 0 | let next = control_char.len_utf8(); |
566 | 0 | if next >= i.input_len() { |
567 | 0 | return Err(Err::Incomplete(Needed::new(1))); |
568 | | } else { |
569 | 0 | match escapable.parse(i.slice(next..)) { |
570 | 0 | Ok((i2, _)) => { |
571 | 0 | if i2.input_len() == 0 { |
572 | 0 | return Err(Err::Incomplete(Needed::Unknown)); |
573 | 0 | } else { |
574 | 0 | i = i2; |
575 | 0 | } |
576 | | } |
577 | 0 | Err(e) => return Err(e), |
578 | | } |
579 | | } |
580 | | } else { |
581 | 0 | let index = input.offset(&i); |
582 | 0 | return Ok(input.take_split(index)); |
583 | | } |
584 | | } |
585 | 0 | Err(e) => { |
586 | 0 | return Err(e); |
587 | | } |
588 | | } |
589 | | } |
590 | | |
591 | 0 | Err(Err::Incomplete(Needed::Unknown)) |
592 | 0 | } Unexecuted instantiation: nom::bytes::streaming::escaped::<_, _, _, _, _, _>::{closure#0}Unexecuted instantiation: nom::bytes::streaming::escaped::<_, _, _, _, _, _>::{closure#0} |
593 | 0 | } Unexecuted instantiation: nom::bytes::streaming::escaped::<_, _, _, _, _, _> Unexecuted instantiation: nom::bytes::streaming::escaped::<_, _, _, _, _, _> |
594 | | |
595 | | /// Matches a byte string with escaped characters. |
596 | | /// |
597 | | /// * The first argument matches the normal characters (it must not match the control character) |
598 | | /// * The second argument is the control character (like `\` in most languages) |
599 | | /// * The third argument matches the escaped characters and transforms them |
600 | | /// |
601 | | /// As an example, the chain `abc\tdef` could be `abc def` (it also consumes the control character) |
602 | | /// |
603 | | /// ``` |
604 | | /// # use nom::{Err, error::ErrorKind, Needed, IResult}; |
605 | | /// # use std::str::from_utf8; |
606 | | /// use nom::bytes::streaming::{escaped_transform, tag}; |
607 | | /// use nom::character::streaming::alpha1; |
608 | | /// use nom::branch::alt; |
609 | | /// use nom::combinator::value; |
610 | | /// |
611 | | /// fn parser(input: &str) -> IResult<&str, String> { |
612 | | /// escaped_transform( |
613 | | /// alpha1, |
614 | | /// '\\', |
615 | | /// alt(( |
616 | | /// value("\\", tag("\\")), |
617 | | /// value("\"", tag("\"")), |
618 | | /// value("\n", tag("n")), |
619 | | /// )) |
620 | | /// )(input) |
621 | | /// } |
622 | | /// |
623 | | /// assert_eq!(parser("ab\\\"cd\""), Ok(("\"", String::from("ab\"cd")))); |
624 | | /// ``` |
625 | | #[cfg(feature = "alloc")] |
626 | | #[cfg_attr(feature = "docsrs", doc(cfg(feature = "alloc")))] |
627 | 0 | pub fn escaped_transform<Input, Error, F, G, O1, O2, ExtendItem, Output>( |
628 | 0 | mut normal: F, |
629 | 0 | control_char: char, |
630 | 0 | mut transform: G, |
631 | 0 | ) -> impl FnMut(Input) -> IResult<Input, Output, Error> |
632 | 0 | where |
633 | 0 | Input: Clone |
634 | 0 | + crate::traits::Offset |
635 | 0 | + InputLength |
636 | 0 | + InputTake |
637 | 0 | + InputTakeAtPosition |
638 | 0 | + Slice<RangeFrom<usize>> |
639 | 0 | + InputIter, |
640 | 0 | Input: crate::traits::ExtendInto<Item = ExtendItem, Extender = Output>, |
641 | 0 | O1: crate::traits::ExtendInto<Item = ExtendItem, Extender = Output>, |
642 | 0 | O2: crate::traits::ExtendInto<Item = ExtendItem, Extender = Output>, |
643 | 0 | <Input as InputIter>::Item: crate::traits::AsChar, |
644 | 0 | F: Parser<Input, O1, Error>, |
645 | 0 | G: Parser<Input, O2, Error>, |
646 | 0 | Error: ParseError<Input>, |
647 | | { |
648 | | use crate::traits::AsChar; |
649 | | |
650 | 0 | move |input: Input| { |
651 | 0 | let mut index = 0; |
652 | 0 | let mut res = input.new_builder(); |
653 | | |
654 | 0 | let i = input.clone(); |
655 | | |
656 | 0 | while index < i.input_len() { |
657 | 0 | let current_len = i.input_len(); |
658 | 0 | let remainder = i.slice(index..); |
659 | 0 | match normal.parse(remainder.clone()) { |
660 | 0 | Ok((i2, o)) => { |
661 | 0 | o.extend_into(&mut res); |
662 | 0 | if i2.input_len() == 0 { |
663 | 0 | return Err(Err::Incomplete(Needed::Unknown)); |
664 | 0 | } else if i2.input_len() == current_len { |
665 | 0 | return Ok((remainder, res)); |
666 | 0 | } else { |
667 | 0 | index = input.offset(&i2); |
668 | 0 | } |
669 | | } |
670 | | Err(Err::Error(_)) => { |
671 | | // unwrap() should be safe here since index < $i.input_len() |
672 | 0 | if remainder.iter_elements().next().unwrap().as_char() == control_char { |
673 | 0 | let next = index + control_char.len_utf8(); |
674 | 0 | let input_len = input.input_len(); |
675 | | |
676 | 0 | if next >= input_len { |
677 | 0 | return Err(Err::Incomplete(Needed::Unknown)); |
678 | | } else { |
679 | 0 | match transform.parse(i.slice(next..)) { |
680 | 0 | Ok((i2, o)) => { |
681 | 0 | o.extend_into(&mut res); |
682 | 0 | if i2.input_len() == 0 { |
683 | 0 | return Err(Err::Incomplete(Needed::Unknown)); |
684 | 0 | } else { |
685 | 0 | index = input.offset(&i2); |
686 | 0 | } |
687 | | } |
688 | 0 | Err(e) => return Err(e), |
689 | | } |
690 | | } |
691 | | } else { |
692 | 0 | return Ok((remainder, res)); |
693 | | } |
694 | | } |
695 | 0 | Err(e) => return Err(e), |
696 | | } |
697 | | } |
698 | 0 | Err(Err::Incomplete(Needed::Unknown)) |
699 | 0 | } Unexecuted instantiation: nom::bytes::streaming::escaped_transform::<_, _, _, _, _, _, _, _>::{closure#0}Unexecuted instantiation: nom::bytes::streaming::escaped_transform::<_, _, _, _, _, _, _, _>::{closure#0} |
700 | 0 | } Unexecuted instantiation: nom::bytes::streaming::escaped_transform::<_, _, _, _, _, _, _, _> Unexecuted instantiation: nom::bytes::streaming::escaped_transform::<_, _, _, _, _, _, _, _> |