Skip to main content

Stateless operations

scan

Scan text with the default scan configuration.

scan_with_config

transform

Transform caller-supplied findings without scanning implicitly. Provider-backed strategies return a provider-required error from this stateless function.

scan_and_transform

Primary configuration types

  • ScanConfig
  • ScanAndTransformConfig
  • TransformationConfig
  • TransformationStrategy
  • MaskConfig and MaskReveal
  • PseudonymizeConfig
  • TokenizeConfig
  • PrivacyContext
Rust constructors validate semantic values and return typed errors where configuration can be invalid.

Results

Finding exposes entity metadata, matched text, byte and code-point ranges, optional confidence, and detector provenance. TransformResult contains transformed text and ordered transformations. RestoreResult contains restored text and ordered restorations. For repeated UTF-16 conversions on the same string, reuse TextIndex::new(text) and call its utf16_range(byte_range) method. It accepts overlapping or unordered ranges, validates UTF-8 boundaries, and returns the same ranges and errors as the standalone utf16_range helper. The index borrows the string and builds sparse checkpoints as needed.

Provider-backed manager

PrivacyManager<P, T> composes key and token provider capabilities.
Use:
  • transform or scan_and_transform for key-backed pseudonymization;
  • transform_with_context or scan_and_transform_with_context when tokenization may be selected;
  • restore for authorized token restoration.
Implement the KeyProvider and TokenProvider traits in application code. DataFog Core ships no cloud-, vault-, or database-specific provider. For exact public definitions, see the crate source.

Structured JSON and PERSON fields

The datafog_core::structured module exposes discover_fields, scan, transform, and scan_and_transform. Use StructuredScanConfig::default() for automatic discovery or structured::parse_scan_config for explicit mappings. PrivacyManager adds transform_structured, scan_and_transform_structured, and restore_structured with the existing provider and scope contracts. Paths are JSON Pointers. All ranges, including JavaScript UTF-16 ranges, address the decoded string at that path. See person-field discovery for aliases, policy configuration, input limits, and examples.