Skip to content

Commit

Permalink
fix: Deprecate streaming/complete-specific parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Dec 12, 2022
1 parent 94f0289 commit f790be8
Show file tree
Hide file tree
Showing 11 changed files with 477 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/bits/complete.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! Bit level parsers
//!

#![allow(deprecated)]

use crate::error::{ErrorKind, ParseError};
use crate::input::{InputIter, InputLength, Slice, ToUsize};
use crate::lib::std::ops::{AddAssign, Div, RangeFrom, Shl, Shr};
Expand Down Expand Up @@ -30,6 +32,7 @@ use crate::{Err, IResult};
/// // Tries to consume 12 bits but only 8 are available
/// assert_eq!(parser(([0b00010010].as_ref(), 0), 12), Err(nom::Err::Error(Error{input: ([0b00010010].as_ref(), 0), code: ErrorKind::Eof })));
/// ```
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bits::take`")]
pub fn take<I, O, C, E: ParseError<(I, usize)>>(
count: C,
) -> impl Fn((I, usize)) -> IResult<(I, usize), O, E>
Expand Down Expand Up @@ -91,6 +94,7 @@ where
}

/// Generates a parser taking `count` bits and comparing them to `pattern`
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bits::tag`")]
pub fn tag<I, O, C, E: ParseError<(I, usize)>>(
pattern: O,
count: C,
Expand Down
10 changes: 10 additions & 0 deletions src/bits/streaming.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
//! Bit level parsers
//!

#![allow(deprecated)]

use crate::error::{ErrorKind, ParseError};
use crate::input::{InputIter, InputLength, Slice, ToUsize};
use crate::lib::std::ops::{AddAssign, Div, RangeFrom, Shl, Shr};
use crate::{Err, IResult, Needed};

/// Generates a parser taking `count` bits
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bits::take` with input wrapped in `nom::input::Streaming`"
)]
pub fn take<I, O, C, E: ParseError<(I, usize)>>(
count: C,
) -> impl Fn((I, usize)) -> IResult<(I, usize), O, E>
Expand Down Expand Up @@ -65,6 +71,10 @@ where
}

/// Generates a parser taking `count` bits and comparing them to `pattern`
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bits::tag` with input wrapped in `nom::input::Streaming`"
)]
pub fn tag<I, O, C, E: ParseError<(I, usize)>>(
pattern: O,
count: C,
Expand Down
19 changes: 19 additions & 0 deletions src/bytes/complete.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Parsers recognizing bytes streams, complete input version

#![allow(deprecated)]

use crate::error::ErrorKind;
use crate::error::ParseError;
use crate::input::{
Expand Down Expand Up @@ -30,6 +32,7 @@ use crate::{Err, IResult, Parser};
/// assert_eq!(parser("Something"), Err(Err::Error(Error::new("Something", ErrorKind::Tag))));
/// assert_eq!(parser(""), Err(Err::Error(Error::new("", ErrorKind::Tag))));
/// ```
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bytes::tag`")]
pub fn tag<T, Input, Error: ParseError<Input>>(
tag: T,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -82,6 +85,7 @@ where
/// assert_eq!(parser("Something"), Err(Err::Error(Error::new("Something", ErrorKind::Tag))));
/// assert_eq!(parser(""), Err(Err::Error(Error::new("", ErrorKind::Tag))));
/// ```
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bytes::tag_no_case`")]
pub fn tag_no_case<T, Input, Error: ParseError<Input>>(
tag: T,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -135,6 +139,7 @@ where
/// assert_eq!(not_space("Nospace"), Ok(("", "Nospace")));
/// assert_eq!(not_space(""), Err(Err::Error(Error::new("", ErrorKind::IsNot))));
/// ```
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bytes::is_not`")]
pub fn is_not<T, Input, Error: ParseError<Input>>(
arr: T,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -181,6 +186,7 @@ where
/// assert_eq!(hex("D15EA5E"), Ok(("", "D15EA5E")));
/// assert_eq!(hex(""), Err(Err::Error(Error::new("", ErrorKind::IsA))));
/// ```
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bytes::is_a`")]
pub fn is_a<T, Input, Error: ParseError<Input>>(
arr: T,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -225,6 +231,7 @@ where
/// assert_eq!(alpha(b"latin"), Ok((&b""[..], &b"latin"[..])));
/// assert_eq!(alpha(b""), Ok((&b""[..], &b""[..])));
/// ```
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bytes::take_while`")]
pub fn take_while<F, Input, Error: ParseError<Input>>(
cond: F,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -268,6 +275,7 @@ where
/// assert_eq!(alpha(b"latin"), Ok((&b""[..], &b"latin"[..])));
/// assert_eq!(alpha(b"12345"), Err(Err::Error(Error::new(&b"12345"[..], ErrorKind::TakeWhile1))));
/// ```
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bytes::take_while1`")]
pub fn take_while1<F, Input, Error: ParseError<Input>>(
cond: F,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -315,6 +323,7 @@ where
/// assert_eq!(short_alpha(b"ed"), Err(Err::Error(Error::new(&b"ed"[..], ErrorKind::TakeWhileMN))));
/// assert_eq!(short_alpha(b"12345"), Err(Err::Error(Error::new(&b"12345"[..], ErrorKind::TakeWhileMN))));
/// ```
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bytes::take_while_m_n`")]
pub fn take_while_m_n<F, Input, Error: ParseError<Input>>(
m: usize,
n: usize,
Expand Down Expand Up @@ -407,6 +416,7 @@ where
/// assert_eq!(till_colon("12345"), Ok(("", "12345")));
/// assert_eq!(till_colon(""), Ok(("", "")));
/// ```
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bytes::take_till`")]
pub fn take_till<F, Input, Error: ParseError<Input>>(
cond: F,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -451,6 +461,7 @@ where
/// assert_eq!(till_colon("12345"), Ok(("", "12345")));
/// assert_eq!(till_colon(""), Err(Err::Error(Error::new("", ErrorKind::TakeTill1))));
/// ```
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bytes::take_till1`")]
pub fn take_till1<F, Input, Error: ParseError<Input>>(
cond: F,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -504,6 +515,7 @@ where
/// assert_eq!(take::<_, _, Error<_>>(1usize)("💙"), Ok(("", "💙")));
/// assert_eq!(take::<_, _, Error<_>>(1usize)("💙".as_bytes()), Ok((b"\x9F\x92\x99".as_ref(), b"\xF0".as_ref())));
/// ```
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bytes::take`")]
pub fn take<C, Input, Error: ParseError<Input>>(
count: C,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -548,6 +560,7 @@ where
/// assert_eq!(until_eof(""), Err(Err::Error(Error::new("", ErrorKind::TakeUntil))));
/// assert_eq!(until_eof("1eof2eof"), Ok(("eof2eof", "1")));
/// ```
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bytes::take_until`")]
pub fn take_until<T, Input, Error: ParseError<Input>>(
tag: T,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -594,6 +607,7 @@ where
/// assert_eq!(until_eof("1eof2eof"), Ok(("eof2eof", "1")));
/// assert_eq!(until_eof("eof"), Err(Err::Error(Error::new("eof", ErrorKind::TakeUntil))));
/// ```
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bytes::take_until1`")]
pub fn take_until1<T, Input, Error: ParseError<Input>>(
tag: T,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -642,6 +656,7 @@ where
/// assert_eq!(esc(r#"12\"34;"#), Ok((";", r#"12\"34"#)));
/// ```
///
#[deprecated(since = "8.0.0", note = "Replaced with `nom::bytes::escaped`")]
pub fn escaped<'a, Input: 'a, Error, F, G, O1, O2>(
mut normal: F,
control_char: char,
Expand Down Expand Up @@ -777,6 +792,10 @@ where
/// assert_eq!(parser("ab\\ncd"), Ok(("", String::from("ab\ncd"))));
/// ```
#[cfg(feature = "alloc")]
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::escaped_transform`"
)]
pub fn escaped_transform<Input, Error, F, G, O1, O2, ExtendItem, Output>(
mut normal: F,
control_char: char,
Expand Down
58 changes: 58 additions & 0 deletions src/bytes/streaming.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Parsers recognizing bytes streams, streaming version

#![allow(deprecated)]

use crate::error::ErrorKind;
use crate::error::ParseError;
use crate::input::{
Expand Down Expand Up @@ -29,6 +31,10 @@ use crate::{Err, IResult, Needed, Parser};
/// assert_eq!(parser("S"), Err(Err::Error(Error::new("S", ErrorKind::Tag))));
/// assert_eq!(parser("H"), Err(Err::Incomplete(Needed::new(4))));
/// ```
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::tag` with input wrapped in `nom::input::Streaming`"
)]
pub fn tag<T, Input, Error: ParseError<Input>>(
tag: T,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -81,6 +87,10 @@ where
/// assert_eq!(parser("Something"), Err(Err::Error(Error::new("Something", ErrorKind::Tag))));
/// assert_eq!(parser(""), Err(Err::Incomplete(Needed::new(5))));
/// ```
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::tag_no_case` with input wrapped in `nom::input::Streaming`"
)]
pub fn tag_no_case<T, Input, Error: ParseError<Input>>(
tag: T,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -135,6 +145,10 @@ where
/// assert_eq!(not_space("Nospace"), Err(Err::Incomplete(Needed::new(1))));
/// assert_eq!(not_space(""), Err(Err::Incomplete(Needed::new(1))));
/// ```
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::is_not` with input wrapped in `nom::input::Streaming`"
)]
pub fn is_not<T, Input, Error: ParseError<Input>>(
arr: T,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -183,6 +197,10 @@ where
/// assert_eq!(hex("D15EA5E"), Err(Err::Incomplete(Needed::new(1))));
/// assert_eq!(hex(""), Err(Err::Incomplete(Needed::new(1))));
/// ```
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::is_a` with input wrapped in `nom::input::Streaming`"
)]
pub fn is_a<T, Input, Error: ParseError<Input>>(
arr: T,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -230,6 +248,10 @@ where
/// assert_eq!(alpha(b"latin"), Err(Err::Incomplete(Needed::new(1))));
/// assert_eq!(alpha(b""), Err(Err::Incomplete(Needed::new(1))));
/// ```
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::take_while` with input wrapped in `nom::input::Streaming`"
)]
pub fn take_while<F, Input, Error: ParseError<Input>>(
cond: F,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -277,6 +299,10 @@ where
/// assert_eq!(alpha(b"latin"), Err(Err::Incomplete(Needed::new(1))));
/// assert_eq!(alpha(b"12345"), Err(Err::Error(Error::new(&b"12345"[..], ErrorKind::TakeWhile1))));
/// ```
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::take_while1` with input wrapped in `nom::input::Streaming`"
)]
pub fn take_while1<F, Input, Error: ParseError<Input>>(
cond: F,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -327,6 +353,10 @@ where
/// assert_eq!(short_alpha(b"ed"), Err(Err::Incomplete(Needed::new(1))));
/// assert_eq!(short_alpha(b"12345"), Err(Err::Error(Error::new(&b"12345"[..], ErrorKind::TakeWhileMN))));
/// ```
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::take_while_m_n` with input wrapped in `nom::input::Streaming`"
)]
pub fn take_while_m_n<F, Input, Error: ParseError<Input>>(
m: usize,
n: usize,
Expand Down Expand Up @@ -423,6 +453,10 @@ where
/// assert_eq!(till_colon("12345"), Err(Err::Incomplete(Needed::new(1))));
/// assert_eq!(till_colon(""), Err(Err::Incomplete(Needed::new(1))));
/// ```
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::take_till` with input wrapped in `nom::input::Streaming`"
)]
pub fn take_till<F, Input, Error: ParseError<Input>>(
cond: F,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -468,6 +502,10 @@ where
/// assert_eq!(till_colon("12345"), Err(Err::Incomplete(Needed::new(1))));
/// assert_eq!(till_colon(""), Err(Err::Incomplete(Needed::new(1))));
/// ```
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::take_till1` with input wrapped in `nom::input::Streaming`"
)]
pub fn take_till1<F, Input, Error: ParseError<Input>>(
cond: F,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -515,6 +553,10 @@ where
/// assert_eq!(take6("things"), Ok(("", "things")));
/// assert_eq!(take6("short"), Err(Err::Incomplete(Needed::Unknown)));
/// ```
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::take` with input wrapped in `nom::input::Streaming`"
)]
pub fn take<C, Input, Error: ParseError<Input>>(
count: C,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -562,6 +604,10 @@ where
/// assert_eq!(until_eof("hello, worldeo"), Err(Err::Incomplete(Needed::Unknown)));
/// assert_eq!(until_eof("1eof2eof"), Ok(("eof2eof", "1")));
/// ```
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::take_until` with input wrapped in `nom::input::Streaming`"
)]
pub fn take_until<T, Input, Error: ParseError<Input>>(
tag: T,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -610,6 +656,10 @@ where
/// assert_eq!(until_eof("1eof2eof"), Ok(("eof2eof", "1")));
/// assert_eq!(until_eof("eof"), Err(Err::Error(Error::new("eof", ErrorKind::TakeUntil))));
/// ```
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::take_until1` with input wrapped in `nom::input::Streaming`"
)]
pub fn take_until1<T, Input, Error: ParseError<Input>>(
tag: T,
) -> impl Fn(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
Expand Down Expand Up @@ -657,6 +707,10 @@ where
/// assert_eq!(esc("12\\\"34;"), Ok((";", "12\\\"34")));
/// ```
///
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::escaped` with input wrapped in `nom::input::Streaming`"
)]
pub fn escaped<Input, Error, F, G, O1, O2>(
mut normal: F,
control_char: char,
Expand Down Expand Up @@ -780,6 +834,10 @@ where
/// assert_eq!(parser("ab\\\"cd\""), Ok(("\"", String::from("ab\"cd"))));
/// ```
#[cfg(feature = "alloc")]
#[deprecated(
since = "8.0.0",
note = "Replaced with `nom::bytes::escaped_transform` with input wrapped in `nom::input::Streaming`"
)]
pub fn escaped_transform<Input, Error, F, G, O1, O2, ExtendItem, Output>(
mut normal: F,
control_char: char,
Expand Down
Loading

0 comments on commit f790be8

Please sign in to comment.