pub mod api_key;
pub mod credit_card;
pub mod detector;
pub mod redactor;
pub mod registry;
pub mod ssn;
pub use detector::{CustomPattern, PiiDetector, PiiMatch, PiiType};
pub use redactor::{PiiRedactor, RedactionStyle, StreamingRedactor};
pub use registry::{PatternEntry, PatternRegistry, PatternSet};
#[must_use]
pub fn contains_pii(text: &str) -> bool {
PiiDetector::new().contains_pii(text)
}
#[must_use]
pub fn redact(text: &str) -> String {
PiiRedactor::new().redact(text)
}
#[must_use]
pub fn redact_asterisks(text: &str) -> String {
PiiRedactor::new()
.style(RedactionStyle::Asterisks)
.redact(text)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn quick_contains() {
assert!(contains_pii("SSN: 123-45-6789"));
assert!(contains_pii("Email: test@example.com"));
assert!(!contains_pii("No PII here"));
}
#[test]
fn quick_redact() {
let result = redact("Card: 4111-1111-1111-1111");
assert!(!result.contains("4111"));
}
}