1use nom::IResult;
2use nom::Parser;
3use nom::character::complete::{line_ending, not_line_ending};
4
5pub fn parse_first_line(input: &str) -> IResult<&str, (&str, &str)> {
6 ((not_line_ending, line_ending)).parse(input)
7}
8
9pub fn parse_headers(input: &str) -> IResult<&str, (&str, &str)> {
10 ((not_line_ending, line_ending)).parse(input)
11}
12
13pub fn parse_body(input: &str) -> IResult<&str, &str> {
14 (not_line_ending).parse(input)
15}
16
17#[cfg(test)]
18mod tests {
19 use super::*;
20
21 #[test]
22 fn it_works() {
23 assert_eq!(
24 parse_first_line("INVIET 8001 SIP/2.0\r\nCall-ID: 1\r\n\r\n"),
25 Ok(("Call-ID: 1\r\n\r\n", ("INVIET 8001 SIP/2.0", "\r\n")))
26 );
27 }
28}