raqeem_core/output.rs
1//! Render a [`Transcript`] for a caller. `Text` is the human-readable verbatim
2//! transcription; `Json` carries both the verbatim and normalized forms plus
3//! provenance (what scout consumes).
4
5use crate::Transcript;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub enum OutputFormat {
9 Text,
10 Json,
11}
12
13impl OutputFormat {
14 pub fn render(self, t: &Transcript) -> String {
15 match self {
16 OutputFormat::Text => t.text.clone(),
17 OutputFormat::Json => {
18 // Transcript derives Serialize; serialization of these plain
19 // fields cannot fail, so the fallback is unreachable in practice.
20 serde_json::to_string_pretty(t).unwrap_or_else(|_| "{}".to_string())
21 }
22 }
23 }
24}