Skip to main content

redact_core/
lib.rs

1// Copyright 2026 Censgate LLC.
2// Licensed under the Apache License, Version 2.0. See the LICENSE file
3// in the project root for license information.
4
5//! Redact Core - PII Detection and Anonymization Engine
6//!
7//! A high-performance, Rust-based PII detection and anonymization library
8//! designed as a replacement for Microsoft Presidio.
9//!
10//! # Features
11//!
12//! - **Pattern-based Detection**: Regex-based PII recognizers for structured data
13//! - **NER Support**: Named Entity Recognition using ONNX Runtime (via redact-ner)
14//! - **Multiple Anonymization Strategies**: Replace, mask, hash, encrypt
15//! - **Policy-Aware**: Configurable rules and thresholds
16//! - **Multi-platform**: Server, WASM, mobile support
17//! - **High Performance**: Zero-copy where possible, efficient overlap resolution
18//!
19//! # Example
20//!
21//! ```no_run
22//! use redact_core::{AnalyzerEngine, AnonymizerConfig, AnonymizationStrategy};
23//!
24//! let mut analyzer = AnalyzerEngine::new();
25//!
26//! let text = "Contact John Doe at john@example.com or 555-1234";
27//! let result = analyzer.analyze(text, None).unwrap();
28//!
29//! println!("Detected {} entities", result.detected_entities.len());
30//!
31//! // Anonymize with replacement strategy
32//! let config = AnonymizerConfig {
33//!     strategy: AnonymizationStrategy::Replace,
34//!     ..Default::default()
35//! };
36//! let anonymized = analyzer.anonymize(text, None, &config).unwrap();
37//! println!("Anonymized: {}", anonymized.text);
38//! ```
39
40pub mod anonymizers;
41pub mod engine;
42pub mod policy;
43pub mod recognizers;
44pub mod types;
45
46// Re-export commonly used types
47pub use anonymizers::{AnonymizationStrategy, AnonymizerConfig, AnonymizerRegistry};
48pub use engine::AnalyzerEngine;
49pub use recognizers::{Recognizer, RecognizerRegistry};
50pub use types::{
51    AnalysisMetadata, AnalysisResult, AnonymizedResult, EntityType, RecognizerResult, Token,
52};
53
54/// Version of the redact-core library
55pub const VERSION: &str = env!("CARGO_PKG_VERSION");
56
57#[cfg(test)]
58mod tests {
59    use super::*;
60
61    #[test]
62    fn test_version() {
63        assert!(!VERSION.is_empty());
64    }
65}