pub mod helper;
mod tag;
#[cfg(feature = "tui")]
pub mod tui;
#[cfg(feature = "tui")]
pub use self::tui::TuiTextGenerator;
use std::fmt::Display;
use crate::{error::LocatedError, parser::ItemG};
pub use tag::{Tag, TagConvertor, TagG};
pub trait Generator<'a>
where
Self::Err: LocatedError + Display,
Self::Convertor: TagConvertor<'a>,
{
type Convertor;
type Output;
type Err;
fn convertor(&mut self) -> &mut Self::Convertor;
fn generate(&mut self, markup: Vec<Vec<ItemG<'a, Self>>>) -> Result<Self::Output, Self::Err>;
}
impl<'a, G: Generator<'a>> Generator<'a> for &mut G
where
G::Err: LocatedError + Display,
G::Convertor: TagConvertor<'a>,
{
type Convertor = G::Convertor;
type Output = G::Output;
type Err = G::Err;
fn convertor(&mut self) -> &mut Self::Convertor {
<G as Generator<'a>>::convertor(self)
}
fn generate(&mut self, ir: Vec<Vec<ItemG<'a, G>>>) -> Result<Self::Output, Self::Err> {
<G as Generator<'a>>::generate(self, ir)
}
}