#![warn(missing_docs)]
pub mod checkstyle;
pub mod json;
pub mod junit;
pub mod markdown;
pub mod sarif;
pub mod terminal;
use zuit_core::engine::Report;
pub use checkstyle::render_checkstyle;
pub use json::render_json;
pub use junit::render_junit;
pub use markdown::render_markdown;
pub use sarif::render_sarif;
pub use terminal::render_terminal;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ReportFormat {
Json,
Terminal,
Markdown,
Sarif,
Checkstyle,
Junit,
}
#[derive(Debug, Clone, Default)]
pub struct RenderOptions {
pub use_color: bool,
pub use_hyperlinks: bool,
}
#[derive(Debug, thiserror::Error)]
pub enum ReportError {
#[error("not implemented: {0}")]
NotImplemented(&'static str),
#[error("serialization error: {0}")]
Serialize(#[from] serde_json::Error),
#[error(transparent)]
Fmt(#[from] std::fmt::Error),
#[error("XML error: {0}")]
Xml(#[from] quick_xml::Error),
}
pub fn render(
format: ReportFormat,
report: &Report,
opts: &RenderOptions,
) -> Result<String, ReportError> {
match format {
ReportFormat::Json => render_json(report),
ReportFormat::Terminal => render_terminal(report, opts),
ReportFormat::Markdown => render_markdown(report),
ReportFormat::Sarif => render_sarif(report),
ReportFormat::Checkstyle => render_checkstyle(report),
ReportFormat::Junit => render_junit(report),
}
}