Use macros for creating the intermediate stage.

This is to make it easier to change function signatures by consolidating the places where the signatures exist.
This commit is contained in:
Tom Alexander
2023-10-29 17:29:16 -04:00
parent ba511b7f9e
commit f98a09bc59
62 changed files with 565 additions and 972 deletions

View File

@@ -1,8 +1,8 @@
use crate::error::CustomError;
use super::macros::iselector;
use super::registry::Registry;
use super::IHeading;
use super::ISection;
use crate::error::CustomError;
use futures::future::{BoxFuture, FutureExt};
#[derive(Debug, Clone)]
@@ -11,21 +11,17 @@ pub(crate) enum IDocumentElement {
Section(ISection),
}
impl IDocumentElement {
pub(crate) fn new<'parse, 'b>(
registry: &'b mut Registry<'parse>,
original: &'b organic::types::DocumentElement<'parse>,
) -> 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?,
)),
}
iselector!(
IDocumentElement,
DocumentElement,
|registry, original| async {
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()
}
}
);