#![deny(rustdoc::broken_intra_doc_links)]
use nom::{error::ParseError, AsChar, IResult, Parser};
pub mod complete;
pub mod streaming;
pub fn is_tchar(c: impl AsChar) -> bool {
matches!(c.as_char(),
'!' | '#' | '$' | '%' | '&' | '\'' | '*' |
'+' | '-' | '.' | '^' | '_' | '`' | '|' | '~' |
'\x41'..='\x5A' | '\x61'..='\x7A' | '\x30'..='\x39' )
}
pub fn is_qdtext(c: impl AsChar) -> bool {
matches!(c.as_char(), '\t' | ' ' | '\x21' | '\x23' ..= '\x5B' | '\x5D' ..= '\x7E' | '\u{80}' ..= '\u{FF}')
}
fn is_quoted_pair(c: impl AsChar) -> bool {
matches!(c.as_char(), '\t' | ' ' | '\x21' ..= '\x7E' | '\u{80}' ..= '\u{FF}')
}
fn optional_parser<I, O, E, L>(
condition: bool,
mut element: L,
) -> impl FnMut(I) -> IResult<I, Option<O>, E>
where
L: Parser<I, O, E>,
E: ParseError<I>,
I: Copy,
{
move |input: I| {
let res = element.parse(input);
if condition {
return Ok(match res {
Ok((k, j)) => (k, Some(j)),
Err(_) => (input, None),
});
}
match res {
Ok((k, j)) => Ok((k, Some(j))),
Err(e) => Err(e),
}
}
}
#[doc = include_str!("../README.md")]
#[cfg(doctest)]
pub struct ReadmeDoctests;