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