use std::{collections::HashMap, fmt, io};
pub mod csv;
pub mod json;
pub mod record;
use crate::parse::record::Record;
use crate::storage::Number;
pub enum ParserSettings {
Csv {
headers: Vec<String>,
delimiter: Option<u8>,
},
Json,
}
#[derive(Debug)]
pub struct ParseError;
impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "parse error")
}
}
#[derive(Debug)]
pub struct ReadError;
impl fmt::Display for ReadError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "read error")
}
}
pub trait Parser<R>: 'static
where
R: io::Read,
{
type Input: Send;
type Settings: Send;
type Reader: Iterator<Item = Result<Self::Input, ReadError>>;
fn wrap_reader(reader: R, settings: Self::Settings) -> Self::Reader;
fn parse<'a>(
&'a self,
input: &'a Self::Input,
) -> Result<Record<'a>, ParseError>;
}