Skip to main content

cloakrs_core/
lib.rs

1//! Core types and scanning primitives for cloakrs.
2//!
3//! `cloakrs-core` contains the public data model, recognizer trait,
4//! registry, scanner, and masking strategy implementations shared by the
5//! rest of the workspace.
6//!
7//! # Examples
8//!
9//! ```
10//! use cloakrs_core::{Confidence, EntityType, Locale, PiiEntity, Recognizer, Scanner, Span};
11//!
12//! struct Email;
13//! impl Recognizer for Email {
14//!     fn id(&self) -> &str { "email_example_v1" }
15//!     fn entity_type(&self) -> EntityType { EntityType::Email }
16//!     fn supported_locales(&self) -> &[Locale] { &[] }
17//!     fn scan(&self, text: &str) -> Vec<PiiEntity> {
18//!         text.find('@').map(|_| PiiEntity {
19//!             entity_type: EntityType::Email,
20//!             span: Span::new(0, text.len()),
21//!             text: text.to_string(),
22//!             confidence: Confidence::new(0.9).unwrap(),
23//!             recognizer_id: self.id().to_string(),
24//!         }).into_iter().collect()
25//!     }
26//! }
27//!
28//! let scanner = Scanner::builder().recognizer(Email).build().unwrap();
29//! let result = scanner.scan("jane@example.com").unwrap();
30//! assert_eq!(result.masked_text.as_deref(), Some("[EMAIL]"));
31//! ```
32
33mod context;
34mod error;
35mod finding;
36mod masker;
37mod recognizer;
38mod scanner;
39
40pub use context::{context_score, surrounding_context, ContextConfig, ContextScore, ContextWindow};
41pub use error::{CloakError, Result};
42pub use finding::{Confidence, EntityType, Locale, PiiEntity, Span};
43pub use masker::{apply_mask, decrypt_masked_value, MaskStrategy};
44pub use recognizer::{Recognizer, RecognizerRegistry};
45pub use scanner::{ScanResult, ScanStats, Scanner, ScannerBuilder};