natter/src/intermediate/document_element.rs

32 lines
974 B
Rust
Raw Normal View History

2023-10-27 22:59:40 +00:00
use crate::error::CustomError;
use super::registry::Registry;
use super::IHeading;
use super::ISection;
2023-10-27 22:59:40 +00:00
use futures::future::{BoxFuture, FutureExt};
#[derive(Debug)]
pub(crate) enum IDocumentElement {
Heading(IHeading),
Section(ISection),
}
2023-10-27 22:59:40 +00:00
impl IDocumentElement {
2023-10-29 16:15:07 +00:00
pub(crate) fn new<'intermediate, 'parse, 'b>(
registry: &'b mut Registry<'intermediate, 'parse>,
original: &'intermediate organic::types::DocumentElement<'parse>,
2023-10-27 22:59:40 +00:00
) -> BoxFuture<'b, Result<IDocumentElement, CustomError>> {
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()
}
}