40 lines
1.0 KiB
Rust
40 lines
1.0 KiB
Rust
use crate::error::CustomError;
|
|
|
|
use super::registry::Registry;
|
|
use super::IDocumentElement;
|
|
use super::IObject;
|
|
|
|
#[derive(Debug)]
|
|
pub(crate) struct IHeading {
|
|
pub(crate) level: organic::types::HeadlineLevel,
|
|
pub(crate) title: Vec<IObject>,
|
|
pub(crate) children: Vec<IDocumentElement>,
|
|
}
|
|
|
|
impl IHeading {
|
|
pub(crate) async fn new<'parse>(
|
|
registry: &mut Registry<'parse>,
|
|
heading: &organic::types::Heading<'parse>,
|
|
) -> Result<IHeading, CustomError> {
|
|
let title = {
|
|
let mut ret = Vec::new();
|
|
for obj in heading.title.iter() {
|
|
ret.push(IObject::new(registry, obj).await?);
|
|
}
|
|
ret
|
|
};
|
|
let children = {
|
|
let mut ret = Vec::new();
|
|
for obj in heading.children.iter() {
|
|
ret.push(IDocumentElement::new(registry, obj).await?);
|
|
}
|
|
ret
|
|
};
|
|
Ok(IHeading {
|
|
title,
|
|
level: heading.level,
|
|
children,
|
|
})
|
|
}
|
|
}
|