pub(crate) mod combinator;
pub(crate) mod component;
mod iso8601;
pub(crate) mod parsable;
mod parsed;
pub(crate) mod shim;
pub use self::parsable::Parsable;
pub use self::parsed::Parsed;
#[derive(Debug)]
pub(crate) struct ParsedItem<'a, T>(pub(crate) &'a [u8], pub(crate) T);
impl<'a, T> ParsedItem<'a, T> {
pub(crate) fn map<U>(self, f: impl FnOnce(T) -> U) -> ParsedItem<'a, U> {
ParsedItem(self.0, f(self.1))
}
pub(crate) fn flat_map<U>(self, f: impl FnOnce(T) -> Option<U>) -> Option<ParsedItem<'a, U>> {
Some(ParsedItem(self.0, f(self.1)?))
}
#[must_use = "this returns the remaining input"]
pub(crate) fn consume_value(self, f: impl FnOnce(T) -> Option<()>) -> Option<&'a [u8]> {
f(self.1)?;
Some(self.0)
}
pub(crate) fn filter(self, f: impl FnOnce(&T) -> bool) -> Option<ParsedItem<'a, T>> {
f(&self.1).then_some(self)
}
}
impl<'a> ParsedItem<'a, ()> {
#[must_use = "this returns the remaining input"]
pub(crate) const fn into_inner(self) -> &'a [u8] {
self.0
}
}
impl<'a> ParsedItem<'a, Option<()>> {
#[must_use = "this returns the remaining input"]
pub(crate) const fn into_inner(self) -> &'a [u8] {
self.0
}
}