use std::iter::Iterator;
use he_di_internals::error::Error as DIError;
mod msgs;
mod extractors;
mod parsers;
pub use self::msgs::*;
pub use self::extractors::*;
pub trait Parser<T: Sized> {
fn parse_into(&self) -> Result<T, DIError>;
}
pub trait Extractor<T> {
fn extract(&self) -> Result<ExtractorIterator<T>, DIError>;
}
pub struct ExtractorIterator<T> {
iter_owned: Box<Iterator<Item=T>>,
}
impl<T> ExtractorIterator<T> {
pub fn from<I>(content: I) -> ExtractorIterator<T>
where I: Iterator<Item=T> + Sized + 'static,
{
ExtractorIterator {
iter_owned: Box::new(content),
}
}
}
impl<T> Iterator for ExtractorIterator<T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
self.iter_owned.next()
}
}