natter/src/context/element.rs

34 lines
783 B
Rust
Raw Normal View History

2023-10-27 15:32:24 -04:00
use std::path::Path;
2023-10-24 00:04:44 -04:00
use serde::Serialize;
2023-10-27 15:32:24 -04:00
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IElement;
2023-10-27 15:46:16 -04:00
use super::paragraph::RenderParagraph;
2023-10-24 00:04:44 -04:00
#[derive(Debug, Serialize)]
#[serde(untagged)]
2023-10-27 15:46:16 -04:00
pub(crate) enum RenderElement {
Paragraph(RenderParagraph),
}
2023-10-27 15:32:24 -04:00
impl RenderElement {
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
config: &Config,
output_directory: D,
output_file: F,
element: &IElement,
) -> Result<RenderElement, CustomError> {
2023-10-27 15:46:16 -04:00
match element {
IElement::Paragraph(inner) => Ok(RenderElement::Paragraph(RenderParagraph::new(
config,
output_directory,
output_file,
inner,
)?)),
}
2023-10-27 15:32:24 -04:00
}
}