pub struct MaskingProfile { /* private fields */ }Expand description
脱敏配置档案:一套命名的字段脱敏规则集合。
用于多租户/多场景隔离,例如 default、strict、gdpr 等不同脱敏强度。
Implementations§
Source§impl MaskingProfile
impl MaskingProfile
Sourcepub fn with_description(name: &str, description: &str) -> Self
pub fn with_description(name: &str, description: &str) -> Self
创建档案并设置描述
Sourcepub fn description(&self) -> &str
pub fn description(&self) -> &str
描述
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
是否启用
Sourcepub fn set_enabled(self, enabled: bool) -> Self
pub fn set_enabled(self, enabled: bool) -> Self
设置启用状态(链式)
Sourcepub fn with_rule(self, field: &str, rule: MaskingRule) -> Self
pub fn with_rule(self, field: &str, rule: MaskingRule) -> Self
添加字段规则(链式)
Sourcepub fn with_rules(self, rules: HashMap<String, MaskingRule>) -> Self
pub fn with_rules(self, rules: HashMap<String, MaskingRule>) -> Self
添加多条规则(链式)
Sourcepub fn rule_count(&self) -> usize
pub fn rule_count(&self) -> usize
规则数
Sourcepub fn get_rule(&self, field: &str) -> Option<&MaskingRule>
pub fn get_rule(&self, field: &str) -> Option<&MaskingRule>
获取字段规则
Sourcepub fn remove_rule(&mut self, field: &str) -> Option<MaskingRule>
pub fn remove_rule(&mut self, field: &str) -> Option<MaskingRule>
移除字段规则
Sourcepub fn rules(&self) -> &HashMap<String, MaskingRule>
pub fn rules(&self) -> &HashMap<String, MaskingRule>
所有规则引用
Sourcepub fn apply_to_map(
&self,
data: &HashMap<String, String>,
) -> HashMap<String, String>
pub fn apply_to_map( &self, data: &HashMap<String, String>, ) -> HashMap<String, String>
对 HashMap 应用本档案脱敏
Sourcepub fn apply_to_json(&self, json: &str) -> String
pub fn apply_to_json(&self, json: &str) -> String
对 JSON 应用本档案脱敏
Trait Implementations§
Source§impl Clone for MaskingProfile
impl Clone for MaskingProfile
Source§fn clone(&self) -> MaskingProfile
fn clone(&self) -> MaskingProfile
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 MaskingProfile
impl Debug for MaskingProfile
Source§impl<'de> Deserialize<'de> for MaskingProfile
impl<'de> Deserialize<'de> for MaskingProfile
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
Auto Trait Implementations§
impl Freeze for MaskingProfile
impl RefUnwindSafe for MaskingProfile
impl Send for MaskingProfile
impl Sync for MaskingProfile
impl Unpin for MaskingProfile
impl UnsafeUnpin for MaskingProfile
impl UnwindSafe for MaskingProfile
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