Coverage Report

Created: 2026-11-12 06:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/nom-8.0.0/src/bytes/streaming.rs
Line
Count
Source
1
//! Parsers recognizing bytes streams, streaming version
2
3
use core::marker::PhantomData;
4
5
use crate::error::ParseError;
6
use crate::internal::{IResult, Parser};
7
use crate::traits::{Compare, FindSubstring, FindToken, ToUsize};
8
use crate::Emit;
9
use crate::Input;
10
use crate::OutputM;
11
use crate::Streaming;
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
52.9M
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
52.9M
where
33
52.9M
  I: Input + Compare<T>,
34
52.9M
  T: Input + Clone,
35
{
36
50.4M
  move |i: I| {
37
50.4M
    let mut parser = super::Tag {
38
50.4M
      tag: tag.clone(),
39
50.4M
      e: PhantomData,
40
50.4M
    };
41
42
50.4M
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
50.4M
  }
nom::bytes::streaming::tag::<&[u8], &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
36
3.57M
  move |i: I| {
37
3.57M
    let mut parser = super::Tag {
38
3.57M
      tag: tag.clone(),
39
3.57M
      e: PhantomData,
40
3.57M
    };
41
42
3.57M
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
3.57M
  }
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::rdp::error::RdpError>::{closure#0}
Line
Count
Source
36
936
  move |i: I| {
37
936
    let mut parser = super::Tag {
38
936
      tag: tag.clone(),
39
936
      e: PhantomData,
40
936
    };
41
42
936
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
936
  }
nom::bytes::streaming::tag::<&str, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
36
36.9k
  move |i: I| {
37
36.9k
    let mut parser = super::Tag {
38
36.9k
      tag: tag.clone(),
39
36.9k
      e: PhantomData,
40
36.9k
    };
41
42
36.9k
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
36.9k
  }
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>::{closure#0}
Line
Count
Source
36
2.03M
  move |i: I| {
37
2.03M
    let mut parser = super::Tag {
38
2.03M
      tag: tag.clone(),
39
2.03M
      e: PhantomData,
40
2.03M
    };
41
42
2.03M
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
2.03M
  }
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::smb::error::SmbError>::{closure#0}
Line
Count
Source
36
30.0k
  move |i: I| {
37
30.0k
    let mut parser = super::Tag {
38
30.0k
      tag: tag.clone(),
39
30.0k
      e: PhantomData,
40
30.0k
    };
41
42
30.0k
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
30.0k
  }
nom::bytes::streaming::tag::<&[u8], &[u8], ()>::{closure#0}
Line
Count
Source
36
17
  move |i: I| {
37
17
    let mut parser = super::Tag {
38
17
      tag: tag.clone(),
39
17
      e: PhantomData,
40
17
    };
41
42
17
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
17
  }
nom::bytes::streaming::tag::<&str, &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>::{closure#0}
Line
Count
Source
36
20.5k
  move |i: I| {
37
20.5k
    let mut parser = super::Tag {
38
20.5k
      tag: tag.clone(),
39
20.5k
      e: PhantomData,
40
20.5k
    };
41
42
20.5k
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
20.5k
  }
nom::bytes::streaming::tag::<&str, &[u8], ()>::{closure#0}
Line
Count
Source
36
330
  move |i: I| {
37
330
    let mut parser = super::Tag {
38
330
      tag: tag.clone(),
39
330
      e: PhantomData,
40
330
    };
41
42
330
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
330
  }
nom::bytes::streaming::tag::<&[u8], &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
36
102k
  move |i: I| {
37
102k
    let mut parser = super::Tag {
38
102k
      tag: tag.clone(),
39
102k
      e: PhantomData,
40
102k
    };
41
42
102k
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
102k
  }
nom::bytes::streaming::tag::<&str, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
36
44.6M
  move |i: I| {
37
44.6M
    let mut parser = super::Tag {
38
44.6M
      tag: tag.clone(),
39
44.6M
      e: PhantomData,
40
44.6M
    };
41
42
44.6M
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
44.6M
  }
Unexecuted instantiation: nom::bytes::streaming::tag::<_, _, _>::{closure#0}
44
52.9M
}
nom::bytes::streaming::tag::<&[u8], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
3.57M
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
3.57M
where
33
3.57M
  I: Input + Compare<T>,
34
3.57M
  T: Input + Clone,
35
{
36
  move |i: I| {
37
    let mut parser = super::Tag {
38
      tag: tag.clone(),
39
      e: PhantomData,
40
    };
41
42
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
  }
44
3.57M
}
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>
Line
Count
Source
31
1.88M
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
1.88M
where
33
1.88M
  I: Input + Compare<T>,
34
1.88M
  T: Input + Clone,
35
{
36
  move |i: I| {
37
    let mut parser = super::Tag {
38
      tag: tag.clone(),
39
      e: PhantomData,
40
    };
41
42
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
  }
44
1.88M
}
nom::bytes::streaming::tag::<&[u8], &[u8], ()>
Line
Count
Source
31
330
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
330
where
33
330
  I: Input + Compare<T>,
34
330
  T: Input + Clone,
35
{
36
  move |i: I| {
37
    let mut parser = super::Tag {
38
      tag: tag.clone(),
39
      e: PhantomData,
40
    };
41
42
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
  }
44
330
}
nom::bytes::streaming::tag::<&str, &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>
Line
Count
Source
31
25.9k
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
25.9k
where
33
25.9k
  I: Input + Compare<T>,
34
25.9k
  T: Input + Clone,
35
{
36
  move |i: I| {
37
    let mut parser = super::Tag {
38
      tag: tag.clone(),
39
      e: PhantomData,
40
    };
41
42
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
  }
44
25.9k
}
nom::bytes::streaming::tag::<&str, &[u8], ()>
Line
Count
Source
31
330
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
330
where
33
330
  I: Input + Compare<T>,
34
330
  T: Input + Clone,
35
{
36
  move |i: I| {
37
    let mut parser = super::Tag {
38
      tag: tag.clone(),
39
      e: PhantomData,
40
    };
41
42
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
  }
44
330
}
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::rdp::error::RdpError>
Line
Count
Source
31
936
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
936
where
33
936
  I: Input + Compare<T>,
34
936
  T: Input + Clone,
35
{
36
  move |i: I| {
37
    let mut parser = super::Tag {
38
      tag: tag.clone(),
39
      e: PhantomData,
40
    };
41
42
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
  }
44
936
}
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::smb::error::SmbError>
Line
Count
Source
31
30.0k
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
30.0k
where
33
30.0k
  I: Input + Compare<T>,
34
30.0k
  T: Input + Clone,
35
{
36
  move |i: I| {
37
    let mut parser = super::Tag {
38
      tag: tag.clone(),
39
      e: PhantomData,
40
    };
41
42
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
  }
44
30.0k
}
nom::bytes::streaming::tag::<&str, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
39.9k
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
39.9k
where
33
39.9k
  I: Input + Compare<T>,
34
39.9k
  T: Input + Clone,
35
{
36
  move |i: I| {
37
    let mut parser = super::Tag {
38
      tag: tag.clone(),
39
      e: PhantomData,
40
    };
41
42
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
  }
44
39.9k
}
nom::bytes::streaming::tag::<&str, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
47.3M
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
47.3M
where
33
47.3M
  I: Input + Compare<T>,
34
47.3M
  T: Input + Clone,
35
{
36
  move |i: I| {
37
    let mut parser = super::Tag {
38
      tag: tag.clone(),
39
      e: PhantomData,
40
    };
41
42
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
  }
44
47.3M
}
Unexecuted instantiation: nom::bytes::streaming::tag::<_, _, _>
nom::bytes::streaming::tag::<&[u8], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
102k
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
102k
where
33
102k
  I: Input + Compare<T>,
34
102k
  T: Input + Clone,
35
{
36
  move |i: I| {
37
    let mut parser = super::Tag {
38
      tag: tag.clone(),
39
      e: PhantomData,
40
    };
41
42
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
  }
44
102k
}
45
46
/// Recognizes a case insensitive pattern.
47
///
48
/// The input data will be compared to the tag combinator's argument and will return the part of
49
/// the input that matches the argument with no regard to case.
50
/// # Example
51
/// ```rust
52
/// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
53
/// use nom::bytes::streaming::tag_no_case;
54
///
55
/// fn parser(s: &str) -> IResult<&str, &str> {
56
///   tag_no_case("hello")(s)
57
/// }
58
///
59
/// assert_eq!(parser("Hello, World!"), Ok((", World!", "Hello")));
60
/// assert_eq!(parser("hello, World!"), Ok((", World!", "hello")));
61
/// assert_eq!(parser("HeLlO, World!"), Ok((", World!", "HeLlO")));
62
/// assert_eq!(parser("Something"), Err(Err::Error(Error::new("Something", ErrorKind::Tag))));
63
/// assert_eq!(parser(""), Err(Err::Incomplete(Needed::new(5))));
64
/// ```
65
0
pub fn tag_no_case<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
66
0
where
67
0
  I: Input + Compare<T>,
68
0
  T: Input + Clone,
69
{
70
0
  move |i: I| {
71
0
    let mut parser = super::TagNoCase {
72
0
      tag: tag.clone(),
73
0
      e: PhantomData,
74
0
    };
75
76
0
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
77
0
  }
78
0
}
79
80
/// Parse till certain characters are met.
81
///
82
/// The parser will return the longest slice till one of the characters of the combinator's argument are met.
83
///
84
/// It doesn't consume the matched character.
85
///
86
/// It will return a `Err::Incomplete(Needed::new(1))` if the pattern wasn't met.
87
/// # Example
88
/// ```rust
89
/// # use nom::{Err, error::ErrorKind, Needed, IResult};
90
/// use nom::bytes::streaming::is_not;
91
///
92
/// fn not_space(s: &str) -> IResult<&str, &str> {
93
///   is_not(" \t\r\n")(s)
94
/// }
95
///
96
/// assert_eq!(not_space("Hello, World!"), Ok((" World!", "Hello,")));
97
/// assert_eq!(not_space("Sometimes\t"), Ok(("\t", "Sometimes")));
98
/// assert_eq!(not_space("Nospace"), Err(Err::Incomplete(Needed::new(1))));
99
/// assert_eq!(not_space(""), Err(Err::Incomplete(Needed::new(1))));
100
/// ```
101
1.93k
pub fn is_not<T, I, Error: ParseError<I>>(arr: T) -> impl FnMut(I) -> IResult<I, I, Error>
102
1.93k
where
103
1.93k
  I: Input,
104
1.93k
  T: FindToken<<I as Input>::Item>,
105
{
106
1.93k
  let mut parser = super::is_not(arr);
107
108
1.93k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::is_not::<&str, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
108
1.93k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::is_not::<_, _, _>::{closure#0}
109
1.93k
}
nom::bytes::streaming::is_not::<&str, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
101
1.93k
pub fn is_not<T, I, Error: ParseError<I>>(arr: T) -> impl FnMut(I) -> IResult<I, I, Error>
102
1.93k
where
103
1.93k
  I: Input,
104
1.93k
  T: FindToken<<I as Input>::Item>,
105
{
106
1.93k
  let mut parser = super::is_not(arr);
107
108
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
109
1.93k
}
Unexecuted instantiation: nom::bytes::streaming::is_not::<_, _, _>
110
111
/// Returns the longest slice of the matches the pattern.
112
///
113
/// The parser will return the longest slice consisting of the characters in provided in the
114
/// combinator's argument.
115
///
116
/// # Streaming specific
117
/// *Streaming version* will return a `Err::Incomplete(Needed::new(1))` if the pattern wasn't met
118
/// or if the pattern reaches the end of the input.
119
/// # Example
120
/// ```rust
121
/// # use nom::{Err, error::ErrorKind, Needed, IResult};
122
/// use nom::bytes::streaming::is_a;
123
///
124
/// fn hex(s: &str) -> IResult<&str, &str> {
125
///   is_a("1234567890ABCDEF")(s)
126
/// }
127
///
128
/// assert_eq!(hex("123 and voila"), Ok((" and voila", "123")));
129
/// assert_eq!(hex("DEADBEEF and others"), Ok((" and others", "DEADBEEF")));
130
/// assert_eq!(hex("BADBABEsomething"), Ok(("something", "BADBABE")));
131
/// assert_eq!(hex("D15EA5E"), Err(Err::Incomplete(Needed::new(1))));
132
/// assert_eq!(hex(""), Err(Err::Incomplete(Needed::new(1))));
133
/// ```
134
0
pub fn is_a<T, I, Error: ParseError<I>>(arr: T) -> impl FnMut(I) -> IResult<I, I, Error>
135
0
where
136
0
  I: Input,
137
0
  T: FindToken<<I as Input>::Item>,
138
{
139
0
  let mut parser = super::is_a(arr);
140
141
0
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
142
0
}
143
144
/// Returns the longest input slice (if any) that matches the predicate.
145
///
146
/// The parser will return the longest slice that matches the given predicate *(a function that
147
/// takes the input and returns a bool)*.
148
///
149
/// # Streaming Specific
150
/// *Streaming version* will return a `Err::Incomplete(Needed::new(1))` if the pattern reaches the end of the input.
151
/// # Example
152
/// ```rust
153
/// # use nom::{Err, error::ErrorKind, Needed, IResult};
154
/// use nom::bytes::streaming::take_while;
155
/// use nom::AsChar;
156
///
157
/// fn alpha(s: &[u8]) -> IResult<&[u8], &[u8]> {
158
///   take_while(AsChar::is_alpha)(s)
159
/// }
160
///
161
/// assert_eq!(alpha(b"latin123"), Ok((&b"123"[..], &b"latin"[..])));
162
/// assert_eq!(alpha(b"12345"), Ok((&b"12345"[..], &b""[..])));
163
/// assert_eq!(alpha(b"latin"), Err(Err::Incomplete(Needed::new(1))));
164
/// assert_eq!(alpha(b""), Err(Err::Incomplete(Needed::new(1))));
165
/// ```
166
4.82M
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
4.82M
where
168
4.82M
  I: Input,
169
4.82M
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
4.82M
  let mut parser = super::take_while(cond);
172
173
4.81M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_while::<suricata::sip::parser::hcolon::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
173
331k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_while::<suricata::sip::parser::hcolon::{closure#1}, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
173
330k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_while::<suricata::tftp::tftp::getstr::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
173
1.74k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_while::<suricata::sip::parser::is_header_name, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
173
331k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_while::<suricata::sip::parser::is_method_char, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
173
25.1k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_while::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
173
8.12k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_while::<suricata::ssh::parser::is_not_lineend, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
173
2.33k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_while::<suricata_htp::util::is_token, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
173
3.78M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::take_while::<_, _, _>::{closure#0}
174
4.82M
}
nom::bytes::streaming::take_while::<suricata::ssh::parser::is_not_lineend, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
2.33k
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
2.33k
where
168
2.33k
  I: Input,
169
2.33k
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
2.33k
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
2.33k
}
nom::bytes::streaming::take_while::<suricata::sip::parser::hcolon::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
331k
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
331k
where
168
331k
  I: Input,
169
331k
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
331k
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
331k
}
nom::bytes::streaming::take_while::<suricata::sip::parser::hcolon::{closure#1}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
331k
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
331k
where
168
331k
  I: Input,
169
331k
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
331k
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
331k
}
nom::bytes::streaming::take_while::<suricata::sip::parser::is_header_name, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
331k
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
331k
where
168
331k
  I: Input,
169
331k
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
331k
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
331k
}
nom::bytes::streaming::take_while::<suricata::sip::parser::is_method_char, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
25.1k
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
25.1k
where
168
25.1k
  I: Input,
169
25.1k
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
25.1k
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
25.1k
}
nom::bytes::streaming::take_while::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
8.12k
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
8.12k
where
168
8.12k
  I: Input,
169
8.12k
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
8.12k
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
8.12k
}
nom::bytes::streaming::take_while::<suricata::tftp::tftp::getstr::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
1.74k
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
1.74k
where
168
1.74k
  I: Input,
169
1.74k
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
1.74k
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
1.74k
}
Unexecuted instantiation: nom::bytes::streaming::take_while::<_, _, _>
nom::bytes::streaming::take_while::<suricata_htp::util::is_token, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
3.79M
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
3.79M
where
168
3.79M
  I: Input,
169
3.79M
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
3.79M
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
3.79M
}
175
176
/// Returns the longest (at least 1) input slice that matches the predicate.
177
///
178
/// The parser will return the longest slice that matches the given predicate *(a function that
179
/// takes the input and returns a bool)*.
180
///
181
/// It will return an `Err(Err::Error((_, ErrorKind::TakeWhile1)))` if the pattern wasn't met.
182
///
183
/// # Streaming Specific
184
/// *Streaming version* will return a `Err::Incomplete(Needed::new(1))` or if the pattern reaches the end of the input.
185
///
186
/// # Example
187
/// ```rust
188
/// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
189
/// use nom::bytes::streaming::take_while1;
190
/// use nom::AsChar;
191
///
192
/// fn alpha(s: &[u8]) -> IResult<&[u8], &[u8]> {
193
///   take_while1(AsChar::is_alpha)(s)
194
/// }
195
///
196
/// assert_eq!(alpha(b"latin123"), Ok((&b"123"[..], &b"latin"[..])));
197
/// assert_eq!(alpha(b"latin"), Err(Err::Incomplete(Needed::new(1))));
198
/// assert_eq!(alpha(b"12345"), Err(Err::Error(Error::new(&b"12345"[..], ErrorKind::TakeWhile1))));
199
/// ```
200
871k
pub fn take_while1<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
201
871k
where
202
871k
  I: Input,
203
871k
  F: Fn(<I as Input>::Item) -> bool,
204
{
205
871k
  let mut parser = super::take_while1(cond);
206
207
135k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_version_char, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
207
27.9k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
207
21.4k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_request_uri_char, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
207
24.7k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_while1::<<suricata_htp::headers::Parser>::complete_eol_deformed::{closure#0}::{closure#1}, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
207
61.6k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::take_while1::<_, _, _>::{closure#0}
208
871k
}
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_version_char, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
200
27.9k
pub fn take_while1<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
201
27.9k
where
202
27.9k
  I: Input,
203
27.9k
  F: Fn(<I as Input>::Item) -> bool,
204
{
205
27.9k
  let mut parser = super::take_while1(cond);
206
207
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
208
27.9k
}
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
200
21.4k
pub fn take_while1<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
201
21.4k
where
202
21.4k
  I: Input,
203
21.4k
  F: Fn(<I as Input>::Item) -> bool,
204
{
205
21.4k
  let mut parser = super::take_while1(cond);
206
207
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
208
21.4k
}
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_request_uri_char, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
200
24.7k
pub fn take_while1<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
201
24.7k
where
202
24.7k
  I: Input,
203
24.7k
  F: Fn(<I as Input>::Item) -> bool,
204
{
205
24.7k
  let mut parser = super::take_while1(cond);
206
207
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
208
24.7k
}
Unexecuted instantiation: nom::bytes::streaming::take_while1::<_, _, _>
nom::bytes::streaming::take_while1::<<suricata_htp::headers::Parser>::complete_eol_deformed::{closure#0}::{closure#1}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
200
797k
pub fn take_while1<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
201
797k
where
202
797k
  I: Input,
203
797k
  F: Fn(<I as Input>::Item) -> bool,
204
{
205
797k
  let mut parser = super::take_while1(cond);
206
207
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
208
797k
}
209
210
/// Returns the longest (m <= len <= n) input slice  that matches the predicate.
211
///
212
/// The parser will return the longest slice that matches the given predicate *(a function that
213
/// takes the input and returns a bool)*.
214
///
215
/// It will return an `Err::Error((_, ErrorKind::TakeWhileMN))` if the pattern wasn't met.
216
/// # Streaming Specific
217
/// *Streaming version* will return a `Err::Incomplete(Needed::new(1))`  if the pattern reaches the end of the input or is too short.
218
///
219
/// # Example
220
/// ```rust
221
/// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
222
/// use nom::bytes::streaming::take_while_m_n;
223
/// use nom::AsChar;
224
///
225
/// fn short_alpha(s: &[u8]) -> IResult<&[u8], &[u8]> {
226
///   take_while_m_n(3, 6, AsChar::is_alpha)(s)
227
/// }
228
///
229
/// assert_eq!(short_alpha(b"latin123"), Ok((&b"123"[..], &b"latin"[..])));
230
/// assert_eq!(short_alpha(b"lengthy"), Ok((&b"y"[..], &b"length"[..])));
231
/// assert_eq!(short_alpha(b"latin"), Err(Err::Incomplete(Needed::new(1))));
232
/// assert_eq!(short_alpha(b"ed"), Err(Err::Incomplete(Needed::new(1))));
233
/// assert_eq!(short_alpha(b"12345"), Err(Err::Error(Error::new(&b"12345"[..], ErrorKind::TakeWhileMN))));
234
/// ```
235
5.38M
pub fn take_while_m_n<F, I, Error: ParseError<I>>(
236
5.38M
  m: usize,
237
5.38M
  n: usize,
238
5.38M
  cond: F,
239
5.38M
) -> impl FnMut(I) -> IResult<I, I, Error>
240
5.38M
where
241
5.38M
  I: Input,
242
5.38M
  F: Fn(<I as Input>::Item) -> bool,
243
{
244
5.38M
  let mut parser = super::take_while_m_n(m, n, cond);
245
246
5.38M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_while_m_n::<suricata::mqtt::parser::is_continuation_bit_set, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
246
5.38M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::take_while_m_n::<_, _, _>::{closure#0}
247
5.38M
}
nom::bytes::streaming::take_while_m_n::<suricata::mqtt::parser::is_continuation_bit_set, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
235
5.38M
pub fn take_while_m_n<F, I, Error: ParseError<I>>(
236
5.38M
  m: usize,
237
5.38M
  n: usize,
238
5.38M
  cond: F,
239
5.38M
) -> impl FnMut(I) -> IResult<I, I, Error>
240
5.38M
where
241
5.38M
  I: Input,
242
5.38M
  F: Fn(<I as Input>::Item) -> bool,
243
{
244
5.38M
  let mut parser = super::take_while_m_n(m, n, cond);
245
246
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
247
5.38M
}
Unexecuted instantiation: nom::bytes::streaming::take_while_m_n::<_, _, _>
248
249
/// Returns the longest input slice (if any) till a predicate is met.
250
///
251
/// The parser will return the longest slice till the given predicate *(a function that
252
/// takes the input and returns a bool)*.
253
///
254
/// # Streaming Specific
255
/// *Streaming version* will return a `Err::Incomplete(Needed::new(1))` if the match reaches the
256
/// end of input or if there was not match.
257
///
258
/// # Example
259
/// ```rust
260
/// # use nom::{Err, error::ErrorKind, Needed, IResult};
261
/// use nom::bytes::streaming::take_till;
262
///
263
/// fn till_colon(s: &str) -> IResult<&str, &str> {
264
///   take_till(|c| c == ':')(s)
265
/// }
266
///
267
/// assert_eq!(till_colon("latin:123"), Ok((":123", "latin")));
268
/// assert_eq!(till_colon(":empty matched"), Ok((":empty matched", ""))); //allowed
269
/// assert_eq!(till_colon("12345"), Err(Err::Incomplete(Needed::new(1))));
270
/// assert_eq!(till_colon(""), Err(Err::Incomplete(Needed::new(1))));
271
/// ```
272
#[allow(clippy::redundant_closure)]
273
21.3M
pub fn take_till<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
274
21.3M
where
275
21.3M
  I: Input,
276
21.3M
  F: Fn(<I as Input>::Item) -> bool,
277
{
278
21.3M
  let mut parser = super::take_till(cond);
279
280
21.3M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_till::<<suricata_htp::headers::Parser>::is_eol::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
280
9.64M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_till::<suricata_htp::util::take_till_lf::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
280
9.88M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_till::<suricata_htp::util::take_till_eol::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
280
1.83M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_till::<suricata_htp::util::take_till_lf_null::{closure#0}, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
280
141
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::take_till::<_, _, _>::{closure#0}
nom::bytes::streaming::take_till::<<suricata_htp::connection_parser::ConnectionParser>::response_body_determine::{closure#2}, &[u8], (&[u8], nom::error::ErrorKind)>::{closure#0}
Line
Count
Source
280
25.4k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
281
21.3M
}
nom::bytes::streaming::take_till::<suricata_htp::util::take_till_lf::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
273
9.88M
pub fn take_till<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
274
9.88M
where
275
9.88M
  I: Input,
276
9.88M
  F: Fn(<I as Input>::Item) -> bool,
277
{
278
9.88M
  let mut parser = super::take_till(cond);
279
280
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
281
9.88M
}
nom::bytes::streaming::take_till::<suricata_htp::util::take_till_eol::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
273
1.83M
pub fn take_till<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
274
1.83M
where
275
1.83M
  I: Input,
276
1.83M
  F: Fn(<I as Input>::Item) -> bool,
277
{
278
1.83M
  let mut parser = super::take_till(cond);
279
280
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
281
1.83M
}
nom::bytes::streaming::take_till::<suricata_htp::util::take_till_lf_null::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
273
141
pub fn take_till<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
274
141
where
275
141
  I: Input,
276
141
  F: Fn(<I as Input>::Item) -> bool,
277
{
278
141
  let mut parser = super::take_till(cond);
279
280
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
281
141
}
Unexecuted instantiation: nom::bytes::streaming::take_till::<_, _, _>
nom::bytes::streaming::take_till::<<suricata_htp::connection_parser::ConnectionParser>::response_body_determine::{closure#2}, &[u8], (&[u8], nom::error::ErrorKind)>
Line
Count
Source
273
25.4k
pub fn take_till<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
274
25.4k
where
275
25.4k
  I: Input,
276
25.4k
  F: Fn(<I as Input>::Item) -> bool,
277
{
278
25.4k
  let mut parser = super::take_till(cond);
279
280
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
281
25.4k
}
nom::bytes::streaming::take_till::<<suricata_htp::headers::Parser>::is_eol::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
273
9.64M
pub fn take_till<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
274
9.64M
where
275
9.64M
  I: Input,
276
9.64M
  F: Fn(<I as Input>::Item) -> bool,
277
{
278
9.64M
  let mut parser = super::take_till(cond);
279
280
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
281
9.64M
}
282
283
/// Returns the longest (at least 1) input slice till a predicate is met.
284
///
285
/// The parser will return the longest slice till the given predicate *(a function that
286
/// takes the input and returns a bool)*.
287
///
288
/// # Streaming Specific
289
/// *Streaming version* will return a `Err::Incomplete(Needed::new(1))` if the match reaches the
290
/// end of input or if there was not match.
291
/// # Example
292
/// ```rust
293
/// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
294
/// use nom::bytes::streaming::take_till1;
295
///
296
/// fn till_colon(s: &str) -> IResult<&str, &str> {
297
///   take_till1(|c| c == ':')(s)
298
/// }
299
///
300
/// assert_eq!(till_colon("latin:123"), Ok((":123", "latin")));
301
/// assert_eq!(till_colon(":empty matched"), Err(Err::Error(Error::new(":empty matched", ErrorKind::TakeTill1))));
302
/// assert_eq!(till_colon("12345"), Err(Err::Incomplete(Needed::new(1))));
303
/// assert_eq!(till_colon(""), Err(Err::Incomplete(Needed::new(1))));
304
/// ```
305
#[allow(clippy::redundant_closure)]
306
0
pub fn take_till1<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
307
0
where
308
0
  I: Input,
309
0
  F: Fn(<I as Input>::Item) -> bool,
310
{
311
0
  let mut parser = super::take_till1(cond);
312
313
0
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
314
0
}
315
316
/// Returns an input slice containing the first N input elements (Input[..N]).
317
///
318
/// # Streaming Specific
319
/// *Streaming version* if the input has less than N elements, `take` will
320
/// return a `Err::Incomplete(Needed::new(M))` where M is the number of
321
/// additional bytes the parser would need to succeed.
322
/// It is well defined for `&[u8]` as the number of elements is the byte size,
323
/// but for types like `&str`, we cannot know how many bytes correspond for
324
/// the next few chars, so the result will be `Err::Incomplete(Needed::Unknown)`
325
///
326
/// # Example
327
/// ```rust
328
/// # use nom::{Err, error::ErrorKind, Needed, IResult};
329
/// use nom::bytes::streaming::take;
330
///
331
/// fn take6(s: &str) -> IResult<&str, &str> {
332
///   take(6usize)(s)
333
/// }
334
///
335
/// assert_eq!(take6("1234567"), Ok(("7", "123456")));
336
/// assert_eq!(take6("things"), Ok(("", "things")));
337
/// assert_eq!(take6("short"), Err(Err::Incomplete(Needed::Unknown)));
338
/// ```
339
11.7M
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
11.7M
where
341
11.7M
  I: Input,
342
11.7M
  C: ToUsize,
343
{
344
11.7M
  let mut parser = super::take(count);
345
346
11.0M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
346
835k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
346
8.41M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take::<u8, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
346
193k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take::<u8, &[u8], suricata::rdp::error::RdpError>::{closure#0}
Line
Count
Source
346
252
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take::<usize, &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>::{closure#0}
Line
Count
Source
346
147k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take::<usize, &[u8], suricata::smb::error::SmbError>::{closure#0}
Line
Count
Source
346
447k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take::<u32, &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>::{closure#0}
Line
Count
Source
346
667k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take::<u16, &[u8], suricata::rdp::error::RdpError>::{closure#0}
Line
Count
Source
346
9.37k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take::<u16, &[u8], suricata::smb::error::SmbError>::{closure#0}
Line
Count
Source
346
60.6k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
346
254k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::take::<_, _, _>::{closure#0}
347
11.7M
}
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
339
280k
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
280k
where
341
280k
  I: Input,
342
280k
  C: ToUsize,
343
{
344
280k
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
280k
}
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
339
9.08M
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
9.08M
where
341
9.08M
  I: Input,
342
9.08M
  C: ToUsize,
343
{
344
9.08M
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
9.08M
}
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
339
835k
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
835k
where
341
835k
  I: Input,
342
835k
  C: ToUsize,
343
{
344
835k
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
835k
}
nom::bytes::streaming::take::<usize, &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>
Line
Count
Source
339
149k
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
149k
where
341
149k
  I: Input,
342
149k
  C: ToUsize,
343
{
344
149k
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
149k
}
nom::bytes::streaming::take::<u32, &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>
Line
Count
Source
339
667k
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
667k
where
341
667k
  I: Input,
342
667k
  C: ToUsize,
343
{
344
667k
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
667k
}
nom::bytes::streaming::take::<u8, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
339
193k
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
193k
where
341
193k
  I: Input,
342
193k
  C: ToUsize,
343
{
344
193k
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
193k
}
nom::bytes::streaming::take::<u8, &[u8], suricata::rdp::error::RdpError>
Line
Count
Source
339
252
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
252
where
341
252
  I: Input,
342
252
  C: ToUsize,
343
{
344
252
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
252
}
nom::bytes::streaming::take::<u16, &[u8], suricata::rdp::error::RdpError>
Line
Count
Source
339
9.37k
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
9.37k
where
341
9.37k
  I: Input,
342
9.37k
  C: ToUsize,
343
{
344
9.37k
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
9.37k
}
nom::bytes::streaming::take::<usize, &[u8], suricata::smb::error::SmbError>
Line
Count
Source
339
459k
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
459k
where
341
459k
  I: Input,
342
459k
  C: ToUsize,
343
{
344
459k
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
459k
}
nom::bytes::streaming::take::<u16, &[u8], suricata::smb::error::SmbError>
Line
Count
Source
339
60.6k
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
60.6k
where
341
60.6k
  I: Input,
342
60.6k
  C: ToUsize,
343
{
344
60.6k
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
60.6k
}
Unexecuted instantiation: nom::bytes::streaming::take::<_, _, _>
348
349
/// Returns the input slice up to the first occurrence of the pattern.
350
///
351
/// It doesn't consume the pattern.
352
///
353
/// # Streaming Specific
354
/// *Streaming version* will return a `Err::Incomplete(Needed::new(N))` if the input doesn't
355
/// contain the pattern or if the input is smaller than the pattern.
356
/// # Example
357
/// ```rust
358
/// # use nom::{Err, error::ErrorKind, Needed, IResult};
359
/// use nom::bytes::streaming::take_until;
360
///
361
/// fn until_eof(s: &str) -> IResult<&str, &str> {
362
///   take_until("eof")(s)
363
/// }
364
///
365
/// assert_eq!(until_eof("hello, worldeof"), Ok(("eof", "hello, world")));
366
/// assert_eq!(until_eof("hello, world"), Err(Err::Incomplete(Needed::Unknown)));
367
/// assert_eq!(until_eof("hello, worldeo"), Err(Err::Incomplete(Needed::Unknown)));
368
/// assert_eq!(until_eof("1eof2eof"), Ok(("eof2eof", "1")));
369
/// ```
370
2.72M
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
371
2.72M
where
372
2.72M
  I: Input + FindSubstring<T>,
373
2.72M
  T: Clone,
374
{
375
2.72M
  let mut parser = super::take_until(tag);
376
377
2.72M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_until::<&[u8], &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
377
1.36M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>::{closure#0}
Line
Count
Source
377
974k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::rdp::error::RdpError>::{closure#0}
Line
Count
Source
377
604
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::smb::error::SmbError>::{closure#0}
Line
Count
Source
377
38.1k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_until::<&str, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
377
325k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::take_until::<_, _, _>::{closure#0}
nom::bytes::streaming::take_until::<&[u8], &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
377
20.5k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
378
2.72M
}
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>
Line
Count
Source
370
979k
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
371
979k
where
372
979k
  I: Input + FindSubstring<T>,
373
979k
  T: Clone,
374
{
375
979k
  let mut parser = super::take_until(tag);
376
377
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
378
979k
}
nom::bytes::streaming::take_until::<&[u8], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
370
1.36M
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
371
1.36M
where
372
1.36M
  I: Input + FindSubstring<T>,
373
1.36M
  T: Clone,
374
{
375
1.36M
  let mut parser = super::take_until(tag);
376
377
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
378
1.36M
}
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::rdp::error::RdpError>
Line
Count
Source
370
604
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
371
604
where
372
604
  I: Input + FindSubstring<T>,
373
604
  T: Clone,
374
{
375
604
  let mut parser = super::take_until(tag);
376
377
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
378
604
}
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::smb::error::SmbError>
Line
Count
Source
370
38.1k
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
371
38.1k
where
372
38.1k
  I: Input + FindSubstring<T>,
373
38.1k
  T: Clone,
374
{
375
38.1k
  let mut parser = super::take_until(tag);
376
377
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
378
38.1k
}
nom::bytes::streaming::take_until::<&str, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
370
325k
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
371
325k
where
372
325k
  I: Input + FindSubstring<T>,
373
325k
  T: Clone,
374
{
375
325k
  let mut parser = super::take_until(tag);
376
377
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
378
325k
}
Unexecuted instantiation: nom::bytes::streaming::take_until::<_, _, _>
nom::bytes::streaming::take_until::<&[u8], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
370
20.5k
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
371
20.5k
where
372
20.5k
  I: Input + FindSubstring<T>,
373
20.5k
  T: Clone,
374
{
375
20.5k
  let mut parser = super::take_until(tag);
376
377
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
378
20.5k
}
379
380
/// Returns the non empty input slice up to the first occurrence of the pattern.
381
///
382
/// It doesn't consume the pattern.
383
///
384
/// # Streaming Specific
385
/// *Streaming version* will return a `Err::Incomplete(Needed::new(N))` if the input doesn't
386
/// contain the pattern or if the input is smaller than the pattern.
387
/// # Example
388
/// ```rust
389
/// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
390
/// use nom::bytes::streaming::take_until1;
391
///
392
/// fn until_eof(s: &str) -> IResult<&str, &str> {
393
///   take_until1("eof")(s)
394
/// }
395
///
396
/// assert_eq!(until_eof("hello, worldeof"), Ok(("eof", "hello, world")));
397
/// assert_eq!(until_eof("hello, world"), Err(Err::Incomplete(Needed::Unknown)));
398
/// assert_eq!(until_eof("hello, worldeo"), Err(Err::Incomplete(Needed::Unknown)));
399
/// assert_eq!(until_eof("1eof2eof"), Ok(("eof2eof", "1")));
400
/// assert_eq!(until_eof("eof"),  Err(Err::Error(Error::new("eof", ErrorKind::TakeUntil))));
401
/// ```
402
915k
pub fn take_until1<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
403
915k
where
404
915k
  I: Input + FindSubstring<T>,
405
915k
  T: Clone,
406
{
407
915k
  let mut parser = super::take_until1(tag);
408
409
910k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
nom::bytes::streaming::take_until1::<&[u8], &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>::{closure#0}
Line
Count
Source
409
910k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::take_until1::<_, _, _>::{closure#0}
410
915k
}
nom::bytes::streaming::take_until1::<&[u8], &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>
Line
Count
Source
402
915k
pub fn take_until1<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
403
915k
where
404
915k
  I: Input + FindSubstring<T>,
405
915k
  T: Clone,
406
{
407
915k
  let mut parser = super::take_until1(tag);
408
409
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
410
915k
}
Unexecuted instantiation: nom::bytes::streaming::take_until1::<_, _, _>
411
412
/// Matches a byte string with escaped characters.
413
///
414
/// * The first argument matches the normal characters (it must not accept the control character)
415
/// * The second argument is the control character (like `\` in most languages)
416
/// * The third argument matches the escaped characters
417
/// # Example
418
/// ```
419
/// # use nom::{Err, error::ErrorKind, Needed, IResult};
420
/// # use nom::character::complete::digit1;
421
/// use nom::bytes::streaming::escaped;
422
/// use nom::character::streaming::one_of;
423
///
424
/// fn esc(s: &str) -> IResult<&str, &str> {
425
///   escaped(digit1, '\\', one_of("\"n\\"))(s)
426
/// }
427
///
428
/// assert_eq!(esc("123;"), Ok((";", "123")));
429
/// assert_eq!(esc("12\\\"34;"), Ok((";", "12\\\"34")));
430
/// ```
431
///
432
0
pub fn escaped<I, Error, F, G>(
433
0
  normal: F,
434
0
  control_char: char,
435
0
  escapable: G,
436
0
) -> impl FnMut(I) -> IResult<I, I, Error>
437
0
where
438
0
  I: Input + Clone + crate::traits::Offset,
439
0
  <I as Input>::Item: crate::traits::AsChar,
440
0
  F: Parser<I, Error = Error>,
441
0
  G: Parser<I, Error = Error>,
442
0
  Error: ParseError<I>,
443
{
444
0
  let mut parser = super::escaped(normal, control_char, escapable);
445
446
0
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
447
0
}
448
449
/// Matches a byte string with escaped characters.
450
///
451
/// * The first argument matches the normal characters (it must not match the control character)
452
/// * The second argument is the control character (like `\` in most languages)
453
/// * The third argument matches the escaped characters and transforms them
454
///
455
/// As an example, the chain `abc\tdef` could be `abc    def` (it also consumes the control character)
456
///
457
/// ```
458
/// # use nom::{Err, error::ErrorKind, Needed, IResult};
459
/// # use std::str::from_utf8;
460
/// use nom::bytes::streaming::{escaped_transform, tag};
461
/// use nom::character::streaming::alpha1;
462
/// use nom::branch::alt;
463
/// use nom::combinator::value;
464
///
465
/// fn parser(input: &str) -> IResult<&str, String> {
466
///   escaped_transform(
467
///     alpha1,
468
///     '\\',
469
///     alt((
470
///       value("\\", tag("\\")),
471
///       value("\"", tag("\"")),
472
///       value("\n", tag("n")),
473
///     ))
474
///   )(input)
475
/// }
476
///
477
/// assert_eq!(parser("ab\\\"cd\""), Ok(("\"", String::from("ab\"cd"))));
478
/// ```
479
#[cfg(feature = "alloc")]
480
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "alloc")))]
481
0
pub fn escaped_transform<I, Error, F, G, O1, O2, ExtendItem, Output>(
482
0
  normal: F,
483
0
  control_char: char,
484
0
  transform: G,
485
0
) -> impl FnMut(I) -> IResult<I, Output, Error>
486
0
where
487
0
  I: Clone + crate::traits::Offset + Input,
488
0
  I: crate::traits::ExtendInto<Item = ExtendItem, Extender = Output>,
489
0
  O1: crate::traits::ExtendInto<Item = ExtendItem, Extender = Output>,
490
0
  O2: crate::traits::ExtendInto<Item = ExtendItem, Extender = Output>,
491
0
  <I as Input>::Item: crate::traits::AsChar,
492
0
  F: Parser<I, Output = O1, Error = Error>,
493
0
  G: Parser<I, Output = O2, Error = Error>,
494
0
  Error: ParseError<I>,
495
{
496
0
  let mut parser = super::escaped_transform(normal, control_char, transform);
497
498
0
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
499
0
}