Coverage Report

Created: 2026-01-16 07:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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
26.1M
pub fn tag<T, Input, Error: ParseError<Input>>(
32
26.1M
  tag: T,
33
26.1M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
34
26.1M
where
35
26.1M
  Input: InputTake + InputLength + Compare<T>,
36
26.1M
  T: InputLength + Clone,
37
{
38
26.7M
  move |i: Input| {
39
26.7M
    let tag_len = tag.input_len();
40
26.7M
    let t = tag.clone();
41
42
26.7M
    let res: IResult<_, _, Error> = match i.compare(t) {
43
22.1M
      CompareResult::Ok => Ok(i.take_split(tag_len)),
44
295k
      CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))),
45
      CompareResult::Error => {
46
4.33M
        let e: ErrorKind = ErrorKind::Tag;
47
4.33M
        Err(Err::Error(Error::from_error_kind(i, e)))
48
      }
49
    };
50
26.7M
    res
51
26.7M
  }
nom::bytes::streaming::tag::<&[u8; 4], &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
38
9.47k
  move |i: Input| {
39
9.47k
    let tag_len = tag.input_len();
40
9.47k
    let t = tag.clone();
41
42
9.47k
    let res: IResult<_, _, Error> = match i.compare(t) {
43
4.80k
      CompareResult::Ok => Ok(i.take_split(tag_len)),
44
829
      CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))),
45
      CompareResult::Error => {
46
3.84k
        let e: ErrorKind = ErrorKind::Tag;
47
3.84k
        Err(Err::Error(Error::from_error_kind(i, e)))
48
      }
49
    };
50
9.47k
    res
51
9.47k
  }
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; 1], &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
38
168k
  move |i: Input| {
39
168k
    let tag_len = tag.input_len();
40
168k
    let t = tag.clone();
41
42
168k
    let res: IResult<_, _, Error> = match i.compare(t) {
43
168k
      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
168k
    res
51
168k
  }
nom::bytes::streaming::tag::<&[u8; 3], &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
38
2.73M
  move |i: Input| {
39
2.73M
    let tag_len = tag.input_len();
40
2.73M
    let t = tag.clone();
41
42
2.73M
    let res: IResult<_, _, Error> = match i.compare(t) {
43
2.71M
      CompareResult::Ok => Ok(i.take_split(tag_len)),
44
7.62k
      CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))),
45
      CompareResult::Error => {
46
14.8k
        let e: ErrorKind = ErrorKind::Tag;
47
14.8k
        Err(Err::Error(Error::from_error_kind(i, e)))
48
      }
49
    };
50
2.73M
    res
51
2.73M
  }
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::smb::error::SmbError>::{closure#0}
Line
Count
Source
38
270k
  move |i: Input| {
39
270k
    let tag_len = tag.input_len();
40
270k
    let t = tag.clone();
41
42
270k
    let res: IResult<_, _, Error> = match i.compare(t) {
43
270k
      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
270k
    res
51
270k
  }
nom::bytes::streaming::tag::<&[u8; 8], &[u8], suricata::rdp::error::RdpError>::{closure#0}
Line
Count
Source
38
178k
  move |i: Input| {
39
178k
    let tag_len = tag.input_len();
40
178k
    let t = tag.clone();
41
42
178k
    let res: IResult<_, _, Error> = match i.compare(t) {
43
1.32k
      CompareResult::Ok => Ok(i.take_split(tag_len)),
44
1.38k
      CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))),
45
      CompareResult::Error => {
46
175k
        let e: ErrorKind = ErrorKind::Tag;
47
175k
        Err(Err::Error(Error::from_error_kind(i, e)))
48
      }
49
    };
50
178k
    res
51
178k
  }
nom::bytes::streaming::tag::<&[u8; 9], &[u8], suricata::rdp::error::RdpError>::{closure#0}
Line
Count
Source
38
1.32k
  move |i: Input| {
39
1.32k
    let tag_len = tag.input_len();
40
1.32k
    let t = tag.clone();
41
42
1.32k
    let res: IResult<_, _, Error> = match i.compare(t) {
43
84
      CompareResult::Ok => Ok(i.take_split(tag_len)),
44
455
      CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))),
45
      CompareResult::Error => {
46
790
        let e: ErrorKind = ErrorKind::Tag;
47
790
        Err(Err::Error(Error::from_error_kind(i, e)))
48
      }
49
    };
50
1.32k
    res
51
1.32k
  }
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::rdp::error::RdpError>::{closure#0}
Line
Count
Source
38
26.1k
  move |i: Input| {
39
26.1k
    let tag_len = tag.input_len();
40
26.1k
    let t = tag.clone();
41
42
26.1k
    let res: IResult<_, _, Error> = match i.compare(t) {
43
26.1k
      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
26.1k
    res
51
26.1k
  }
nom::bytes::streaming::tag::<[u8; 1], &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
38
771k
  move |i: Input| {
39
771k
    let tag_len = tag.input_len();
40
771k
    let t = tag.clone();
41
42
771k
    let res: IResult<_, _, Error> = match i.compare(t) {
43
771k
      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
58
        let e: ErrorKind = ErrorKind::Tag;
47
58
        Err(Err::Error(Error::from_error_kind(i, e)))
48
      }
49
    };
50
771k
    res
51
771k
  }
nom::bytes::streaming::tag::<&str, &[u8], ()>::{closure#0}
Line
Count
Source
38
19.9k
  move |i: Input| {
39
19.9k
    let tag_len = tag.input_len();
40
19.9k
    let t = tag.clone();
41
42
19.9k
    let res: IResult<_, _, Error> = match i.compare(t) {
43
10.8k
      CompareResult::Ok => Ok(i.take_split(tag_len)),
44
991
      CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))),
45
      CompareResult::Error => {
46
8.03k
        let e: ErrorKind = ErrorKind::Tag;
47
8.03k
        Err(Err::Error(Error::from_error_kind(i, e)))
48
      }
49
    };
50
19.9k
    res
51
19.9k
  }
nom::bytes::streaming::tag::<&[u8; 4], &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
38
2.73M
  move |i: Input| {
39
2.73M
    let tag_len = tag.input_len();
40
2.73M
    let t = tag.clone();
41
42
2.73M
    let res: IResult<_, _, Error> = match i.compare(t) {
43
2.72M
      CompareResult::Ok => Ok(i.take_split(tag_len)),
44
521
      CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))),
45
      CompareResult::Error => {
46
6.27k
        let e: ErrorKind = ErrorKind::Tag;
47
6.27k
        Err(Err::Error(Error::from_error_kind(i, e)))
48
      }
49
    };
50
2.73M
    res
51
2.73M
  }
nom::bytes::streaming::tag::<&[u8], &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
38
2.65M
  move |i: Input| {
39
2.65M
    let tag_len = tag.input_len();
40
2.65M
    let t = tag.clone();
41
42
2.65M
    let res: IResult<_, _, Error> = match i.compare(t) {
43
2.65M
      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
2.65M
    res
51
2.65M
  }
nom::bytes::streaming::tag::<&str, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
38
17.1M
  move |i: Input| {
39
17.1M
    let tag_len = tag.input_len();
40
17.1M
    let t = tag.clone();
41
42
17.1M
    let res: IResult<_, _, Error> = match i.compare(t) {
43
12.7M
      CompareResult::Ok => Ok(i.take_split(tag_len)),
44
283k
      CompareResult::Incomplete => Err(Err::Incomplete(Needed::new(tag_len - i.input_len()))),
45
      CompareResult::Error => {
46
4.12M
        let e: ErrorKind = ErrorKind::Tag;
47
4.12M
        Err(Err::Error(Error::from_error_kind(i, e)))
48
      }
49
    };
50
17.1M
    res
51
17.1M
  }
Unexecuted instantiation: nom::bytes::streaming::tag::<[u8; 2], &[u8], nom::error::Error<&[u8]>>::{closure#0}
Unexecuted instantiation: nom::bytes::streaming::tag::<_, _, _>::{closure#0}
52
26.1M
}
nom::bytes::streaming::tag::<&[u8; 4], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
7.40k
pub fn tag<T, Input, Error: ParseError<Input>>(
32
7.40k
  tag: T,
33
7.40k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
34
7.40k
where
35
7.40k
  Input: InputTake + InputLength + Compare<T>,
36
7.40k
  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.40k
}
Unexecuted instantiation: nom::bytes::streaming::tag::<[u8; 2], &[u8], nom::error::Error<&[u8]>>
Unexecuted instantiation: nom::bytes::streaming::tag::<_, _, _>
nom::bytes::streaming::tag::<&[u8; 1], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
168k
pub fn tag<T, Input, Error: ParseError<Input>>(
32
168k
  tag: T,
33
168k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
34
168k
where
35
168k
  Input: InputTake + InputLength + Compare<T>,
36
168k
  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
168k
}
nom::bytes::streaming::tag::<&[u8; 3], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
2.73M
pub fn tag<T, Input, Error: ParseError<Input>>(
32
2.73M
  tag: T,
33
2.73M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
34
2.73M
where
35
2.73M
  Input: InputTake + InputLength + Compare<T>,
36
2.73M
  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.73M
}
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::smb::error::SmbError>
Line
Count
Source
31
270k
pub fn tag<T, Input, Error: ParseError<Input>>(
32
270k
  tag: T,
33
270k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
34
270k
where
35
270k
  Input: InputTake + InputLength + Compare<T>,
36
270k
  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
270k
}
nom::bytes::streaming::tag::<&[u8; 8], &[u8], suricata::rdp::error::RdpError>
Line
Count
Source
31
178k
pub fn tag<T, Input, Error: ParseError<Input>>(
32
178k
  tag: T,
33
178k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
34
178k
where
35
178k
  Input: InputTake + InputLength + Compare<T>,
36
178k
  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
178k
}
nom::bytes::streaming::tag::<&[u8; 9], &[u8], suricata::rdp::error::RdpError>
Line
Count
Source
31
1.32k
pub fn tag<T, Input, Error: ParseError<Input>>(
32
1.32k
  tag: T,
33
1.32k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
34
1.32k
where
35
1.32k
  Input: InputTake + InputLength + Compare<T>,
36
1.32k
  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.32k
}
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::rdp::error::RdpError>
Line
Count
Source
31
26.1k
pub fn tag<T, Input, Error: ParseError<Input>>(
32
26.1k
  tag: T,
33
26.1k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
34
26.1k
where
35
26.1k
  Input: InputTake + InputLength + Compare<T>,
36
26.1k
  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.1k
}
nom::bytes::streaming::tag::<[u8; 1], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
771k
pub fn tag<T, Input, Error: ParseError<Input>>(
32
771k
  tag: T,
33
771k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
34
771k
where
35
771k
  Input: InputTake + InputLength + Compare<T>,
36
771k
  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
771k
}
nom::bytes::streaming::tag::<&[u8; 4], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
2.73M
pub fn tag<T, Input, Error: ParseError<Input>>(
32
2.73M
  tag: T,
33
2.73M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
34
2.73M
where
35
2.73M
  Input: InputTake + InputLength + Compare<T>,
36
2.73M
  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.73M
}
nom::bytes::streaming::tag::<&str, &[u8], ()>
Line
Count
Source
31
28.9k
pub fn tag<T, Input, Error: ParseError<Input>>(
32
28.9k
  tag: T,
33
28.9k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
34
28.9k
where
35
28.9k
  Input: InputTake + InputLength + Compare<T>,
36
28.9k
  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.9k
}
nom::bytes::streaming::tag::<&str, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
16.5M
pub fn tag<T, Input, Error: ParseError<Input>>(
32
16.5M
  tag: T,
33
16.5M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
34
16.5M
where
35
16.5M
  Input: InputTake + InputLength + Compare<T>,
36
16.5M
  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
16.5M
}
nom::bytes::streaming::tag::<&[u8], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
2.65M
pub fn tag<T, Input, Error: ParseError<Input>>(
32
2.65M
  tag: T,
33
2.65M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
34
2.65M
where
35
2.65M
  Input: InputTake + InputLength + Compare<T>,
36
2.65M
  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.65M
}
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
10.1k
pub fn is_not<T, Input, Error: ParseError<Input>>(
118
10.1k
  arr: T,
119
10.1k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
120
10.1k
where
121
10.1k
  Input: InputTakeAtPosition,
122
10.1k
  T: FindToken<<Input as InputTakeAtPosition>::Item>,
123
{
124
10.1k
  move |i: Input| {
125
10.1k
    let e: ErrorKind = ErrorKind::IsNot;
126
19.5M
    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
92.9k
    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
19.5M
    i.split_at_position1(|c| arr.find_token(c), e)
Unexecuted instantiation: nom::bytes::streaming::is_not::<_, _, _>::{closure#0}::{closure#0}
127
10.1k
  }
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
3.42k
  move |i: Input| {
125
3.42k
    let e: ErrorKind = ErrorKind::IsNot;
126
3.42k
    i.split_at_position1(|c| arr.find_token(c), e)
127
3.42k
  }
nom::bytes::streaming::is_not::<&str, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
124
6.77k
  move |i: Input| {
125
6.77k
    let e: ErrorKind = ErrorKind::IsNot;
126
6.77k
    i.split_at_position1(|c| arr.find_token(c), e)
127
6.77k
  }
Unexecuted instantiation: nom::bytes::streaming::is_not::<_, _, _>::{closure#0}
128
10.1k
}
Unexecuted instantiation: nom::bytes::streaming::is_not::<_, _, _>
nom::bytes::streaming::is_not::<&str, &str, nom::error::Error<&str>>
Line
Count
Source
117
3.42k
pub fn is_not<T, Input, Error: ParseError<Input>>(
118
3.42k
  arr: T,
119
3.42k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
120
3.42k
where
121
3.42k
  Input: InputTakeAtPosition,
122
3.42k
  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
3.42k
}
nom::bytes::streaming::is_not::<&str, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
117
6.77k
pub fn is_not<T, Input, Error: ParseError<Input>>(
118
6.77k
  arr: T,
119
6.77k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
120
6.77k
where
121
6.77k
  Input: InputTakeAtPosition,
122
6.77k
  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
6.77k
}
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
3.42k
pub fn is_a<T, Input, Error: ParseError<Input>>(
154
3.42k
  arr: T,
155
3.42k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
156
3.42k
where
157
3.42k
  Input: InputTakeAtPosition,
158
3.42k
  T: FindToken<<Input as InputTakeAtPosition>::Item>,
159
{
160
3.42k
  move |i: Input| {
161
3.42k
    let e: ErrorKind = ErrorKind::IsA;
162
3.42k
    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
3.42k
    i.split_at_position1(|c| !arr.find_token(c), e)
Unexecuted instantiation: nom::bytes::streaming::is_a::<_, _, _>::{closure#0}::{closure#0}
163
3.42k
  }
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
3.42k
  move |i: Input| {
161
3.42k
    let e: ErrorKind = ErrorKind::IsA;
162
3.42k
    i.split_at_position1(|c| !arr.find_token(c), e)
163
3.42k
  }
Unexecuted instantiation: nom::bytes::streaming::is_a::<_, _, _>::{closure#0}
164
3.42k
}
Unexecuted instantiation: nom::bytes::streaming::is_a::<_, _, _>
nom::bytes::streaming::is_a::<&str, &str, nom::error::Error<&str>>
Line
Count
Source
153
3.42k
pub fn is_a<T, Input, Error: ParseError<Input>>(
154
3.42k
  arr: T,
155
3.42k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
156
3.42k
where
157
3.42k
  Input: InputTakeAtPosition,
158
3.42k
  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
3.42k
}
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
7.26M
pub fn take_while<F, Input, Error: ParseError<Input>>(
189
7.26M
  cond: F,
190
7.26M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
191
7.26M
where
192
7.26M
  Input: InputTakeAtPosition,
193
7.26M
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
194
{
195
81.6M
  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
85.1k
  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
79.8k
  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
533k
  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
24.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}
Line
Count
Source
195
21.4k
  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
3.44M
  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
771k
  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
1.06M
  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
532k
  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
95.2k
  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
96.1k
  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
103k
  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
413k
  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
123k
  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
183k
  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
6.12M
  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
3.46M
  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
6.73M
  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
49.3k
  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
62.7k
  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
2.68M
  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.65M
  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
14.6M
  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
4.02M
  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
10.0M
  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.8M
  move |i: Input| i.split_at_position(|c| !cond(c))
Unexecuted instantiation: nom::bytes::streaming::take_while::<_, _, _>::{closure#0}::{closure#0}
196
7.26M
}
nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
188
85.1k
pub fn take_while<F, Input, Error: ParseError<Input>>(
189
85.1k
  cond: F,
190
85.1k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
191
85.1k
where
192
85.1k
  Input: InputTakeAtPosition,
193
85.1k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
194
{
195
  move |i: Input| i.split_at_position(|c| !cond(c))
196
85.1k
}
nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#2}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
188
79.8k
pub fn take_while<F, Input, Error: ParseError<Input>>(
189
79.8k
  cond: F,
190
79.8k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
191
79.8k
where
192
79.8k
  Input: InputTakeAtPosition,
193
79.8k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
194
{
195
  move |i: Input| i.split_at_position(|c| !cond(c))
196
79.8k
}
nom::bytes::streaming::take_while::<suricata::http2::parser::http2_parse_var_uint::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
188
533k
pub fn take_while<F, Input, Error: ParseError<Input>>(
189
533k
  cond: F,
190
533k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
191
533k
where
192
533k
  Input: InputTakeAtPosition,
193
533k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
194
{
195
  move |i: Input| i.split_at_position(|c| !cond(c))
196
533k
}
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
24.5k
pub fn take_while<F, Input, Error: ParseError<Input>>(
189
24.5k
  cond: F,
190
24.5k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
191
24.5k
where
192
24.5k
  Input: InputTakeAtPosition,
193
24.5k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
194
{
195
  move |i: Input| i.split_at_position(|c| !cond(c))
196
24.5k
}
nom::bytes::streaming::take_while::<suricata::http2::range::http2_parse_content_range::{closure#2}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
188
21.4k
pub fn take_while<F, Input, Error: ParseError<Input>>(
189
21.4k
  cond: F,
190
21.4k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
191
21.4k
where
192
21.4k
  Input: InputTakeAtPosition,
193
21.4k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
194
{
195
  move |i: Input| i.split_at_position(|c| !cond(c))
196
21.4k
}
nom::bytes::streaming::take_while::<nom::character::is_space, &[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_header_name, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
188
532k
pub fn take_while<F, Input, Error: ParseError<Input>>(
189
532k
  cond: F,
190
532k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
191
532k
where
192
532k
  Input: InputTakeAtPosition,
193
532k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
194
{
195
  move |i: Input| i.split_at_position(|c| !cond(c))
196
532k
}
nom::bytes::streaming::take_while::<suricata::sip::parser::is_method_char, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
188
95.2k
pub fn take_while<F, Input, Error: ParseError<Input>>(
189
95.2k
  cond: F,
190
95.2k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
191
95.2k
where
192
95.2k
  Input: InputTakeAtPosition,
193
95.2k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
194
{
195
  move |i: Input| i.split_at_position(|c| !cond(c))
196
95.2k
}
nom::bytes::streaming::take_while::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
188
96.1k
pub fn take_while<F, Input, Error: ParseError<Input>>(
189
96.1k
  cond: F,
190
96.1k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
191
96.1k
where
192
96.1k
  Input: InputTakeAtPosition,
193
96.1k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
194
{
195
  move |i: Input| i.split_at_position(|c| !cond(c))
196
96.1k
}
nom::bytes::streaming::take_while::<suricata::mime::mime_parse_header_token::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
188
3.44M
pub fn take_while<F, Input, Error: ParseError<Input>>(
189
3.44M
  cond: F,
190
3.44M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
191
3.44M
where
192
3.44M
  Input: InputTakeAtPosition,
193
3.44M
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
194
{
195
  move |i: Input| i.split_at_position(|c| !cond(c))
196
3.44M
}
nom::bytes::streaming::take_while::<suricata::tftp::tftp::getstr::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
188
771k
pub fn take_while<F, Input, Error: ParseError<Input>>(
189
771k
  cond: F,
190
771k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
191
771k
where
192
771k
  Input: InputTakeAtPosition,
193
771k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
194
{
195
  move |i: Input| i.split_at_position(|c| !cond(c))
196
771k
}
nom::bytes::streaming::take_while::<suricata::http2::parser::http2_parse_var_uint::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
188
413k
pub fn take_while<F, Input, Error: ParseError<Input>>(
189
413k
  cond: F,
190
413k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
191
413k
where
192
413k
  Input: InputTakeAtPosition,
193
413k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
194
{
195
  move |i: Input| i.split_at_position(|c| !cond(c))
196
413k
}
nom::bytes::streaming::take_while::<suricata::ssh::parser::is_not_lineend, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
188
103k
pub fn take_while<F, Input, Error: ParseError<Input>>(
189
103k
  cond: F,
190
103k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
191
103k
where
192
103k
  Input: InputTakeAtPosition,
193
103k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
194
{
195
  move |i: Input| i.split_at_position(|c| !cond(c))
196
103k
}
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
472k
pub fn take_while1<F, Input, Error: ParseError<Input>>(
223
472k
  cond: F,
224
472k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
225
472k
where
226
472k
  Input: InputTakeAtPosition,
227
472k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
228
{
229
472k
  move |i: Input| {
230
472k
    let e: ErrorKind = ErrorKind::TakeWhile1;
231
27.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
4.42M
    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
13.5M
    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
9.94M
    i.split_at_position1(|c| !cond(c), e)
Unexecuted instantiation: nom::bytes::streaming::take_while1::<_, _, _>::{closure#0}::{closure#0}
232
472k
  }
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
190k
  move |i: Input| {
230
190k
    let e: ErrorKind = ErrorKind::TakeWhile1;
231
190k
    i.split_at_position1(|c| !cond(c), e)
232
190k
  }
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
229
187k
  move |i: Input| {
230
187k
    let e: ErrorKind = ErrorKind::TakeWhile1;
231
187k
    i.split_at_position1(|c| !cond(c), e)
232
187k
  }
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_request_uri_char, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
229
95.1k
  move |i: Input| {
230
95.1k
    let e: ErrorKind = ErrorKind::TakeWhile1;
231
95.1k
    i.split_at_position1(|c| !cond(c), e)
232
95.1k
  }
Unexecuted instantiation: nom::bytes::streaming::take_while1::<_, _, _>::{closure#0}
233
472k
}
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
190k
pub fn take_while1<F, Input, Error: ParseError<Input>>(
223
190k
  cond: F,
224
190k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
225
190k
where
226
190k
  Input: InputTakeAtPosition,
227
190k
  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
190k
}
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
222
187k
pub fn take_while1<F, Input, Error: ParseError<Input>>(
223
187k
  cond: F,
224
187k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
225
187k
where
226
187k
  Input: InputTakeAtPosition,
227
187k
  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
187k
}
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_request_uri_char, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
222
95.1k
pub fn take_while1<F, Input, Error: ParseError<Input>>(
223
95.1k
  cond: F,
224
95.1k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
225
95.1k
where
226
95.1k
  Input: InputTakeAtPosition,
227
95.1k
  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
95.1k
}
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
40.0M
pub fn take_while_m_n<F, Input, Error: ParseError<Input>>(
261
40.0M
  m: usize,
262
40.0M
  n: usize,
263
40.0M
  cond: F,
264
40.0M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
265
40.0M
where
266
40.0M
  Input: InputTake + InputIter + InputLength,
267
40.0M
  F: Fn(<Input as InputIter>::Item) -> bool,
268
{
269
40.0M
  move |i: Input| {
270
40.0M
    let input = i;
271
272
51.9M
    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
51.9M
    match input.position(|c| !cond(c)) {
Unexecuted instantiation: nom::bytes::streaming::take_while_m_n::<_, _, _>::{closure#0}::{closure#0}
273
40.0M
      Some(idx) => {
274
40.0M
        if idx >= m {
275
40.0M
          if idx <= n {
276
40.0M
            let res: IResult<_, _, Error> = if let Ok(index) = input.slice_index(idx) {
277
40.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
40.0M
            res
285
          } else {
286
479
            let res: IResult<_, _, Error> = if let Ok(index) = input.slice_index(n) {
287
479
              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
479
            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
25.3k
        let len = input.input_len();
303
25.3k
        if len >= n {
304
850
          match input.slice_index(n) {
305
850
            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
24.5k
          let needed = if m > len { m - len } else { 1 };
313
24.5k
          Err(Err::Incomplete(Needed::new(needed)))
314
        }
315
      }
316
    }
317
40.0M
  }
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
40.0M
  move |i: Input| {
270
40.0M
    let input = i;
271
272
40.0M
    match input.position(|c| !cond(c)) {
273
40.0M
      Some(idx) => {
274
40.0M
        if idx >= m {
275
40.0M
          if idx <= n {
276
40.0M
            let res: IResult<_, _, Error> = if let Ok(index) = input.slice_index(idx) {
277
40.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
40.0M
            res
285
          } else {
286
479
            let res: IResult<_, _, Error> = if let Ok(index) = input.slice_index(n) {
287
479
              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
479
            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
25.3k
        let len = input.input_len();
303
25.3k
        if len >= n {
304
850
          match input.slice_index(n) {
305
850
            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
24.5k
          let needed = if m > len { m - len } else { 1 };
313
24.5k
          Err(Err::Incomplete(Needed::new(needed)))
314
        }
315
      }
316
    }
317
40.0M
  }
Unexecuted instantiation: nom::bytes::streaming::take_while_m_n::<_, _, _>::{closure#0}
318
40.0M
}
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
40.0M
pub fn take_while_m_n<F, Input, Error: ParseError<Input>>(
261
40.0M
  m: usize,
262
40.0M
  n: usize,
263
40.0M
  cond: F,
264
40.0M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
265
40.0M
where
266
40.0M
  Input: InputTake + InputIter + InputLength,
267
40.0M
  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
40.0M
}
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
107k
pub fn take_till<F, Input, Error: ParseError<Input>>(
344
107k
  cond: F,
345
107k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
346
107k
where
347
107k
  Input: InputTakeAtPosition,
348
107k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
349
{
350
3.64M
  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
83.5k
  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
24.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
1.78M
  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.85M
  move |i: Input| i.split_at_position(|c| cond(c))
Unexecuted instantiation: nom::bytes::streaming::take_till::<_, _, _>::{closure#0}::{closure#0}
351
107k
}
nom::bytes::streaming::take_till::<suricata::http2::range::http2_parse_content_range::{closure#1}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
343
83.5k
pub fn take_till<F, Input, Error: ParseError<Input>>(
344
83.5k
  cond: F,
345
83.5k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
346
83.5k
where
347
83.5k
  Input: InputTakeAtPosition,
348
83.5k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
349
{
350
  move |i: Input| i.split_at_position(|c| cond(c))
351
83.5k
}
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
24.2k
pub fn take_till<F, Input, Error: ParseError<Input>>(
344
24.2k
  cond: F,
345
24.2k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
346
24.2k
where
347
24.2k
  Input: InputTakeAtPosition,
348
24.2k
  F: Fn(<Input as InputTakeAtPosition>::Item) -> bool,
349
{
350
  move |i: Input| i.split_at_position(|c| cond(c))
351
24.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
129M
pub fn take<C, Input, Error: ParseError<Input>>(
412
129M
  count: C,
413
129M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
129M
where
415
129M
  Input: InputIter + InputTake + InputLength,
416
129M
  C: ToUsize,
417
{
418
129M
  let c = count.to_usize();
419
127M
  move |i: Input| match i.slice_index(c) {
420
6.47M
    Err(i) => Err(Err::Incomplete(i)),
421
120M
    Ok(index) => Ok(i.take_split(index)),
422
127M
  }
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
15.8M
  move |i: Input| match i.slice_index(c) {
420
351k
    Err(i) => Err(Err::Incomplete(i)),
421
15.5M
    Ok(index) => Ok(i.take_split(index)),
422
15.8M
  }
nom::bytes::streaming::take::<usize, &[u8], suricata::kerberos::SecBlobError>::{closure#0}
Line
Count
Source
419
72.7k
  move |i: Input| match i.slice_index(c) {
420
995
    Err(i) => Err(Err::Incomplete(i)),
421
71.7k
    Ok(index) => Ok(i.take_split(index)),
422
72.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.42k
    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
507k
  move |i: Input| match i.slice_index(c) {
420
22.3k
    Err(i) => Err(Err::Incomplete(i)),
421
485k
    Ok(index) => Ok(i.take_split(index)),
422
507k
  }
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
1.03M
  move |i: Input| match i.slice_index(c) {
420
2.67k
    Err(i) => Err(Err::Incomplete(i)),
421
1.03M
    Ok(index) => Ok(i.take_split(index)),
422
1.03M
  }
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
49.6k
  move |i: Input| match i.slice_index(c) {
420
35.8k
    Err(i) => Err(Err::Incomplete(i)),
421
13.8k
    Ok(index) => Ok(i.take_split(index)),
422
49.6k
  }
nom::bytes::streaming::take::<u8, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
13.9k
  move |i: Input| match i.slice_index(c) {
420
5.52k
    Err(i) => Err(Err::Incomplete(i)),
421
8.45k
    Ok(index) => Ok(i.take_split(index)),
422
13.9k
  }
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
42.0k
  move |i: Input| match i.slice_index(c) {
420
1.58k
    Err(i) => Err(Err::Incomplete(i)),
421
40.5k
    Ok(index) => Ok(i.take_split(index)),
422
42.0k
  }
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
4.92M
  move |i: Input| match i.slice_index(c) {
420
35.8k
    Err(i) => Err(Err::Incomplete(i)),
421
4.89M
    Ok(index) => Ok(i.take_split(index)),
422
4.92M
  }
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.22k
  move |i: Input| match i.slice_index(c) {
420
319
    Err(i) => Err(Err::Incomplete(i)),
421
904
    Ok(index) => Ok(i.take_split(index)),
422
1.22k
  }
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>::{closure#0}
Line
Count
Source
419
5.38M
  move |i: Input| match i.slice_index(c) {
420
96.5k
    Err(i) => Err(Err::Incomplete(i)),
421
5.28M
    Ok(index) => Ok(i.take_split(index)),
422
5.38M
  }
nom::bytes::streaming::take::<u8, &[u8], asn1_rs::error::Error>::{closure#0}
Line
Count
Source
419
319k
  move |i: Input| match i.slice_index(c) {
420
23.0k
    Err(i) => Err(Err::Incomplete(i)),
421
296k
    Ok(index) => Ok(i.take_split(index)),
422
319k
  }
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>::{closure#0}
Line
Count
Source
419
7.25k
  move |i: Input| match i.slice_index(c) {
420
8
    Err(i) => Err(Err::Incomplete(i)),
421
7.24k
    Ok(index) => Ok(i.take_split(index)),
422
7.25k
  }
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
665k
  move |i: Input| match i.slice_index(c) {
420
15.0k
    Err(i) => Err(Err::Incomplete(i)),
421
650k
    Ok(index) => Ok(i.take_split(index)),
422
665k
  }
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
756k
  move |i: Input| match i.slice_index(c) {
420
38.5k
    Err(i) => Err(Err::Incomplete(i)),
421
718k
    Ok(index) => Ok(i.take_split(index)),
422
756k
  }
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
13.7k
  move |i: Input| match i.slice_index(c) {
420
307
    Err(i) => Err(Err::Incomplete(i)),
421
13.4k
    Ok(index) => Ok(i.take_split(index)),
422
13.7k
  }
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>::{closure#0}
Line
Count
Source
419
377k
  move |i: Input| match i.slice_index(c) {
420
13.5k
    Err(i) => Err(Err::Incomplete(i)),
421
363k
    Ok(index) => Ok(i.take_split(index)),
422
377k
  }
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>::{closure#0}
Line
Count
Source
419
19.0M
  move |i: Input| match i.slice_index(c) {
420
67.5k
    Err(i) => Err(Err::Incomplete(i)),
421
18.9M
    Ok(index) => Ok(i.take_split(index)),
422
19.0M
  }
nom::bytes::streaming::take::<u8, &[u8], asn1_rs::error::Error>::{closure#0}
Line
Count
Source
419
262k
  move |i: Input| match i.slice_index(c) {
420
57.2k
    Err(i) => Err(Err::Incomplete(i)),
421
205k
    Ok(index) => Ok(i.take_split(index)),
422
262k
  }
Unexecuted instantiation: nom::bytes::streaming::take::<_, _, _>::{closure#0}
nom::bytes::streaming::take::<u8, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
5.13M
  move |i: Input| match i.slice_index(c) {
420
6.47k
    Err(i) => Err(Err::Incomplete(i)),
421
5.13M
    Ok(index) => Ok(i.take_split(index)),
422
5.13M
  }
nom::bytes::streaming::take::<usize, &[u8], suricata::kerberos::SecBlobError>::{closure#0}
Line
Count
Source
419
54.4k
  move |i: Input| match i.slice_index(c) {
420
972
    Err(i) => Err(Err::Incomplete(i)),
421
53.4k
    Ok(index) => Ok(i.take_split(index)),
422
54.4k
  }
nom::bytes::streaming::take::<u8, &[u8], suricata::rdp::error::RdpError>::{closure#0}
Line
Count
Source
419
187k
  move |i: Input| match i.slice_index(c) {
420
771
    Err(i) => Err(Err::Incomplete(i)),
421
187k
    Ok(index) => Ok(i.take_split(index)),
422
187k
  }
nom::bytes::streaming::take::<u16, &[u8], suricata::rdp::error::RdpError>::{closure#0}
Line
Count
Source
419
2.56M
  move |i: Input| match i.slice_index(c) {
420
13.1k
    Err(i) => Err(Err::Incomplete(i)),
421
2.55M
    Ok(index) => Ok(i.take_split(index)),
422
2.56M
  }
nom::bytes::streaming::take::<usize, &[u8], suricata::smb::error::SmbError>::{closure#0}
Line
Count
Source
419
862k
  move |i: Input| match i.slice_index(c) {
420
87.6k
    Err(i) => Err(Err::Incomplete(i)),
421
774k
    Ok(index) => Ok(i.take_split(index)),
422
862k
  }
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
3.63M
  move |i: Input| match i.slice_index(c) {
420
190k
    Err(i) => Err(Err::Incomplete(i)),
421
3.44M
    Ok(index) => Ok(i.take_split(index)),
422
3.63M
  }
nom::bytes::streaming::take::<u16, &[u8], suricata::smb::error::SmbError>::{closure#0}
Line
Count
Source
419
224k
  move |i: Input| match i.slice_index(c) {
420
138k
    Err(i) => Err(Err::Incomplete(i)),
421
86.2k
    Ok(index) => Ok(i.take_split(index)),
422
224k
  }
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
34.8M
  move |i: Input| match i.slice_index(c) {
420
4.24M
    Err(i) => Err(Err::Incomplete(i)),
421
30.5M
    Ok(index) => Ok(i.take_split(index)),
422
34.8M
  }
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
2.30M
  move |i: Input| match i.slice_index(c) {
420
613k
    Err(i) => Err(Err::Incomplete(i)),
421
1.68M
    Ok(index) => Ok(i.take_split(index)),
422
2.30M
  }
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
421k
  move |i: Input| match i.slice_index(c) {
420
29.4k
    Err(i) => Err(Err::Incomplete(i)),
421
392k
    Ok(index) => Ok(i.take_split(index)),
422
421k
  }
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
2.55M
  move |i: Input| match i.slice_index(c) {
420
3.25k
    Err(i) => Err(Err::Incomplete(i)),
421
2.54M
    Ok(index) => Ok(i.take_split(index)),
422
2.55M
  }
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
48.8k
  move |i: Input| match i.slice_index(c) {
420
35.2k
    Err(i) => Err(Err::Incomplete(i)),
421
13.5k
    Ok(index) => Ok(i.take_split(index)),
422
48.8k
  }
nom::bytes::streaming::take::<u8, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
22.8k
  move |i: Input| match i.slice_index(c) {
420
3.96k
    Err(i) => Err(Err::Incomplete(i)),
421
18.8k
    Ok(index) => Ok(i.take_split(index)),
422
22.8k
  }
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
43.4k
  move |i: Input| match i.slice_index(c) {
420
4.23k
    Err(i) => Err(Err::Incomplete(i)),
421
39.2k
    Ok(index) => Ok(i.take_split(index)),
422
43.4k
  }
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
7.77M
  move |i: Input| match i.slice_index(c) {
420
69.0k
    Err(i) => Err(Err::Incomplete(i)),
421
7.70M
    Ok(index) => Ok(i.take_split(index)),
422
7.77M
  }
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>::{closure#0}
Line
Count
Source
419
6.88k
  move |i: Input| match i.slice_index(c) {
420
11
    Err(i) => Err(Err::Incomplete(i)),
421
6.87k
    Ok(index) => Ok(i.take_split(index)),
422
6.88k
  }
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
431k
  move |i: Input| match i.slice_index(c) {
420
26.9k
    Err(i) => Err(Err::Incomplete(i)),
421
404k
    Ok(index) => Ok(i.take_split(index)),
422
431k
  }
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
640k
  move |i: Input| match i.slice_index(c) {
420
33.6k
    Err(i) => Err(Err::Incomplete(i)),
421
607k
    Ok(index) => Ok(i.take_split(index)),
422
640k
  }
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
15.2k
  move |i: Input| match i.slice_index(c) {
420
374
    Err(i) => Err(Err::Incomplete(i)),
421
14.8k
    Ok(index) => Ok(i.take_split(index)),
422
15.2k
  }
nom::bytes::streaming::take::<usize, &[u8], der_parser::error::BerError>::{closure#0}
Line
Count
Source
419
2.12M
  move |i: Input| match i.slice_index(c) {
420
105k
    Err(i) => Err(Err::Incomplete(i)),
421
2.02M
    Ok(index) => Ok(i.take_split(index)),
422
2.12M
  }
nom::bytes::streaming::take::<u8, &[u8], der_parser::error::BerError>::{closure#0}
Line
Count
Source
419
92.1k
  move |i: Input| match i.slice_index(c) {
420
44.9k
    Err(i) => Err(Err::Incomplete(i)),
421
47.2k
    Ok(index) => Ok(i.take_split(index)),
422
92.1k
  }
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
419
13.2k
  move |i: Input| match i.slice_index(c) {
420
0
    Err(i) => Err(Err::Incomplete(i)),
421
13.2k
    Ok(index) => Ok(i.take_split(index)),
422
13.2k
  }
nom::bytes::streaming::take::<usize, &[u8], der_parser::error::BerError>::{closure#0}
Line
Count
Source
419
1.14M
  move |i: Input| match i.slice_index(c) {
420
28.2k
    Err(i) => Err(Err::Incomplete(i)),
421
1.11M
    Ok(index) => Ok(i.take_split(index)),
422
1.14M
  }
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>::{closure#0}
Line
Count
Source
419
197k
  move |i: Input| match i.slice_index(c) {
420
0
    Err(i) => Err(Err::Incomplete(i)),
421
197k
    Ok(index) => Ok(i.take_split(index)),
422
197k
  }
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>::{closure#0}
Line
Count
Source
419
12.2M
  move |i: Input| match i.slice_index(c) {
420
17.9k
    Err(i) => Err(Err::Incomplete(i)),
421
12.2M
    Ok(index) => Ok(i.take_split(index)),
422
12.2M
  }
nom::bytes::streaming::take::<u8, &[u8], asn1_rs::error::Error>::{closure#0}
Line
Count
Source
419
70.7k
  move |i: Input| match i.slice_index(c) {
420
4.63k
    Err(i) => Err(Err::Incomplete(i)),
421
66.0k
    Ok(index) => Ok(i.take_split(index)),
422
70.7k
  }
Unexecuted instantiation: nom::bytes::streaming::take::<_, _, _>::{closure#0}
423
129M
}
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
16.3M
pub fn take<C, Input, Error: ParseError<Input>>(
412
16.3M
  count: C,
413
16.3M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
16.3M
where
415
16.3M
  Input: InputIter + InputTake + InputLength,
416
16.3M
  C: ToUsize,
417
{
418
16.3M
  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.3M
}
nom::bytes::streaming::take::<usize, &[u8], suricata::kerberos::SecBlobError>
Line
Count
Source
411
72.7k
pub fn take<C, Input, Error: ParseError<Input>>(
412
72.7k
  count: C,
413
72.7k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
72.7k
where
415
72.7k
  Input: InputIter + InputTake + InputLength,
416
72.7k
  C: ToUsize,
417
{
418
72.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
72.7k
}
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
402k
pub fn take<C, Input, Error: ParseError<Input>>(
412
402k
  count: C,
413
402k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
402k
where
415
402k
  Input: InputIter + InputTake + InputLength,
416
402k
  C: ToUsize,
417
{
418
402k
  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
402k
}
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
507k
pub fn take<C, Input, Error: ParseError<Input>>(
412
507k
  count: C,
413
507k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
507k
where
415
507k
  Input: InputIter + InputTake + InputLength,
416
507k
  C: ToUsize,
417
{
418
507k
  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
507k
}
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
49.6k
pub fn take<C, Input, Error: ParseError<Input>>(
412
49.6k
  count: C,
413
49.6k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
49.6k
where
415
49.6k
  Input: InputIter + InputTake + InputLength,
416
49.6k
  C: ToUsize,
417
{
418
49.6k
  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
49.6k
}
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>
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::<u8, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
397k
pub fn take<C, Input, Error: ParseError<Input>>(
412
397k
  count: C,
413
397k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
397k
where
415
397k
  Input: InputIter + InputTake + InputLength,
416
397k
  C: ToUsize,
417
{
418
397k
  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
397k
}
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
42.0k
pub fn take<C, Input, Error: ParseError<Input>>(
412
42.0k
  count: C,
413
42.0k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
42.0k
where
415
42.0k
  Input: InputIter + InputTake + InputLength,
416
42.0k
  C: ToUsize,
417
{
418
42.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
42.0k
}
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
4.92M
pub fn take<C, Input, Error: ParseError<Input>>(
412
4.92M
  count: C,
413
4.92M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
4.92M
where
415
4.92M
  Input: InputIter + InputTake + InputLength,
416
4.92M
  C: ToUsize,
417
{
418
4.92M
  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.92M
}
nom::bytes::streaming::take::<usize, &[u8], ldap_parser::error::LdapError>
Line
Count
Source
411
1.22k
pub fn take<C, Input, Error: ParseError<Input>>(
412
1.22k
  count: C,
413
1.22k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
1.22k
where
415
1.22k
  Input: InputIter + InputTake + InputLength,
416
1.22k
  C: ToUsize,
417
{
418
1.22k
  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.22k
}
nom::bytes::streaming::take::<u8, &[u8], asn1_rs::error::Error>
Line
Count
Source
411
319k
pub fn take<C, Input, Error: ParseError<Input>>(
412
319k
  count: C,
413
319k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
319k
where
415
319k
  Input: InputIter + InputTake + InputLength,
416
319k
  C: ToUsize,
417
{
418
319k
  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
319k
}
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>
Line
Count
Source
411
5.38M
pub fn take<C, Input, Error: ParseError<Input>>(
412
5.38M
  count: C,
413
5.38M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
5.38M
where
415
5.38M
  Input: InputIter + InputTake + InputLength,
416
5.38M
  C: ToUsize,
417
{
418
5.38M
  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.38M
}
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>
Line
Count
Source
411
7.25k
pub fn take<C, Input, Error: ParseError<Input>>(
412
7.25k
  count: C,
413
7.25k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
7.25k
where
415
7.25k
  Input: InputIter + InputTake + InputLength,
416
7.25k
  C: ToUsize,
417
{
418
7.25k
  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.25k
}
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
798k
pub fn take<C, Input, Error: ParseError<Input>>(
412
798k
  count: C,
413
798k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
798k
where
415
798k
  Input: InputIter + InputTake + InputLength,
416
798k
  C: ToUsize,
417
{
418
798k
  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
798k
}
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
665k
pub fn take<C, Input, Error: ParseError<Input>>(
412
665k
  count: C,
413
665k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
665k
where
415
665k
  Input: InputIter + InputTake + InputLength,
416
665k
  C: ToUsize,
417
{
418
665k
  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
665k
}
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
13.7k
pub fn take<C, Input, Error: ParseError<Input>>(
412
13.7k
  count: C,
413
13.7k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
13.7k
where
415
13.7k
  Input: InputIter + InputTake + InputLength,
416
13.7k
  C: ToUsize,
417
{
418
13.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
13.7k
}
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>
Line
Count
Source
411
377k
pub fn take<C, Input, Error: ParseError<Input>>(
412
377k
  count: C,
413
377k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
377k
where
415
377k
  Input: InputIter + InputTake + InputLength,
416
377k
  C: ToUsize,
417
{
418
377k
  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
377k
}
nom::bytes::streaming::take::<u8, &[u8], asn1_rs::error::Error>
Line
Count
Source
411
262k
pub fn take<C, Input, Error: ParseError<Input>>(
412
262k
  count: C,
413
262k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
262k
where
415
262k
  Input: InputIter + InputTake + InputLength,
416
262k
  C: ToUsize,
417
{
418
262k
  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
262k
}
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>
Line
Count
Source
411
19.0M
pub fn take<C, Input, Error: ParseError<Input>>(
412
19.0M
  count: C,
413
19.0M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
19.0M
where
415
19.0M
  Input: InputIter + InputTake + InputLength,
416
19.0M
  C: ToUsize,
417
{
418
19.0M
  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
19.0M
}
Unexecuted instantiation: nom::bytes::streaming::take::<_, _, _>
nom::bytes::streaming::take::<u8, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
5.13M
pub fn take<C, Input, Error: ParseError<Input>>(
412
5.13M
  count: C,
413
5.13M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
5.13M
where
415
5.13M
  Input: InputIter + InputTake + InputLength,
416
5.13M
  C: ToUsize,
417
{
418
5.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
5.13M
}
nom::bytes::streaming::take::<u8, &[u8], suricata::rdp::error::RdpError>
Line
Count
Source
411
187k
pub fn take<C, Input, Error: ParseError<Input>>(
412
187k
  count: C,
413
187k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
187k
where
415
187k
  Input: InputIter + InputTake + InputLength,
416
187k
  C: ToUsize,
417
{
418
187k
  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
187k
}
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
36.0M
pub fn take<C, Input, Error: ParseError<Input>>(
412
36.0M
  count: C,
413
36.0M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
36.0M
where
415
36.0M
  Input: InputIter + InputTake + InputLength,
416
36.0M
  C: ToUsize,
417
{
418
36.0M
  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
36.0M
}
nom::bytes::streaming::take::<usize, &[u8], suricata::kerberos::SecBlobError>
Line
Count
Source
411
54.4k
pub fn take<C, Input, Error: ParseError<Input>>(
412
54.4k
  count: C,
413
54.4k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
54.4k
where
415
54.4k
  Input: InputIter + InputTake + InputLength,
416
54.4k
  C: ToUsize,
417
{
418
54.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
54.4k
}
nom::bytes::streaming::take::<usize, &[u8], suricata::smb::error::SmbError>
Line
Count
Source
411
871k
pub fn take<C, Input, Error: ParseError<Input>>(
412
871k
  count: C,
413
871k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
871k
where
415
871k
  Input: InputIter + InputTake + InputLength,
416
871k
  C: ToUsize,
417
{
418
871k
  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
871k
}
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
2.36M
pub fn take<C, Input, Error: ParseError<Input>>(
412
2.36M
  count: C,
413
2.36M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
2.36M
where
415
2.36M
  Input: InputIter + InputTake + InputLength,
416
2.36M
  C: ToUsize,
417
{
418
2.36M
  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.36M
}
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
3.70M
pub fn take<C, Input, Error: ParseError<Input>>(
412
3.70M
  count: C,
413
3.70M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
3.70M
where
415
3.70M
  Input: InputIter + InputTake + InputLength,
416
3.70M
  C: ToUsize,
417
{
418
3.70M
  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.70M
}
nom::bytes::streaming::take::<u16, &[u8], suricata::rdp::error::RdpError>
Line
Count
Source
411
2.56M
pub fn take<C, Input, Error: ParseError<Input>>(
412
2.56M
  count: C,
413
2.56M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
2.56M
where
415
2.56M
  Input: InputIter + InputTake + InputLength,
416
2.56M
  C: ToUsize,
417
{
418
2.56M
  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.56M
}
nom::bytes::streaming::take::<u16, &[u8], suricata::smb::error::SmbError>
Line
Count
Source
411
224k
pub fn take<C, Input, Error: ParseError<Input>>(
412
224k
  count: C,
413
224k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
224k
where
415
224k
  Input: InputIter + InputTake + InputLength,
416
224k
  C: ToUsize,
417
{
418
224k
  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
224k
}
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
421k
pub fn take<C, Input, Error: ParseError<Input>>(
412
421k
  count: C,
413
421k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
421k
where
415
421k
  Input: InputIter + InputTake + InputLength,
416
421k
  C: ToUsize,
417
{
418
421k
  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
421k
}
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
48.8k
pub fn take<C, Input, Error: ParseError<Input>>(
412
48.8k
  count: C,
413
48.8k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
48.8k
where
415
48.8k
  Input: InputIter + InputTake + InputLength,
416
48.8k
  C: ToUsize,
417
{
418
48.8k
  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
48.8k
}
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
2.55M
pub fn take<C, Input, Error: ParseError<Input>>(
412
2.55M
  count: C,
413
2.55M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
2.55M
where
415
2.55M
  Input: InputIter + InputTake + InputLength,
416
2.55M
  C: ToUsize,
417
{
418
2.55M
  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.55M
}
nom::bytes::streaming::take::<u8, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
223k
pub fn take<C, Input, Error: ParseError<Input>>(
412
223k
  count: C,
413
223k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
223k
where
415
223k
  Input: InputIter + InputTake + InputLength,
416
223k
  C: ToUsize,
417
{
418
223k
  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
223k
}
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
43.4k
pub fn take<C, Input, Error: ParseError<Input>>(
412
43.4k
  count: C,
413
43.4k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
43.4k
where
415
43.4k
  Input: InputIter + InputTake + InputLength,
416
43.4k
  C: ToUsize,
417
{
418
43.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
43.4k
}
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
7.77M
pub fn take<C, Input, Error: ParseError<Input>>(
412
7.77M
  count: C,
413
7.77M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
7.77M
where
415
7.77M
  Input: InputIter + InputTake + InputLength,
416
7.77M
  C: ToUsize,
417
{
418
7.77M
  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.77M
}
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>
Line
Count
Source
411
6.88k
pub fn take<C, Input, Error: ParseError<Input>>(
412
6.88k
  count: C,
413
6.88k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
6.88k
where
415
6.88k
  Input: InputIter + InputTake + InputLength,
416
6.88k
  C: ToUsize,
417
{
418
6.88k
  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.88k
}
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
694k
pub fn take<C, Input, Error: ParseError<Input>>(
412
694k
  count: C,
413
694k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
694k
where
415
694k
  Input: InputIter + InputTake + InputLength,
416
694k
  C: ToUsize,
417
{
418
694k
  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
694k
}
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
431k
pub fn take<C, Input, Error: ParseError<Input>>(
412
431k
  count: C,
413
431k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
431k
where
415
431k
  Input: InputIter + InputTake + InputLength,
416
431k
  C: ToUsize,
417
{
418
431k
  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
431k
}
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
15.2k
pub fn take<C, Input, Error: ParseError<Input>>(
412
15.2k
  count: C,
413
15.2k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
15.2k
where
415
15.2k
  Input: InputIter + InputTake + InputLength,
416
15.2k
  C: ToUsize,
417
{
418
15.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
15.2k
}
nom::bytes::streaming::take::<usize, &[u8], der_parser::error::BerError>
Line
Count
Source
411
2.12M
pub fn take<C, Input, Error: ParseError<Input>>(
412
2.12M
  count: C,
413
2.12M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
2.12M
where
415
2.12M
  Input: InputIter + InputTake + InputLength,
416
2.12M
  C: ToUsize,
417
{
418
2.12M
  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.12M
}
nom::bytes::streaming::take::<u8, &[u8], der_parser::error::BerError>
Line
Count
Source
411
92.1k
pub fn take<C, Input, Error: ParseError<Input>>(
412
92.1k
  count: C,
413
92.1k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
92.1k
where
415
92.1k
  Input: InputIter + InputTake + InputLength,
416
92.1k
  C: ToUsize,
417
{
418
92.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
92.1k
}
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
411
13.2k
pub fn take<C, Input, Error: ParseError<Input>>(
412
13.2k
  count: C,
413
13.2k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
13.2k
where
415
13.2k
  Input: InputIter + InputTake + InputLength,
416
13.2k
  C: ToUsize,
417
{
418
13.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
13.2k
}
nom::bytes::streaming::take::<usize, &[u8], der_parser::error::BerError>
Line
Count
Source
411
1.14M
pub fn take<C, Input, Error: ParseError<Input>>(
412
1.14M
  count: C,
413
1.14M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
1.14M
where
415
1.14M
  Input: InputIter + InputTake + InputLength,
416
1.14M
  C: ToUsize,
417
{
418
1.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
1.14M
}
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>
Line
Count
Source
411
197k
pub fn take<C, Input, Error: ParseError<Input>>(
412
197k
  count: C,
413
197k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
197k
where
415
197k
  Input: InputIter + InputTake + InputLength,
416
197k
  C: ToUsize,
417
{
418
197k
  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
197k
}
nom::bytes::streaming::take::<u8, &[u8], asn1_rs::error::Error>
Line
Count
Source
411
70.7k
pub fn take<C, Input, Error: ParseError<Input>>(
412
70.7k
  count: C,
413
70.7k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
70.7k
where
415
70.7k
  Input: InputIter + InputTake + InputLength,
416
70.7k
  C: ToUsize,
417
{
418
70.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
70.7k
}
nom::bytes::streaming::take::<usize, &[u8], asn1_rs::error::Error>
Line
Count
Source
411
12.2M
pub fn take<C, Input, Error: ParseError<Input>>(
412
12.2M
  count: C,
413
12.2M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
414
12.2M
where
415
12.2M
  Input: InputIter + InputTake + InputLength,
416
12.2M
  C: ToUsize,
417
{
418
12.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
12.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
14.5M
pub fn take_until<T, Input, Error: ParseError<Input>>(
447
14.5M
  tag: T,
448
14.5M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
449
14.5M
where
450
14.5M
  Input: InputTake + InputLength + FindSubstring<T>,
451
14.5M
  T: Clone,
452
{
453
14.0M
  move |i: Input| {
454
14.0M
    let t = tag.clone();
455
456
14.0M
    let res: IResult<_, _, Error> = match i.find_substring(t) {
457
821k
      None => Err(Err::Incomplete(Needed::Unknown)),
458
13.2M
      Some(index) => Ok(i.take_split(index)),
459
    };
460
14.0M
    res
461
14.0M
  }
Unexecuted instantiation: nom::bytes::streaming::take_until::<_, _, _>::{closure#0}
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::smb::error::SmbError>::{closure#0}
Line
Count
Source
453
338k
  move |i: Input| {
454
338k
    let t = tag.clone();
455
456
338k
    let res: IResult<_, _, Error> = match i.find_substring(t) {
457
67.9k
      None => Err(Err::Incomplete(Needed::Unknown)),
458
270k
      Some(index) => Ok(i.take_split(index)),
459
    };
460
338k
    res
461
338k
  }
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::rdp::error::RdpError>::{closure#0}
Line
Count
Source
453
29.3k
  move |i: Input| {
454
29.3k
    let t = tag.clone();
455
456
29.3k
    let res: IResult<_, _, Error> = match i.find_substring(t) {
457
3.24k
      None => Err(Err::Incomplete(Needed::Unknown)),
458
26.1k
      Some(index) => Ok(i.take_split(index)),
459
    };
460
29.3k
    res
461
29.3k
  }
nom::bytes::streaming::take_until::<&[u8], &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
453
2.95M
  move |i: Input| {
454
2.95M
    let t = tag.clone();
455
456
2.95M
    let res: IResult<_, _, Error> = match i.find_substring(t) {
457
293k
      None => Err(Err::Incomplete(Needed::Unknown)),
458
2.66M
      Some(index) => Ok(i.take_split(index)),
459
    };
460
2.95M
    res
461
2.95M
  }
nom::bytes::streaming::take_until::<&str, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
453
10.7M
  move |i: Input| {
454
10.7M
    let t = tag.clone();
455
456
10.7M
    let res: IResult<_, _, Error> = match i.find_substring(t) {
457
457k
      None => Err(Err::Incomplete(Needed::Unknown)),
458
10.3M
      Some(index) => Ok(i.take_split(index)),
459
    };
460
10.7M
    res
461
10.7M
  }
Unexecuted instantiation: nom::bytes::streaming::take_until::<_, _, _>::{closure#0}
462
14.5M
}
Unexecuted instantiation: nom::bytes::streaming::take_until::<_, _, _>
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::smb::error::SmbError>
Line
Count
Source
446
338k
pub fn take_until<T, Input, Error: ParseError<Input>>(
447
338k
  tag: T,
448
338k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
449
338k
where
450
338k
  Input: InputTake + InputLength + FindSubstring<T>,
451
338k
  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
338k
}
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::rdp::error::RdpError>
Line
Count
Source
446
29.3k
pub fn take_until<T, Input, Error: ParseError<Input>>(
447
29.3k
  tag: T,
448
29.3k
) -> impl Fn(Input) -> IResult<Input, Input, Error>
449
29.3k
where
450
29.3k
  Input: InputTake + InputLength + FindSubstring<T>,
451
29.3k
  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
29.3k
}
nom::bytes::streaming::take_until::<&str, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
446
11.2M
pub fn take_until<T, Input, Error: ParseError<Input>>(
447
11.2M
  tag: T,
448
11.2M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
449
11.2M
where
450
11.2M
  Input: InputTake + InputLength + FindSubstring<T>,
451
11.2M
  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
11.2M
}
nom::bytes::streaming::take_until::<&[u8], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
446
2.95M
pub fn take_until<T, Input, Error: ParseError<Input>>(
447
2.95M
  tag: T,
448
2.95M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
449
2.95M
where
450
2.95M
  Input: InputTake + InputLength + FindSubstring<T>,
451
2.95M
  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
2.95M
}
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.69M
pub fn take_until1<T, Input, Error: ParseError<Input>>(
487
2.69M
  tag: T,
488
2.69M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
489
2.69M
where
490
2.69M
  Input: InputTake + InputLength + FindSubstring<T>,
491
2.69M
  T: Clone,
492
{
493
2.65M
  move |i: Input| {
494
2.65M
    let t = tag.clone();
495
496
2.65M
    let res: IResult<_, _, Error> = match i.find_substring(t) {
497
40.6k
      None => Err(Err::Incomplete(Needed::Unknown)),
498
67.2k
      Some(0) => Err(Err::Error(Error::from_error_kind(i, ErrorKind::TakeUntil))),
499
2.54M
      Some(index) => Ok(i.take_split(index)),
500
    };
501
2.65M
    res
502
2.65M
  }
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.65M
  move |i: Input| {
494
2.65M
    let t = tag.clone();
495
496
2.65M
    let res: IResult<_, _, Error> = match i.find_substring(t) {
497
40.6k
      None => Err(Err::Incomplete(Needed::Unknown)),
498
67.2k
      Some(0) => Err(Err::Error(Error::from_error_kind(i, ErrorKind::TakeUntil))),
499
2.54M
      Some(index) => Ok(i.take_split(index)),
500
    };
501
2.65M
    res
502
2.65M
  }
Unexecuted instantiation: nom::bytes::streaming::take_until1::<_, _, _>::{closure#0}
503
2.69M
}
Unexecuted instantiation: nom::bytes::streaming::take_until1::<_, _, _>
nom::bytes::streaming::take_until1::<&str, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
486
2.69M
pub fn take_until1<T, Input, Error: ParseError<Input>>(
487
2.69M
  tag: T,
488
2.69M
) -> impl Fn(Input) -> IResult<Input, Input, Error>
489
2.69M
where
490
2.69M
  Input: InputTake + InputLength + FindSubstring<T>,
491
2.69M
  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.69M
}
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::<_, _, _, _, _, _, _, _>