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,7 +1,7 @@
use crate::error::CustomError;
use super::macros::intermediate;
use super::registry::Registry;
use super::IObject;
use crate::error::CustomError;
#[derive(Debug, Clone)]
pub(crate) struct IRegularLink {
@@ -9,21 +9,16 @@ pub(crate) struct IRegularLink {
pub(crate) children: Vec<IObject>,
}
impl IRegularLink {
pub(crate) async fn new<'b, 'parse>(
registry: &'b mut Registry<'parse>,
original: &'b organic::types::RegularLink<'parse>,
) -> Result<IRegularLink, CustomError> {
let children = {
let mut ret = Vec::new();
for obj in original.children.iter() {
ret.push(IObject::new(registry, obj).await?);
}
ret
};
Ok(IRegularLink {
raw_link: original.get_raw_link().into_owned(),
children,
})
}
}
intermediate!(IRegularLink, RegularLink, |registry, original| async {
let children = {
let mut ret = Vec::new();
for obj in original.children.iter() {
ret.push(IObject::new(registry, obj).await?);
}
ret
};
Ok(IRegularLink {
raw_link: original.get_raw_link().into_owned(),
children,
})
});