pub enum MaskStrategy {
Redact,
PartialMask {
reveal_prefix: usize,
reveal_suffix: usize,
mask_char: char,
},
Hash {
salt: Option<String>,
},
Replace,
Encrypt {
key: String,
},
Custom(String),
}Expand description
How detected PII should be masked.
§Examples
use cloakrs_core::MaskStrategy;
let strategy = MaskStrategy::PartialMask {
reveal_prefix: 1,
reveal_suffix: 4,
mask_char: '*',
};
assert!(matches!(strategy, MaskStrategy::PartialMask { .. }));Variants§
Redact
Replace with a typed placeholder such as [EMAIL] or [SSN].
PartialMask
Preserve selected prefix and suffix characters while masking the middle.
Fields
Hash
Deterministic SHA-256 hash.
Replace
Replace with deterministic fake-but-safe data.
Encrypt
AES-256-GCM encryption.
Custom(String)
Replace every finding with this exact string.
Implementations§
Source§impl MaskStrategy
impl MaskStrategy
Sourcepub fn replacement(&self, finding: &PiiEntity) -> String
pub fn replacement(&self, finding: &PiiEntity) -> String
Returns the replacement text for a finding.
Sourcepub fn try_replacement(&self, finding: &PiiEntity) -> Result<String>
pub fn try_replacement(&self, finding: &PiiEntity) -> Result<String>
Returns the replacement text for a finding, propagating fallible strategies.
Trait Implementations§
Source§impl Clone for MaskStrategy
impl Clone for MaskStrategy
Source§fn clone(&self) -> MaskStrategy
fn clone(&self) -> MaskStrategy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MaskStrategy
impl Debug for MaskStrategy
Source§impl Default for MaskStrategy
impl Default for MaskStrategy
Source§fn default() -> MaskStrategy
fn default() -> MaskStrategy
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for MaskStrategy
impl<'de> Deserialize<'de> for MaskStrategy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for MaskStrategy
impl PartialEq for MaskStrategy
Source§fn eq(&self, other: &MaskStrategy) -> bool
fn eq(&self, other: &MaskStrategy) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for MaskStrategy
impl Serialize for MaskStrategy
impl Eq for MaskStrategy
impl StructuralPartialEq for MaskStrategy
Auto Trait Implementations§
impl Freeze for MaskStrategy
impl RefUnwindSafe for MaskStrategy
impl Send for MaskStrategy
impl Sync for MaskStrategy
impl Unpin for MaskStrategy
impl UnsafeUnpin for MaskStrategy
impl UnwindSafe for MaskStrategy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more