pub mod processor;
pub trait EssenceModeProcessor {
fn new(enabled: bool) -> Self;
fn process_line(&self, line: &str) -> String;
fn set_enabled(&mut self, enabled: bool);
fn is_enabled(&self) -> bool;
fn get_timestamps_replaced(&self) -> u64;
fn get_supported_formats_count(&self) -> usize;
fn validate_constitutional_compliance(&self) -> EssenceModeValidation;
}
#[derive(Debug, Clone)]
pub struct EssenceModeValidation {
pub is_non_default: bool, pub supports_all_formats: bool, pub preserves_structure: bool, pub achieves_independence: bool, }
impl EssenceModeValidation {
pub fn meets_constitutional_requirements(&self) -> bool {
self.is_non_default
&& self.supports_all_formats
&& self.preserves_structure
&& self.achieves_independence
}
}
#[derive(Debug, Clone)]
pub enum TokenizationStrategy {
ReplaceWithToken(String), RemoveCompletely,
NormalizeFormat(String),
}
impl Default for TokenizationStrategy {
fn default() -> Self {
TokenizationStrategy::ReplaceWithToken("<TIMESTAMP>".to_string())
}
}
#[derive(Debug, Clone)]
pub struct TimestampMatch {
pub original: String,
pub format_type: TimestampFormat,
pub start_pos: usize,
pub end_pos: usize,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub enum TimestampFormat {
ISO8601Full, ISO8601NoZ, ISO8601Date, ISO8601Time,
RFC3339, RFC3339NoZ,
SyslogBSD, SyslogRFC5424,
ApacheCommon, ApacheError, NginxAccess,
JavaSimpleDate, KubernetesLog, ElasticsearchLog, DockerLog,
UnixTimestamp, UnixTimestampMs, UnixTimestampNs,
MySQLTimestamp, PostgreSQLTimestamp,
WindowsEvent, WindowsIIS,
GitCommit, Aws, Gcp, Azure,
RelativeTime, Duration,
CFormat, RFC822, RFC850, Ansic, }
#[derive(Debug, Clone)]
pub enum EssenceModeError {
InvalidConfiguration(String),
PatternCompilationError(String),
ProcessingError(String),
ConstitutionalViolation(String),
}
impl std::fmt::Display for EssenceModeError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
EssenceModeError::InvalidConfiguration(msg) => {
write!(f, "Invalid essence mode configuration: {msg}")
}
EssenceModeError::PatternCompilationError(msg) => {
write!(f, "Pattern compilation error: {msg}")
}
EssenceModeError::ProcessingError(msg) => {
write!(f, "Processing error: {msg}")
}
EssenceModeError::ConstitutionalViolation(msg) => {
write!(f, "Constitutional violation in essence mode: {msg}")
}
}
}
}
impl std::error::Error for EssenceModeError {}