pub struct RedactionPolicy { /* private fields */ }Expand description
Immutable field-classification and value-masking policy.
Cloning a policy shares its complete configuration and has constant cost.
Implementations§
Source§impl RedactionPolicy
impl RedactionPolicy
Sourcepub fn standard() -> Self
pub fn standard() -> Self
Returns the built-in conservative policy.
§Returns
A policy containing every built-in preset and extra sensitive field.
Sourcepub fn global_default() -> Self
pub fn global_default() -> Self
Returns a snapshot of the process-wide default policy.
Before a custom default is installed, this returns a new shared handle
to the built-in Self::standard policy. The returned snapshot never
changes after a later installation.
§Returns
A shared immutable snapshot of the current process-wide default.
Sourcepub fn builder() -> RedactionPolicyBuilder
pub fn builder() -> RedactionPolicyBuilder
Creates a builder without sensitive or allow rules.
§Returns
A mutable builder with default matching, masking, and diagnostic limits.
Sourcepub fn builder_from_default() -> RedactionPolicyBuilder
pub fn builder_from_default() -> RedactionPolicyBuilder
Creates a builder initialized from the current default policy.
§Returns
A mutable builder containing a snapshot of the current default policy.
Sourcepub fn builder_from(base: &Self) -> RedactionPolicyBuilder
pub fn builder_from(base: &Self) -> RedactionPolicyBuilder
Sourcepub const fn diagnostic_budget(&self) -> DiagnosticBudget
pub const fn diagnostic_budget(&self) -> DiagnosticBudget
Returns the hard limits for diagnostics rendered with this policy.
§Returns
The immutable diagnostic input and output budget.
Sourcepub fn set_global_default(policy: Self) -> Result<(), GlobalDefaultAlreadySet>
pub fn set_global_default(policy: Self) -> Result<(), GlobalDefaultAlreadySet>
Installs the process-wide default policy exactly once.
The installed immutable policy affects later calls to Self::default
and RedactionPolicyBuilder::load_default. Previously created
snapshots remain unchanged.
§Parameters
policy- Immutable policy to install as the process-wide default.
§Returns
Ok(()) when this call installs the process-wide default.
§Errors
Returns GlobalDefaultAlreadySet when a policy was installed by an
earlier successful call. The existing policy is never replaced.
Sourcepub fn classify_field<'a>(&'a self, field: &str) -> FieldClassification<'a>
pub fn classify_field<'a>(&'a self, field: &str) -> FieldClassification<'a>
Classifies field and returns the configured rule that decided it.
Candidates are examined from the complete canonical name to shorter semantic token suffixes. An allow rule wins over a sensitive rule at the same candidate, but exact allow rules apply only to the complete input candidate.
§Type Parameters
'a- Lifetime of rules borrowed from this policy in the result.
§Parameters
field- Raw field name to classify.
§Returns
A borrowed sensitive or allow rule for the first matching candidate, or
FieldClassification::Unknown when no rule matches.
Sourcepub fn sensitivity_for(&self, field: &str) -> Option<Sensitivity>
pub fn sensitivity_for(&self, field: &str) -> Option<Sensitivity>
Sourcepub fn matching(&self) -> FieldNameMatching
pub fn matching(&self) -> FieldNameMatching
Returns the configured sensitive-field matching breadth.
§Returns
The matching mode used to generate lookup candidates.
Sourcepub fn unknown_field_policy(&self) -> UnknownFieldPolicy
pub fn unknown_field_policy(&self) -> UnknownFieldPolicy
Returns fallback behavior for fields with no matching rule.
§Returns
The immutable unknown-field policy configured for this snapshot.
Sourcepub fn masking(&self) -> &MaskingPolicy
pub fn masking(&self) -> &MaskingPolicy
Returns the configured value-masking policy.
§Returns
The four-level immutable masking configuration.
Sourcepub fn sensitive_rules(&self) -> impl Iterator<Item = SensitiveFieldRule<'_>>
pub fn sensitive_rules(&self) -> impl Iterator<Item = SensitiveFieldRule<'_>>
Iterates configured sensitive-field rules in canonical name order.
§Returns
Borrowed read-only views of all sensitive-field rules.
Sourcepub fn allow_rules(&self) -> impl Iterator<Item = AllowRule<'_>>
pub fn allow_rules(&self) -> impl Iterator<Item = AllowRule<'_>>
Iterates exact allow rules followed by suffix allow rules.
Each group is ordered by canonical field name.
§Returns
Borrowed read-only views of all allow rules.
Trait Implementations§
Source§impl Clone for RedactionPolicy
impl Clone for RedactionPolicy
Source§fn clone(&self) -> RedactionPolicy
fn clone(&self) -> RedactionPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RedactionPolicy
impl Debug for RedactionPolicy
Source§impl Default for RedactionPolicy
impl Default for RedactionPolicy
Source§fn default() -> Self
fn default() -> Self
Returns a snapshot of the current process-wide default policy.
§Returns
The installed global configuration, or RedactionPolicy::standard
before a custom default is installed.