2023-10-27 21:48:19 +00:00
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
use serde::Serialize;
|
|
|
|
|
|
|
|
use crate::config::Config;
|
|
|
|
use crate::error::CustomError;
|
|
|
|
use crate::intermediate::IRegularLink;
|
|
|
|
|
2023-10-28 00:43:57 +00:00
|
|
|
use super::RenderObject;
|
|
|
|
|
2023-10-27 21:48:19 +00:00
|
|
|
#[derive(Debug, Serialize)]
|
|
|
|
#[serde(tag = "type")]
|
|
|
|
#[serde(rename = "regular_link")]
|
2023-10-28 00:43:57 +00:00
|
|
|
pub(crate) struct RenderRegularLink {
|
2023-10-29 13:31:00 +00:00
|
|
|
raw_link: String,
|
2023-10-28 00:43:57 +00:00
|
|
|
children: Vec<RenderObject>,
|
|
|
|
}
|
2023-10-27 21:48:19 +00:00
|
|
|
|
|
|
|
impl RenderRegularLink {
|
2023-10-27 22:59:40 +00:00
|
|
|
pub(crate) fn new(
|
2023-10-27 21:48:19 +00:00
|
|
|
config: &Config,
|
2023-10-27 22:59:40 +00:00
|
|
|
output_directory: &Path,
|
|
|
|
output_file: &Path,
|
2023-10-28 00:43:57 +00:00
|
|
|
regular_link: &IRegularLink,
|
2023-10-27 21:48:19 +00:00
|
|
|
) -> Result<RenderRegularLink, CustomError> {
|
2023-10-28 00:43:57 +00:00
|
|
|
let children = {
|
|
|
|
let mut ret = Vec::new();
|
|
|
|
for obj in regular_link.children.iter() {
|
|
|
|
ret.push(RenderObject::new(
|
|
|
|
config,
|
|
|
|
&output_directory,
|
|
|
|
&output_file,
|
|
|
|
obj,
|
|
|
|
)?);
|
|
|
|
}
|
|
|
|
ret
|
|
|
|
};
|
|
|
|
|
|
|
|
Ok(RenderRegularLink {
|
2023-10-29 13:31:00 +00:00
|
|
|
raw_link: regular_link.raw_link.clone(),
|
2023-10-28 00:43:57 +00:00
|
|
|
children,
|
|
|
|
})
|
2023-10-27 21:48:19 +00:00
|
|
|
}
|
|
|
|
}
|