Skip to main content

RedactionPolicy

Struct RedactionPolicy 

Source
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

Source

pub fn standard() -> Self

Returns the built-in conservative policy.

§Returns

A policy containing every built-in preset and extra sensitive field.

Source

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.

Source

pub fn builder() -> RedactionPolicyBuilder

Creates a builder without sensitive or allow rules.

§Returns

A mutable builder with default matching, masking, and diagnostic limits.

Source

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.

Source

pub fn builder_from(base: &Self) -> RedactionPolicyBuilder

Creates a builder by copying one immutable policy snapshot.

§Parameters
  • base - Policy whose complete configuration is copied.
§Returns

A mutable builder initialized from base.

Source

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.

Source

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.

Source

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.

Source

pub fn sensitivity_for(&self, field: &str) -> Option<Sensitivity>

Resolves the sensitivity configured for field.

§Parameters
  • field - Raw field name to classify.
§Returns

Some(level) for a sensitive classification or configured unknown-field fallback, or None when an allow rule wins or the fallback passes unknown fields through.

Source

pub fn matching(&self) -> FieldNameMatching

Returns the configured sensitive-field matching breadth.

§Returns

The matching mode used to generate lookup candidates.

Source

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.

Source

pub fn masking(&self) -> &MaskingPolicy

Returns the configured value-masking policy.

§Returns

The four-level immutable masking configuration.

Source

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.

Source

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

Source§

fn clone(&self) -> RedactionPolicy

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RedactionPolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RedactionPolicy

Source§

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.

Source§

impl Eq for RedactionPolicy

Source§

impl PartialEq for RedactionPolicy

Source§

fn eq(&self, other: &RedactionPolicy) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RedactionPolicy

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.