use crate::error::BatlessResult;
use crate::file_info::FileInfo;
use crate::summary::SummaryLevel;
use crate::summary_item::SummaryItem;
pub trait LanguageDetection {
fn detect_language_with_fallback(&self, file_path: &str) -> Option<String>;
fn detect_from_content(&self, content: &str, file_path: Option<&str>) -> Option<String>;
}
pub trait SummaryExtraction {
fn extract_summary(
&self,
lines: &[String],
language: Option<&str>,
level: SummaryLevel,
) -> Vec<SummaryItem>;
fn is_summary_worthy(&self, line: &str, language: Option<&str>, level: SummaryLevel) -> bool;
}
pub trait TokenExtraction {
fn extract_tokens(&self, content: &str, file_path: &str) -> Vec<String>;
fn count_tokens(&self, content: &str) -> usize;
}
pub trait FileProcessing {
fn process_file(file_path: &str, config: &dyn ProcessingConfig) -> BatlessResult<FileInfo>;
fn process_stdin(config: &dyn ProcessingConfig) -> BatlessResult<FileInfo>;
fn validate_file_access(file_path: &str) -> BatlessResult<()>;
}
pub trait ProcessingConfig {
fn max_lines(&self) -> usize;
fn max_bytes(&self) -> Option<usize>;
fn language(&self) -> Option<&str>;
fn summary_mode(&self) -> bool;
fn include_tokens(&self) -> bool;
}
pub trait EncodingDetection {
fn detect_encoding(file_path: &str) -> BatlessResult<String>;
fn is_likely_binary(file_path: &str) -> BatlessResult<bool>;
}
pub trait ProcessorFactory {
type Processor: FileProcessing;
fn create_processor(
language_detector: Box<dyn LanguageDetection>,
summary_extractor: Box<dyn SummaryExtraction>,
token_extractor: Box<dyn TokenExtraction>,
) -> Self::Processor;
}