2023-10-27 21:48:19 +00:00
|
|
|
use crate::error::CustomError;
|
|
|
|
|
|
|
|
use super::registry::Registry;
|
2023-10-28 00:43:57 +00:00
|
|
|
use super::IObject;
|
2023-10-27 21:48:19 +00:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
2023-10-28 00:43:57 +00:00
|
|
|
pub(crate) struct IRegularLink {
|
2023-10-29 13:31:00 +00:00
|
|
|
pub(crate) raw_link: String,
|
2023-10-28 00:43:57 +00:00
|
|
|
pub(crate) children: Vec<IObject>,
|
|
|
|
}
|
2023-10-27 21:48:19 +00:00
|
|
|
|
|
|
|
impl IRegularLink {
|
2023-10-29 18:14:10 +00:00
|
|
|
pub(crate) async fn new<'b, 'parse>(
|
|
|
|
registry: &'b mut Registry<'parse>,
|
|
|
|
original: &'b organic::types::RegularLink<'parse>,
|
2023-10-27 21:48:19 +00:00
|
|
|
) -> Result<IRegularLink, CustomError> {
|
2023-10-28 00:43:57 +00:00
|
|
|
let children = {
|
|
|
|
let mut ret = Vec::new();
|
|
|
|
for obj in original.children.iter() {
|
|
|
|
ret.push(IObject::new(registry, obj).await?);
|
|
|
|
}
|
|
|
|
ret
|
|
|
|
};
|
|
|
|
Ok(IRegularLink {
|
2023-10-29 13:31:00 +00:00
|
|
|
raw_link: original.get_raw_link().into_owned(),
|
2023-10-28 00:43:57 +00:00
|
|
|
children,
|
|
|
|
})
|
2023-10-27 21:48:19 +00:00
|
|
|
}
|
|
|
|
}
|