use crate::parsers::{BaseVersionParser, FullVersionParser, VersionParser};
use crate::{BaseVersion, FullVersion, ParserError, Version};
pub use error::{ModularParserError, NumberError};
pub use parser::{ParsedBase, ParsedFull, ParsedState, Parser, Unparsed};
mod component;
mod error;
mod parser;
mod take_while_peekable;
#[derive(Debug)]
pub struct ModularParser;
impl VersionParser for ModularParser {
fn parse_version<B: AsRef<[u8]>>(&self, input: B) -> Result<Version, ParserError> {
let parser = Parser::from_slice(input.as_ref());
parser.parse().map_err(ParserError::from)
}
}
impl BaseVersionParser for ModularParser {
fn parse_base<B: AsRef<[u8]>>(&self, input: B) -> Result<BaseVersion, ParserError> {
let parser = Parser::from_slice(input.as_ref());
parser
.parse_base()
.and_then(|parser| parser.finish_base_version())
.map_err(ParserError::from)
}
}
impl FullVersionParser for ModularParser {
fn parse_full<B: AsRef<[u8]>>(&self, input: B) -> Result<FullVersion, ParserError> {
let parser = Parser::from_slice(input.as_ref());
parser
.parse_full()
.and_then(|parser| parser.finish_full_version())
.map_err(ParserError::from)
}
}