use crate::cli::OutputFormat;
use crate::core::cache::FileCache;
use crate::core::context_builder::ContextOptions;
use crate::core::walker::FileInfo;
use anyhow::Result;
use std::sync::Arc;
pub mod markdown;
pub mod paths;
pub mod plain;
pub mod xml;
pub struct DigestData<'a> {
pub files: &'a [FileInfo],
pub options: &'a ContextOptions,
pub cache: &'a Arc<FileCache>,
pub base_directory: &'a str,
}
pub trait DigestFormatter {
fn render_header(&mut self, data: &DigestData) -> Result<()>;
fn render_statistics(&mut self, data: &DigestData) -> Result<()>;
fn render_file_tree(&mut self, data: &DigestData) -> Result<()>;
fn render_toc(&mut self, data: &DigestData) -> Result<()>;
fn render_file_details(&mut self, file: &FileInfo, data: &DigestData) -> Result<()>;
fn finalize(self: Box<Self>) -> String;
fn format_name(&self) -> &'static str;
}
pub fn create_formatter(format: OutputFormat) -> Box<dyn DigestFormatter> {
match format {
OutputFormat::Markdown => Box::new(markdown::MarkdownFormatter::new()),
OutputFormat::Xml => Box::new(xml::XmlFormatter::new()),
OutputFormat::Plain => Box::new(plain::PlainFormatter::new()),
OutputFormat::Paths => Box::new(paths::PathsFormatter::new()),
}
}