use crate::essence::{
EssenceModeProcessor, EssenceModeValidation, TimestampFormat, TimestampMatch,
};
use crate::patterns::timestamp::TimestampDetector;
pub struct EssenceProcessor {
enabled: bool,
timestamps_replaced: u64,
}
impl EssenceProcessor {
#[allow(dead_code)]
fn increment_timestamps_replaced(&mut self) {
self.timestamps_replaced += 1;
}
}
impl EssenceModeProcessor for EssenceProcessor {
fn new(enabled: bool) -> Self {
EssenceProcessor {
enabled,
timestamps_replaced: 0,
}
}
fn process_line(&self, line: &str) -> String {
if !self.enabled {
return line.to_string();
}
let (result, _tokens) = TimestampDetector::detect_and_replace(line);
result
}
fn set_enabled(&mut self, enabled: bool) {
self.enabled = enabled;
}
fn is_enabled(&self) -> bool {
self.enabled
}
fn get_timestamps_replaced(&self) -> u64 {
self.timestamps_replaced
}
fn get_supported_formats_count(&self) -> usize {
use crate::patterns::timestamp::TimestampRegistry;
TimestampRegistry::new().get_patterns().len()
}
fn validate_constitutional_compliance(&self) -> EssenceModeValidation {
use crate::patterns::timestamp::TimestampRegistry;
let pattern_count = TimestampRegistry::new().get_patterns().len();
EssenceModeValidation {
is_non_default: !self.enabled, supports_all_formats: pattern_count >= 30, preserves_structure: true, achieves_independence: true, }
}
}
pub fn detect_timestamps(line: &str) -> Vec<TimestampMatch> {
use crate::patterns::timestamp::UnifiedTimestampDetector;
let result = UnifiedTimestampDetector::detect_with_metadata(line);
result
.matches
.into_iter()
.map(|m| TimestampMatch {
original: m.original,
format_type: TimestampFormat::ISO8601Full, start_pos: m.start_pos,
end_pos: m.end_pos,
})
.collect()
}
pub fn tokenize_timestamps(line: &str, _token: &str) -> String {
use crate::patterns::timestamp::TimestampDetector;
let (result, _tokens) = TimestampDetector::detect_and_replace(line);
result
}