ox_content_renderer/render.rs
1//! Renderer trait and utilities.
2
3use ox_content_ast::Document;
4use thiserror::Error;
5
6/// Result type for rendering operations.
7pub type RenderResult<T> = Result<T, RenderError>;
8
9/// Render error.
10#[derive(Debug, Error)]
11pub enum RenderError {
12 /// IO error during rendering.
13 #[error("IO error: {0}")]
14 Io(#[from] std::io::Error),
15
16 /// Custom error.
17 #[error("{0}")]
18 Custom(String),
19}
20
21/// Trait for rendering Markdown AST to various output formats.
22pub trait Renderer {
23 /// The output type of the renderer.
24 type Output;
25
26 /// Renders a document to the output format.
27 fn render(&mut self, document: &Document<'_>) -> RenderResult<Self::Output>;
28}