Skip to main content

RedactionPolicy

Struct RedactionPolicy 

Source
pub struct RedactionPolicy { /* private fields */ }
Expand description

Immutable redaction policy.

Implementations§

Source§

impl RedactionPolicy

Source

pub fn install_global(policy: Self) -> Result<(), InstallGlobalPolicyError>

Installs the application-owned default policy exactly once.

The policy is copied into a process-wide immutable slot. Reading Self::global before installation only observes Self::standard and does not occupy this slot. If a policy was already installed, the rejected policy is returned through crate::InstallGlobalPolicyError::into_policy. Libraries should leave this operation to their host application.

§Warning

This is application-assembly configuration, not runtime reconfiguration. The executable should call it at most once, after constructing the final policy and before starting workers or request processing. Library crates must never call it. Calling it from feature code, tests sharing one process, or after concurrent application work has begun is a lifecycle error even though the type system cannot distinguish those call sites.

Objects created before installation may already own a snapshot of Self::standard. They intentionally keep that snapshot after installation. Any object that must use the application policy must be created after this call or receive the policy explicitly.

Source

pub fn global() -> &'static Self

Returns the process-wide default policy snapshot.

Returns the installed policy when available; otherwise returns the fixed standard policy without changing global installation state. Existing policy and redactor snapshots are unaffected by a later global installation.

§Warning

The pre-installation fallback exists so application assembly may safely construct dependencies that consult redaction defaults before the host has finalized its policy. It is not a runtime configuration mechanism. A caller that requires the application policy must either run after Self::install_global or use an explicitly injected policy. Never assume that a value returned before installation will change afterward.

Source

pub fn standard() -> Self

Returns the fixed built-in standard policy.

Its application rules are empty and its explicit floor is RedactionFloor::standard, so it never observes later process-wide default installations.

Source

pub fn strict() -> Self

Returns a strict boundary policy whose unknown fields are masked at Sensitivity::Secret in addition to the standard floor.

This preset is intended for untrusted external boundaries. It is more protective than Self::standard but may reduce diagnostic detail.

Source

pub fn builder_from_default() -> RedactionPolicyBuilder

Creates a builder initialized from the process-wide default snapshot.

Source

pub fn builder() -> RedactionPolicyBuilder

Creates a deterministic builder with no application rules and the standard minimum-protection floor.

Source

pub fn to_builder(&self) -> RedactionPolicyBuilder

Creates a builder that exactly copies self.

The copy includes application rules, limits, and the attached floor.

Source

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

Creates a builder that exactly copies base.

Source

pub const fn limits(&self) -> &RedactionLimits

Returns all static limits used by this policy.

Source

pub fn http(&self) -> &HttpPolicy

Returns the unified HTTP context policy.

Source

pub fn uri(&self) -> &UriPolicy

Returns the unified URI context policy.

Source

pub fn header_rules(&self) -> &RedactionRules

Returns the HTTP header field rules.

Source

pub fn query_rules(&self) -> &RedactionRules

Returns the HTTP query field rules.

Source

pub fn body_rules(&self) -> &RedactionRules

Returns the HTTP body field rules.

Source

pub fn url_path_policy(&self) -> UrlPathPolicy

Returns the HTTP URL path policy.

Source

pub fn text_body_policy(&self) -> TextBodyPolicy

Returns the HTTP text-body policy.

Source

pub fn body_budget(&self) -> BodyBudget

Returns the HTTP body byte budget.

Source

pub fn path_policy(&self) -> UriPathPolicy

Returns the URI path policy.

Source

pub fn fragment_policy(&self) -> UriFragmentPolicy

Returns the URI fragment policy.

Source

pub const fn json_depth_budget(&self) -> JsonDepthBudget

Returns the maximum JSON nesting depth for JSON redaction.

Source

pub const fn unkeyed_json_value_policy(&self) -> UnkeyedJsonValuePolicy

Returns the behavior for root and array JSON scalar values.

Source

pub const fn rules(&self) -> &RedactionRules

Returns the immutable field rules without diagnostic resource limits.

Source

pub const fn fields(&self) -> &RedactionRules

Returns the base field policy view.

Source

pub fn floor(&self) -> Option<&RedactionFloor>

Returns the attached minimum floor, or None when it was explicitly disabled.

Source

pub fn with_floor(self, floor: RedactionFloor) -> Self

Replaces the floor for this immutable policy.

Source

pub fn disable_floor(self) -> Self

Disables every floor for this immutable policy.

§Security

This explicitly removes minimum protection inherited from any source.

Source

pub fn classify_field<'a>(&'a self, field: &str) -> FieldClassification<'a>

Explains application-rule matching for field without applying the floor.

This is useful for diagnostics about configured application rules. Use Self::sensitivity_for for the final security decision.

Source

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

Returns the final sensitivity for field after applying application rules and the enabled floor.

Returns None only when neither layer classifies the field as sensitive.

Source

pub fn matching(&self) -> FieldNameMatching

Returns the application layer’s field-name matching mode.

An attached floor may use a different matching mode for its independent classification.

Source

pub fn unknown_field_policy(&self) -> UnknownFieldPolicy

Returns the application layer’s fallback for unclassified fields.

An attached floor applies its own fallback independently.

Source

pub fn masking(&self) -> &MaskingPolicy

Returns the single mask table used by every sensitivity decision.

Field classification determines the effective sensitivity; this table determines how that sensitivity is rendered. Floors never own a second mask table.

Source

pub fn application_sensitive_rules( &self, ) -> impl Iterator<Item = SensitiveFieldRule<'_>>

Iterates sensitive rules configured in the application layer only.

Use Self::floor to inspect the independent minimum-protection rules.

Source

pub fn application_allow_rules(&self) -> impl Iterator<Item = AllowRule<'_>>

Iterates allow rules configured in the application layer only.

These rules never bypass an enabled floor.

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

Clones the currently visible process default.

§Warning

Before application assembly calls Self::install_global, this clones Self::standard. The clone is a permanent snapshot and will not be updated by a later installation. Policy-sensitive objects that require application configuration must be constructed after installation or be given an explicit policy.

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.