Skip to main content

redact_core/
lib.rs

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