use crate::attributes;
use crate::tag::Tag;
use crate::text::Text;
use attributes::Attribute;
use derive_more::{From, Into};
use std::collections::HashMap;
type Void = ();
type Normal<'a> = Vec<Node<'a>>;
pub type Attributes<'a> = HashMap<Attribute<'a>, Option<attributes::Value<'a>>>;
#[derive(Clone, From)]
pub enum Node<'a> {
Text(Text),
Comment(Comment),
Element(Element<'a, Normal<'a>>),
Void(Element<'a, Void>),
}
#[derive(From, Into, Clone)]
pub struct Comment(String);
#[derive(Clone)]
pub struct Element<'a, T>
where
T: ElementType,
{
pub name: Tag<'a>,
pub attributes: Attributes<'a>,
pub children: T,
}
pub trait ElementType: private::Sealed + Default {}
mod private {
impl super::ElementType for super::Void {}
impl<'a> super::ElementType for super::Normal<'a> {}
pub trait Sealed {}
impl Sealed for () {}
impl<'a> Sealed for Vec<super::Node<'a>> {}
}