Skip to main content

Strategy

Trait Strategy 

Source
pub trait Strategy: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn replace(&self, original: &str, entropy: &[u8; 32]) -> String;
}
Expand description

A pluggable replacement strategy.

Strategies transform an original sensitive value into a sanitized replacement using 32 bytes of caller-provided entropy. They MUST be pure functions of their inputs: the same (original, entropy) pair always produces the same output.

Strategies are agnostic to how entropy is produced (HMAC-deterministic or CSPRNG-random). That concern is handled by StrategyGenerator.

Required Methods§

Source

fn name(&self) -> &'static str

Human-readable, unique name for this strategy (e.g. "random_string").

Source

fn replace(&self, original: &str, entropy: &[u8; 32]) -> String

Produce a sanitized replacement for original using entropy.

§Contract
  • Must be deterministic: same (original, entropy) → same output.
  • Must not perform I/O or access external mutable state.
  • Returned value should be clearly synthetic / non-sensitive.

Implementors§