natter/src/context/section.rs
2023-10-29 18:46:13 -04:00

41 lines
912 B
Rust

use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::ISection;
use super::RenderElement;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "section")]
pub(crate) struct RenderSection {
children: Vec<RenderElement>,
}
impl RenderSection {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
section: &ISection,
) -> Result<RenderSection, CustomError> {
let children = {
let mut ret = Vec::new();
for obj in section.children.iter() {
ret.push(RenderElement::new(
config,
output_directory,
output_file,
obj,
)?);
}
ret
};
Ok(RenderSection { children })
}
}