use std::borrow::Cow;
use std::io;
use std::path::Path;
use crate::grouper::{DuplicateGroup, DuplicationStats};
use crate::output::check_breach::CheckBreach;
use crate::output::report::Report;
#[must_use]
pub fn display_path<'a>(base: Option<&Path>, path: &'a Path) -> Cow<'a, str> {
if let Some(base) = base
&& let Ok(rel) = path.strip_prefix(base)
{
return rel.to_string_lossy();
}
path.to_string_lossy()
}
pub trait Reporter {
fn report(&self, report: &Report<'_>) -> io::Result<String>;
fn report_check(
&self,
stats: &DuplicationStats,
breaches: &[CheckBreach<'_>],
) -> io::Result<String>;
fn report_stats(&self, stats: &DuplicationStats) -> io::Result<String>;
fn report_exact(&self, groups: &[DuplicateGroup]) -> io::Result<String>;
fn report_near(&self, groups: &[DuplicateGroup]) -> io::Result<String>;
fn report_sub_exact(&self, groups: &[DuplicateGroup]) -> io::Result<String>;
fn report_sub_near(&self, groups: &[DuplicateGroup]) -> io::Result<String>;
}