Skip to main content

SanitizationEngine

Trait SanitizationEngine 

Source
pub trait SanitizationEngine: Send + Sync {
    // Required methods
    fn sanitize(
        &self,
        content: &str,
        source_id: &str,
        run_id: &str,
        input_hash: &str,
        user_id: &str,
        reason: &str,
        outcome: &str,
        audit_log: Option<&mut AuditLog>,
    ) -> Result<(String, Vec<RedactionSummaryItem>)>;
    fn analyze_for_stats(
        &self,
        content: &str,
        source_id: &str,
    ) -> Result<Vec<RedactionSummaryItem>>;
    fn find_matches_for_ui(
        &self,
        content: &str,
        source_id: &str,
    ) -> Result<Vec<RedactionMatch>>;
    fn get_heat_scores(&self, content: &str) -> Vec<f64>;
    fn compiled_rules(&self) -> &CompiledRules;
    fn get_rules(&self) -> &RedactionConfig;
    fn get_options(&self) -> &EngineOptions;
    fn set_remediation_tx(&mut self, tx: Sender<RedactionMatch>);
}
Expand description

A trait that defines the core functionality of a sanitization engine.

This trait decouples the high-level application logic from the specific implementation of a sanitization method, allowing for different engines to be used interchangeably.

Required Methods§

Source

fn sanitize( &self, content: &str, source_id: &str, run_id: &str, input_hash: &str, user_id: &str, reason: &str, outcome: &str, audit_log: Option<&mut AuditLog>, ) -> Result<(String, Vec<RedactionSummaryItem>)>

Performs full sanitization on the provided content.

This method is responsible for finding all sensitive data, applying redactions, and generating a summary of all matched items. It returns the fully sanitized content and a summary of all redaction events.

§Arguments
  • content - The input string to sanitize.
  • source_id - The name or identifier of the source being processed.
  • run_id - A unique identifier for the current sanitization run.
  • input_hash - A hash of the original input content for integrity checks.
  • user_id - The user ID associated with the sanitization run.
  • reason - The reason for the sanitization.
  • outcome - The outcome of the sanitization.
  • audit_log - An optional mutable reference to an AuditLog instance for logging events.
Source

fn analyze_for_stats( &self, content: &str, source_id: &str, ) -> Result<Vec<RedactionSummaryItem>>

Analyzes the provided content for sensitive data without performing redaction.

This method is used specifically for the --stats-only command. It returns a summary of all matched items, but the original content is not modified.

§Arguments
  • content - The input string to scan.
  • source_id - An identifier for the source of the content (e.g., a file path).
Source

fn find_matches_for_ui( &self, content: &str, source_id: &str, ) -> Result<Vec<RedactionMatch>>

Finds all matches and prepares them for an interactive TUI session.

This method returns a flattened vector of RedactionMatch instances, each with a stable sort order, a source ID, and a canonical hash.

§Arguments
  • content - The input string to scan.
  • source_id - An identifier for the source of the content (e.g., a file path).
Source

fn get_heat_scores(&self, content: &str) -> Vec<f64>

Returns the statistical “heat” (entropy) for each character in the input. This allows the UI to render heatmaps via dependency inversion.

Source

fn compiled_rules(&self) -> &CompiledRules

Returns a reference to the CompiledRules used by the engine.

This is used by external components, such as the statistics command, to access and display information about the rules without needing to recompile them.

Source

fn get_rules(&self) -> &RedactionConfig

Returns a reference to the engine’s configuration.

Source

fn get_options(&self) -> &EngineOptions

Returns a reference to the engine’s options.

Source

fn set_remediation_tx(&mut self, tx: Sender<RedactionMatch>)

Sets the remediation channel for the self-healing orchestrator. This enables v0.2.0 “Tee-Logic” where matches are sent asynchronously for healing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§