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 with cargo, enable only required rules, and validate output against realistic sample logs before rollout.

Installation

cargo add mask-pii

Usage

src/main.rs
use mask_pii::Masker;

fn main() {
  // 1) Enable only the masking rules you need.
  let masker = Masker::new()
    .mask_emails()
    .mask_phones()
    .with_mask_char('*');

  // 2) Process free-form text such as logs or export lines.
  let input = "user=alice@example.com phone=+81-90-1234-5678";
  let output = masker.process(input);
  println!("{}", output);

  // 3) Keep a minimal regression check in tests.
  assert_ne!(output, input);
  assert!(output.contains("@example.com"));
}

// README (Rust):
https://github.com/finitefield-org/mask-pii/tree/main/rust
README and implementation notes

For rollout details such as edge cases, test strategy, and language-specific caveats, review the README before production use.