Coverage Report

Created: 2026-03-31 07:45

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
66.2M
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
66.2M
where
33
66.2M
  I: Input + Compare<T>,
34
66.2M
  T: Input + Clone,
35
{
36
60.7M
  move |i: I| {
37
60.7M
    let mut parser = super::Tag {
38
60.7M
      tag: tag.clone(),
39
60.7M
      e: PhantomData,
40
60.7M
    };
41
42
60.7M
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
60.7M
  }
nom::bytes::streaming::tag::<&str, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
36
1.76M
  move |i: I| {
37
1.76M
    let mut parser = super::Tag {
38
1.76M
      tag: tag.clone(),
39
1.76M
      e: PhantomData,
40
1.76M
    };
41
42
1.76M
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
1.76M
  }
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>::{closure#0}
Line
Count
Source
36
4.77M
  move |i: I| {
37
4.77M
    let mut parser = super::Tag {
38
4.77M
      tag: tag.clone(),
39
4.77M
      e: PhantomData,
40
4.77M
    };
41
42
4.77M
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
4.77M
  }
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::smb::error::SmbError>::{closure#0}
Line
Count
Source
36
164k
  move |i: I| {
37
164k
    let mut parser = super::Tag {
38
164k
      tag: tag.clone(),
39
164k
      e: PhantomData,
40
164k
    };
41
42
164k
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
164k
  }
nom::bytes::streaming::tag::<&[u8], &[u8], ()>::{closure#0}
Line
Count
Source
36
5.55k
  move |i: I| {
37
5.55k
    let mut parser = super::Tag {
38
5.55k
      tag: tag.clone(),
39
5.55k
      e: PhantomData,
40
5.55k
    };
41
42
5.55k
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
5.55k
  }
nom::bytes::streaming::tag::<&str, &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>::{closure#0}
Line
Count
Source
36
774k
  move |i: I| {
37
774k
    let mut parser = super::Tag {
38
774k
      tag: tag.clone(),
39
774k
      e: PhantomData,
40
774k
    };
41
42
774k
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
774k
  }
nom::bytes::streaming::tag::<&str, &[u8], ()>::{closure#0}
Line
Count
Source
36
198k
  move |i: I| {
37
198k
    let mut parser = super::Tag {
38
198k
      tag: tag.clone(),
39
198k
      e: PhantomData,
40
198k
    };
41
42
198k
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
198k
  }
nom::bytes::streaming::tag::<&[u8], &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
36
11.2M
  move |i: I| {
37
11.2M
    let mut parser = super::Tag {
38
11.2M
      tag: tag.clone(),
39
11.2M
      e: PhantomData,
40
11.2M
    };
41
42
11.2M
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
11.2M
  }
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::rdp::error::RdpError>::{closure#0}
Line
Count
Source
36
44.2k
  move |i: I| {
37
44.2k
    let mut parser = super::Tag {
38
44.2k
      tag: tag.clone(),
39
44.2k
      e: PhantomData,
40
44.2k
    };
41
42
44.2k
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
44.2k
  }
nom::bytes::streaming::tag::<&[u8], &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
36
108k
  move |i: I| {
37
108k
    let mut parser = super::Tag {
38
108k
      tag: tag.clone(),
39
108k
      e: PhantomData,
40
108k
    };
41
42
108k
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
108k
  }
nom::bytes::streaming::tag::<&str, &[u8], nom::error::Error<&[u8]>>::{closure#0}
Line
Count
Source
36
41.6M
  move |i: I| {
37
41.6M
    let mut parser = super::Tag {
38
41.6M
      tag: tag.clone(),
39
41.6M
      e: PhantomData,
40
41.6M
    };
41
42
41.6M
    parser.process::<OutputM<Emit, Emit, Streaming>>(i)
43
41.6M
  }
Unexecuted instantiation: nom::bytes::streaming::tag::<_, _, _>::{closure#0}
44
66.2M
}
nom::bytes::streaming::tag::<&[u8], &[u8], ()>
Line
Count
Source
31
198k
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
198k
where
33
198k
  I: Input + Compare<T>,
34
198k
  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
198k
}
nom::bytes::streaming::tag::<&str, &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>
Line
Count
Source
31
804k
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
804k
where
33
804k
  I: Input + Compare<T>,
34
804k
  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
804k
}
nom::bytes::streaming::tag::<&str, &[u8], ()>
Line
Count
Source
31
198k
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
198k
where
33
198k
  I: Input + Compare<T>,
34
198k
  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
198k
}
nom::bytes::streaming::tag::<&str, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
1.82M
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
1.82M
where
33
1.82M
  I: Input + Compare<T>,
34
1.82M
  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.82M
}
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>
Line
Count
Source
31
4.11M
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
4.11M
where
33
4.11M
  I: Input + Compare<T>,
34
4.11M
  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
4.11M
}
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::rdp::error::RdpError>
Line
Count
Source
31
44.2k
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
44.2k
where
33
44.2k
  I: Input + Compare<T>,
34
44.2k
  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
44.2k
}
nom::bytes::streaming::tag::<&[u8], &[u8], suricata::smb::error::SmbError>
Line
Count
Source
31
164k
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
164k
where
33
164k
  I: Input + Compare<T>,
34
164k
  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
164k
}
nom::bytes::streaming::tag::<&[u8], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
11.2M
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
11.2M
where
33
11.2M
  I: Input + Compare<T>,
34
11.2M
  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
11.2M
}
nom::bytes::streaming::tag::<&str, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
47.4M
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
47.4M
where
33
47.4M
  I: Input + Compare<T>,
34
47.4M
  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.4M
}
Unexecuted instantiation: nom::bytes::streaming::tag::<_, _, _>
nom::bytes::streaming::tag::<&[u8], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
31
120k
pub fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Fn(I) -> IResult<I, I, Error>
32
120k
where
33
120k
  I: Input + Compare<T>,
34
120k
  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
120k
}
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
7.34k
pub fn is_not<T, I, Error: ParseError<I>>(arr: T) -> impl FnMut(I) -> IResult<I, I, Error>
102
7.34k
where
103
7.34k
  I: Input,
104
7.34k
  T: FindToken<<I as Input>::Item>,
105
{
106
7.34k
  let mut parser = super::is_not(arr);
107
108
7.34k
  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
7.34k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::is_not::<_, _, _>::{closure#0}
109
7.34k
}
nom::bytes::streaming::is_not::<&str, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
101
7.34k
pub fn is_not<T, I, Error: ParseError<I>>(arr: T) -> impl FnMut(I) -> IResult<I, I, Error>
102
7.34k
where
103
7.34k
  I: Input,
104
7.34k
  T: FindToken<<I as Input>::Item>,
105
{
106
7.34k
  let mut parser = super::is_not(arr);
107
108
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
109
7.34k
}
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
10.7M
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
10.7M
where
168
10.7M
  I: Input,
169
10.7M
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
10.7M
  let mut parser = super::take_while(cond);
172
173
10.6M
  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
828k
  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
826k
  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
647k
  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
829k
  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
842k
  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
552k
  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
39.7k
  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
6.11M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::take_while::<_, _, _>::{closure#0}
174
10.7M
}
nom::bytes::streaming::take_while::<suricata::ssh::parser::is_not_lineend, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
39.7k
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
39.7k
where
168
39.7k
  I: Input,
169
39.7k
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
39.7k
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
39.7k
}
nom::bytes::streaming::take_while::<suricata::tftp::tftp::getstr::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
647k
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
647k
where
168
647k
  I: Input,
169
647k
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
647k
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
647k
}
nom::bytes::streaming::take_while::<suricata::sip::parser::hcolon::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
828k
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
828k
where
168
828k
  I: Input,
169
828k
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
828k
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
828k
}
nom::bytes::streaming::take_while::<suricata::sip::parser::hcolon::{closure#1}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
828k
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
828k
where
168
828k
  I: Input,
169
828k
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
828k
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
828k
}
nom::bytes::streaming::take_while::<suricata::sip::parser::is_header_name, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
829k
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
829k
where
168
829k
  I: Input,
169
829k
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
829k
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
829k
}
nom::bytes::streaming::take_while::<suricata::sip::parser::is_method_char, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
842k
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
842k
where
168
842k
  I: Input,
169
842k
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
842k
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
842k
}
nom::bytes::streaming::take_while::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
166
552k
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
552k
where
168
552k
  I: Input,
169
552k
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
552k
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
552k
}
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
6.14M
pub fn take_while<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
167
6.14M
where
168
6.14M
  I: Input,
169
6.14M
  F: Fn(<I as Input>::Item) -> bool,
170
{
171
6.14M
  let mut parser = super::take_while(cond);
172
173
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
174
6.14M
}
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
5.09M
pub fn take_while1<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
201
5.09M
where
202
5.09M
  I: Input,
203
5.09M
  F: Fn(<I as Input>::Item) -> bool,
204
{
205
5.09M
  let mut parser = super::take_while1(cond);
206
207
3.64M
  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
1.38M
  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
1.36M
  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
839k
  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
60.6k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::take_while1::<_, _, _>::{closure#0}
208
5.09M
}
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_version_char, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
200
1.38M
pub fn take_while1<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
201
1.38M
where
202
1.38M
  I: Input,
203
1.38M
  F: Fn(<I as Input>::Item) -> bool,
204
{
205
1.38M
  let mut parser = super::take_while1(cond);
206
207
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
208
1.38M
}
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_reason_phrase, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
200
1.36M
pub fn take_while1<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
201
1.36M
where
202
1.36M
  I: Input,
203
1.36M
  F: Fn(<I as Input>::Item) -> bool,
204
{
205
1.36M
  let mut parser = super::take_while1(cond);
206
207
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
208
1.36M
}
nom::bytes::streaming::take_while1::<suricata::sip::parser::is_request_uri_char, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
200
839k
pub fn take_while1<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
201
839k
where
202
839k
  I: Input,
203
839k
  F: Fn(<I as Input>::Item) -> bool,
204
{
205
839k
  let mut parser = super::take_while1(cond);
206
207
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
208
839k
}
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
1.50M
pub fn take_while1<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
201
1.50M
where
202
1.50M
  I: Input,
203
1.50M
  F: Fn(<I as Input>::Item) -> bool,
204
{
205
1.50M
  let mut parser = super::take_while1(cond);
206
207
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
208
1.50M
}
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
32.5M
pub fn take_while_m_n<F, I, Error: ParseError<I>>(
236
32.5M
  m: usize,
237
32.5M
  n: usize,
238
32.5M
  cond: F,
239
32.5M
) -> impl FnMut(I) -> IResult<I, I, Error>
240
32.5M
where
241
32.5M
  I: Input,
242
32.5M
  F: Fn(<I as Input>::Item) -> bool,
243
{
244
32.5M
  let mut parser = super::take_while_m_n(m, n, cond);
245
246
32.5M
  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
32.5M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::take_while_m_n::<_, _, _>::{closure#0}
247
32.5M
}
nom::bytes::streaming::take_while_m_n::<suricata::mqtt::parser::is_continuation_bit_set, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
235
32.5M
pub fn take_while_m_n<F, I, Error: ParseError<I>>(
236
32.5M
  m: usize,
237
32.5M
  n: usize,
238
32.5M
  cond: F,
239
32.5M
) -> impl FnMut(I) -> IResult<I, I, Error>
240
32.5M
where
241
32.5M
  I: Input,
242
32.5M
  F: Fn(<I as Input>::Item) -> bool,
243
{
244
32.5M
  let mut parser = super::take_while_m_n(m, n, cond);
245
246
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
247
32.5M
}
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
22.4M
pub fn take_till<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
274
22.4M
where
275
22.4M
  I: Input,
276
22.4M
  F: Fn(<I as Input>::Item) -> bool,
277
{
278
22.4M
  let mut parser = super::take_till(cond);
279
280
22.4M
  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.09M
  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
10.8M
  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
2.52M
  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
658
  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
30.9k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
281
22.4M
}
nom::bytes::streaming::take_till::<suricata_htp::util::take_till_lf::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
273
10.8M
pub fn take_till<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
274
10.8M
where
275
10.8M
  I: Input,
276
10.8M
  F: Fn(<I as Input>::Item) -> bool,
277
{
278
10.8M
  let mut parser = super::take_till(cond);
279
280
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
281
10.8M
}
nom::bytes::streaming::take_till::<suricata_htp::util::take_till_eol::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
273
2.52M
pub fn take_till<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
274
2.52M
where
275
2.52M
  I: Input,
276
2.52M
  F: Fn(<I as Input>::Item) -> bool,
277
{
278
2.52M
  let mut parser = super::take_till(cond);
279
280
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
281
2.52M
}
nom::bytes::streaming::take_till::<suricata_htp::util::take_till_lf_null::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
273
658
pub fn take_till<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
274
658
where
275
658
  I: Input,
276
658
  F: Fn(<I as Input>::Item) -> bool,
277
{
278
658
  let mut parser = super::take_till(cond);
279
280
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
281
658
}
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
30.9k
pub fn take_till<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
274
30.9k
where
275
30.9k
  I: Input,
276
30.9k
  F: Fn(<I as Input>::Item) -> bool,
277
{
278
30.9k
  let mut parser = super::take_till(cond);
279
280
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
281
30.9k
}
nom::bytes::streaming::take_till::<<suricata_htp::headers::Parser>::is_eol::{closure#0}, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
273
9.09M
pub fn take_till<F, I, Error: ParseError<I>>(cond: F) -> impl FnMut(I) -> IResult<I, I, Error>
274
9.09M
where
275
9.09M
  I: Input,
276
9.09M
  F: Fn(<I as Input>::Item) -> bool,
277
{
278
9.09M
  let mut parser = super::take_till(cond);
279
280
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
281
9.09M
}
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
66.9M
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
66.9M
where
341
66.9M
  I: Input,
342
66.9M
  C: ToUsize,
343
{
344
66.9M
  let mut parser = super::take(count);
345
346
51.0M
  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
19.2M
  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
3.61M
  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
17.6k
  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
274k
  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
1.00M
  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
4.71M
  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
4.38M
  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
1.79M
  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
250k
  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
15.7M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::take::<_, _, _>::{closure#0}
347
66.9M
}
nom::bytes::streaming::take::<u32, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
339
15.7M
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
15.7M
where
341
15.7M
  I: Input,
342
15.7M
  C: ToUsize,
343
{
344
15.7M
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
15.7M
}
nom::bytes::streaming::take::<usize, &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>
Line
Count
Source
339
703k
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
703k
where
341
703k
  I: Input,
342
703k
  C: ToUsize,
343
{
344
703k
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
703k
}
nom::bytes::streaming::take::<usize, &[u8], suricata::smb::error::SmbError>
Line
Count
Source
339
1.01M
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
1.01M
where
341
1.01M
  I: Input,
342
1.01M
  C: ToUsize,
343
{
344
1.01M
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
1.01M
}
nom::bytes::streaming::take::<u32, &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>
Line
Count
Source
339
4.71M
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
4.71M
where
341
4.71M
  I: Input,
342
4.71M
  C: ToUsize,
343
{
344
4.71M
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
4.71M
}
nom::bytes::streaming::take::<u16, &[u8], suricata::smb::error::SmbError>
Line
Count
Source
339
250k
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
250k
where
341
250k
  I: Input,
342
250k
  C: ToUsize,
343
{
344
250k
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
250k
}
nom::bytes::streaming::take::<usize, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
339
34.5M
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
34.5M
where
341
34.5M
  I: Input,
342
34.5M
  C: ToUsize,
343
{
344
34.5M
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
34.5M
}
nom::bytes::streaming::take::<u8, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
339
3.61M
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
3.61M
where
341
3.61M
  I: Input,
342
3.61M
  C: ToUsize,
343
{
344
3.61M
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
3.61M
}
nom::bytes::streaming::take::<u8, &[u8], suricata::rdp::error::RdpError>
Line
Count
Source
339
17.6k
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
17.6k
where
341
17.6k
  I: Input,
342
17.6k
  C: ToUsize,
343
{
344
17.6k
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
17.6k
}
nom::bytes::streaming::take::<u16, &[u8], suricata::rdp::error::RdpError>
Line
Count
Source
339
1.79M
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
1.79M
where
341
1.79M
  I: Input,
342
1.79M
  C: ToUsize,
343
{
344
1.79M
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
1.79M
}
nom::bytes::streaming::take::<u16, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
339
4.55M
pub fn take<C, I, Error: ParseError<I>>(count: C) -> impl FnMut(I) -> IResult<I, I, Error>
340
4.55M
where
341
4.55M
  I: Input,
342
4.55M
  C: ToUsize,
343
{
344
4.55M
  let mut parser = super::take(count);
345
346
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
347
4.55M
}
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
8.91M
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
371
8.91M
where
372
8.91M
  I: Input + FindSubstring<T>,
373
8.91M
  T: Clone,
374
{
375
8.91M
  let mut parser = super::take_until(tag);
376
377
8.90M
  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
5.89M
  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
2.20M
  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
35.2k
  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
242k
  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
508k
  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
14.9k
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::take_until::<_, _, _>::{closure#0}
378
8.91M
}
nom::bytes::streaming::take_until::<&str, &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
370
508k
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
371
508k
where
372
508k
  I: Input + FindSubstring<T>,
373
508k
  T: Clone,
374
{
375
508k
  let mut parser = super::take_until(tag);
376
377
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
378
508k
}
nom::bytes::streaming::take_until::<&[u8], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
370
5.89M
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
371
5.89M
where
372
5.89M
  I: Input + FindSubstring<T>,
373
5.89M
  T: Clone,
374
{
375
5.89M
  let mut parser = super::take_until(tag);
376
377
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
378
5.89M
}
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>
Line
Count
Source
370
2.21M
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
371
2.21M
where
372
2.21M
  I: Input + FindSubstring<T>,
373
2.21M
  T: Clone,
374
{
375
2.21M
  let mut parser = super::take_until(tag);
376
377
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
378
2.21M
}
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::rdp::error::RdpError>
Line
Count
Source
370
35.2k
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
371
35.2k
where
372
35.2k
  I: Input + FindSubstring<T>,
373
35.2k
  T: Clone,
374
{
375
35.2k
  let mut parser = super::take_until(tag);
376
377
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
378
35.2k
}
nom::bytes::streaming::take_until::<&[u8], &[u8], suricata::smb::error::SmbError>
Line
Count
Source
370
242k
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
371
242k
where
372
242k
  I: Input + FindSubstring<T>,
373
242k
  T: Clone,
374
{
375
242k
  let mut parser = super::take_until(tag);
376
377
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
378
242k
}
Unexecuted instantiation: nom::bytes::streaming::take_until::<_, _, _>
nom::bytes::streaming::take_until::<&[u8], &[u8], nom::error::Error<&[u8]>>
Line
Count
Source
370
14.9k
pub fn take_until<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
371
14.9k
where
372
14.9k
  I: Input + FindSubstring<T>,
373
14.9k
  T: Clone,
374
{
375
14.9k
  let mut parser = super::take_until(tag);
376
377
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
378
14.9k
}
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
1.85M
pub fn take_until1<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
403
1.85M
where
404
1.85M
  I: Input + FindSubstring<T>,
405
1.85M
  T: Clone,
406
{
407
1.85M
  let mut parser = super::take_until1(tag);
408
409
1.84M
  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
1.84M
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
Unexecuted instantiation: nom::bytes::streaming::take_until1::<_, _, _>::{closure#0}
410
1.85M
}
nom::bytes::streaming::take_until1::<&[u8], &[u8], suricata::pgsql::parser::PgsqlParseError<&[u8]>>
Line
Count
Source
402
1.85M
pub fn take_until1<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> IResult<I, I, Error>
403
1.85M
where
404
1.85M
  I: Input + FindSubstring<T>,
405
1.85M
  T: Clone,
406
{
407
1.85M
  let mut parser = super::take_until1(tag);
408
409
  move |i: I| parser.process::<OutputM<Emit, Emit, Streaming>>(i)
410
1.85M
}
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
}