mask-pii for Rust
Rust implementation of mask-pii. Configure explicit masking rules for emails and phone numbers to prepare text safely before logging, auditing, or sharing data.
Email masking rule
Keeps domain visibility and masks the local part so email addresses remain traceable without exposing full PII.
Phone masking rule
Masks middle digits while preserving format and suffix visibility to keep operational troubleshooting possible.
Safe-by-default configuration
Masking is opt-in. Enable only the required rules and choose a mask character that matches your log policy.
Installation, usage, and rollout checklist
Install the verified crates.io release, load the Rust API, and run the minimal example below. It enables both masking rules explicitly and records the expected output.
Installation
cargo add mask-pii@0.2.0
Usage
use mask_pii::Masker;
fn main() {
// Configure the masker
let masker = Masker::new()
.mask_emails()
.mask_phones()
.with_mask_char('#'); // Optional: Use '#' instead of '*'
let input = "Contact: alice@example.com or 090-1234-5678.";
// Process the text
let output = masker.process(input);
println!("{}", output);
// Output: "Contact: a####@example.com or ###-####-5678."
}
README and implementation notes
For rollout details such as edge cases, test strategy, and language-specific caveats, review the README before production use.
Previous
Language indexNext
GitHub (Rust)