diff --git a/Cargo.toml b/Cargo.toml index 969bb6f..be55c77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ readme = "README.md" documentation = "https://docs.rs/nom-bufreader" [dependencies] -nom = "7.0.0" +nom = "8.0.0" async-trait = { version = "0.1.51", optional = true } futures = { version = "0.3.16", optional = true } pin-project-lite = { version = "0.2.7", optional = true } diff --git a/examples/async_std_http.rs b/examples/async_std_http.rs index dd15fbe..4a3f1b6 100644 --- a/examples/async_std_http.rs +++ b/examples/async_std_http.rs @@ -3,7 +3,7 @@ use nom::{ bytes::streaming::{tag, take_until}, character::streaming::space0, combinator::map_res, - IResult, + IResult, Parser, }; use nom_bufreader::async_bufreader::BufReader; use nom_bufreader::{AsyncParse, Error}; @@ -12,11 +12,12 @@ use std::str::from_utf8; fn method(i: &[u8]) -> IResult<&[u8], String, ()> { map_res(alt((tag("GET"), tag("POST"), tag("HEAD"))), |s| { from_utf8(s).map(|s| s.to_string()) - })(i) + }) + .parse(i) } fn path(i: &[u8]) -> IResult<&[u8], String, ()> { - map_res(take_until(" "), |s| from_utf8(s).map(|s| s.to_string()))(i) + map_res(take_until(" "), |s| from_utf8(s).map(|s| s.to_string())).parse(i) } fn space(i: &[u8]) -> IResult<&[u8], (), ()> { diff --git a/examples/sync_http.rs b/examples/sync_http.rs index 7617838..d309863 100644 --- a/examples/sync_http.rs +++ b/examples/sync_http.rs @@ -3,7 +3,7 @@ use nom::{ bytes::streaming::{tag, take_until}, character::streaming::space0, combinator::map_res, - IResult, + IResult, Parser, }; use nom_bufreader::bufreader::BufReader; use nom_bufreader::{Error, Parse}; @@ -12,11 +12,12 @@ use std::{net::TcpListener, str::from_utf8}; fn method(i: &[u8]) -> IResult<&[u8], String, ()> { map_res(alt((tag("GET"), tag("POST"), tag("HEAD"))), |s| { from_utf8(s).map(|s| s.to_string()) - })(i) + }) + .parse(i) } fn path(i: &[u8]) -> IResult<&[u8], String, ()> { - map_res(take_until(" "), |s| from_utf8(s).map(|s| s.to_string()))(i) + map_res(take_until(" "), |s| from_utf8(s).map(|s| s.to_string())).parse(i) } fn space(i: &[u8]) -> IResult<&[u8], (), ()> { diff --git a/examples/tokio_http.rs b/examples/tokio_http.rs index 194996e..7ed67e7 100644 --- a/examples/tokio_http.rs +++ b/examples/tokio_http.rs @@ -3,7 +3,7 @@ use nom::{ bytes::streaming::{tag, take_until}, character::streaming::space0, combinator::map_res, - IResult, + IResult, Parser, }; use nom_bufreader::async_bufreader::BufReader; use nom_bufreader::{AsyncParse, Error}; @@ -13,11 +13,12 @@ use tokio_util::compat::TokioAsyncReadCompatExt; fn method(i: &[u8]) -> IResult<&[u8], String, ()> { map_res(alt((tag("GET"), tag("POST"), tag("HEAD"))), |s| { from_utf8(s).map(|s| s.to_string()) - })(i) + }) + .parse(i) } fn path(i: &[u8]) -> IResult<&[u8], String, ()> { - map_res(take_until(" "), |s| from_utf8(s).map(|s| s.to_string()))(i) + map_res(take_until(" "), |s| from_utf8(s).map(|s| s.to_string())).parse(i) } fn space(i: &[u8]) -> IResult<&[u8], (), ()> { diff --git a/src/lib.rs b/src/lib.rs index 6fdca82..2314bd7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,13 +104,13 @@ impl From for Error { pub trait Parse { fn parse(&mut self, p: P) -> Result> where - for<'a> P: Parser<&'a [u8], O, E>; + for<'a> P: Parser<&'a [u8], Output = O, Error = E>; } impl Parse for std::io::BufReader { fn parse(&mut self, mut p: P) -> Result> where - for<'a> P: Parser<&'a [u8], O, E>, + for<'a> P: Parser<&'a [u8], Output = O, Error = E>, { loop { let opt = @@ -143,7 +143,7 @@ impl Parse for std::io::BufReader { impl Parse for bufreader::BufReader { fn parse(&mut self, mut p: P) -> Result> where - for<'a> P: Parser<&'a [u8], O, E>, + for<'a> P: Parser<&'a [u8], Output = O, Error = E>, { let mut eof = false; let mut error = None; @@ -195,7 +195,7 @@ impl Parse for bufreader::BufReader { pub trait AsyncParse { async fn parse(&mut self, p: P) -> Result> where - for<'a> P: Parser<&'a [u8], O, E> + Send + 'async_trait; + for<'a> P: Parser<&'a [u8], Output = O, Error = E> + Send + 'async_trait; } #[cfg(feature = "async")] @@ -203,7 +203,7 @@ pub trait AsyncParse { impl AsyncParse for BufReader { async fn parse(&mut self, mut p: P) -> Result> where - for<'a> P: Parser<&'a [u8], O, E> + Send + 'async_trait, + for<'a> P: Parser<&'a [u8], Output = O, Error = E> + Send + 'async_trait, { loop { let opt = @@ -240,7 +240,7 @@ impl AsyncParse { async fn parse(&mut self, mut p: P) -> Result> where - for<'a> P: Parser<&'a [u8], O, E> + Send + 'async_trait, + for<'a> P: Parser<&'a [u8], Output = O, Error = E> + Send + 'async_trait, { loop { let opt =