use crate::error::RedactorResult;
use std::path::Path;
#[derive(Debug, Clone)]
pub enum RedactionTarget {
Literal(String),
Regex(String),
PhoneNumbers,
VerizonAccount,
VerizonCallDetails,
}
#[derive(Debug, Clone, Default)]
pub struct RedactionResult {
pub instances_redacted: usize,
pub pages_processed: usize,
pub pages_modified: usize,
pub secure: bool,
}
impl RedactionResult {
pub fn none() -> Self {
Self::default()
}
pub fn has_redactions(&self) -> bool {
self.instances_redacted > 0
}
}
pub trait RedactionStrategy: Send + Sync {
fn redact(
&self,
input: &Path,
output: &Path,
targets: &[RedactionTarget],
) -> RedactorResult<RedactionResult>;
fn extract_text(&self, input: &Path) -> RedactorResult<String>;
fn name(&self) -> &str;
fn is_secure(&self) -> bool;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_redaction_result() {
let result = RedactionResult::none();
assert!(!result.has_redactions());
let result = RedactionResult {
instances_redacted: 5,
..Default::default()
};
assert!(result.has_redactions());
}
}