use std::path::Path; use crate::config::Config; use crate::error::CustomError; /// The supporting information used for converting the intermediate representation into the dust context for rendering. #[derive(Debug, Clone)] pub(crate) struct RenderContext<'intermediate> { pub(crate) config: &'intermediate Config, // TODO: Perhaps rename to output_root_directory. pub(crate) output_directory: &'intermediate Path, pub(crate) output_file: &'intermediate Path, /// An optional string that gets added to IDs in HTML. /// /// This is useful for cases where you may have conflicting HTML /// IDs, for example, multiple blog posts with footnotes in a blog /// stream. pub(crate) id_addition: Option<&'intermediate str>, } impl<'intermediate> RenderContext<'intermediate> { pub(crate) fn new( config: &'intermediate Config, output_directory: &'intermediate Path, output_file: &'intermediate Path, id_addition: Option<&'intermediate str>, ) -> Result, CustomError> { Ok(RenderContext { config, output_directory, output_file, id_addition, }) } }