use crate::error::LlmError;
use crate::output::OutputFormat;
use serde::Serialize;
pub fn render_json_response<T: Serialize>(
data: &T,
partial: bool,
format: OutputFormat,
) -> Result<String, LlmError> {
use crate::output::json_response_with_partial;
let payload = json_response_with_partial(data, partial);
let rendered = if matches!(format, OutputFormat::Pretty) {
serde_json::to_string_pretty(&payload)
} else {
serde_json::to_string(&payload)
}?;
Ok(rendered)
}
pub fn format_total_header(total: u64) -> String {
format!("total: {}", total)
}
pub fn format_partial_footer() -> &'static str {
"partial: true"
}
pub fn is_json_format(format: OutputFormat) -> bool {
matches!(format, OutputFormat::Json | OutputFormat::Pretty)
}