use crate::error::CustomError; use super::registry::Registry; use super::IHeading; use super::ISection; use futures::future::{BoxFuture, FutureExt}; #[derive(Debug)] pub(crate) enum IDocumentElement { Heading(IHeading), Section(ISection), } impl IDocumentElement { pub(crate) fn new<'parse, 'b>( registry: &'b mut Registry<'parse>, original: &'b organic::types::DocumentElement<'parse>, ) -> BoxFuture<'b, Result> { async move { match original { organic::types::DocumentElement::Heading(inner) => Ok(IDocumentElement::Heading( IHeading::new(registry, inner).await?, )), organic::types::DocumentElement::Section(inner) => Ok(IDocumentElement::Section( ISection::new(registry, inner).await?, )), } } .boxed() } }