1pub mod canonical;
7pub mod graph;
8pub mod json;
9pub mod json_canonical;
10pub mod markdown;
11pub mod mem;
12pub mod state;
13
14use crate::model::file::AgmFile;
15
16#[derive(Debug, Clone, PartialEq, thiserror::Error)]
22pub enum RenderError {
23 #[error("missing required field: {field}")]
24 MissingField { field: String },
25
26 #[error("invalid field type for '{field}': expected {expected}, got {actual}")]
27 InvalidType {
28 field: String,
29 expected: String,
30 actual: String,
31 },
32
33 #[error("invalid enum value for '{field}': {value}")]
34 InvalidEnumValue { field: String, value: String },
35
36 #[error("JSON deserialization error: {0}")]
37 JsonError(String),
38}
39
40#[derive(Debug, Clone, Copy, PartialEq, Eq)]
46pub enum RenderFormat {
47 Json,
48 JsonCanonical,
49 Markdown,
50 Canonical,
51 Dot,
52 Mermaid,
53}
54
55#[must_use]
64pub fn render(file: &AgmFile, format: RenderFormat) -> String {
65 match format {
66 RenderFormat::Json => json::render_json(file),
67 RenderFormat::JsonCanonical => json_canonical::render_json_canonical(file),
68 RenderFormat::Markdown => markdown::render_markdown(file),
69 RenderFormat::Canonical => canonical::render_canonical(file),
70 RenderFormat::Dot => graph::render_graph_dot(file),
71 RenderFormat::Mermaid => graph::render_graph_mermaid(file),
72 }
73}