Skip to main content

meta_ast/output/
mod.rs

1pub mod dashboard;
2pub mod emitter;
3pub mod graph;
4pub mod inspect;
5
6use serde::Serialize;
7
8/// Supported output serialization formats.
9#[derive(Debug, Clone, Copy, PartialEq)]
10#[non_exhaustive]
11pub enum OutputFormat {
12    Json,
13    Yaml,
14}
15
16impl OutputFormat {
17    /// Serialize a value to the chosen format.
18    pub fn serialize<T: Serialize>(&self, value: &T) -> anyhow::Result<String> {
19        match self {
20            Self::Json => Ok(serde_json::to_string_pretty(value)?),
21            Self::Yaml => Ok(yaml_serde::to_string(value)?),
22        }
23    }
24}