pub struct RedactionPolicy { /* private fields */ }Expand description
Immutable redaction policy.
Implementations§
Source§impl RedactionPolicy
impl RedactionPolicy
Sourcepub fn install_global(policy: Self) -> Result<(), InstallGlobalPolicyError>
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.
Sourcepub fn global() -> &'static Self
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.
Sourcepub fn standard() -> Self
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.
Sourcepub fn strict() -> Self
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.
Sourcepub fn builder_from_default() -> RedactionPolicyBuilder
pub fn builder_from_default() -> RedactionPolicyBuilder
Creates a builder initialized from the process-wide default snapshot.
Sourcepub fn builder() -> RedactionPolicyBuilder
pub fn builder() -> RedactionPolicyBuilder
Creates a deterministic builder with no application rules and the standard minimum-protection floor.
Sourcepub fn to_builder(&self) -> RedactionPolicyBuilder
pub fn to_builder(&self) -> RedactionPolicyBuilder
Creates a builder that exactly copies self.
The copy includes application rules, limits, and the attached floor.
Sourcepub fn builder_from(base: &Self) -> RedactionPolicyBuilder
pub fn builder_from(base: &Self) -> RedactionPolicyBuilder
Creates a builder that exactly copies base.
Sourcepub const fn limits(&self) -> &RedactionLimits
pub const fn limits(&self) -> &RedactionLimits
Returns all static limits used by this policy.
Sourcepub fn http(&self) -> &HttpPolicy
pub fn http(&self) -> &HttpPolicy
Returns the unified HTTP context policy.
Sourcepub fn header_rules(&self) -> &RedactionRules
pub fn header_rules(&self) -> &RedactionRules
Returns the HTTP header field rules.
Sourcepub fn query_rules(&self) -> &RedactionRules
pub fn query_rules(&self) -> &RedactionRules
Returns the HTTP query field rules.
Sourcepub fn body_rules(&self) -> &RedactionRules
pub fn body_rules(&self) -> &RedactionRules
Returns the HTTP body field rules.
Sourcepub fn url_path_policy(&self) -> UrlPathPolicy
pub fn url_path_policy(&self) -> UrlPathPolicy
Returns the HTTP URL path policy.
Sourcepub fn text_body_policy(&self) -> TextBodyPolicy
pub fn text_body_policy(&self) -> TextBodyPolicy
Returns the HTTP text-body policy.
Sourcepub fn body_budget(&self) -> BodyBudget
pub fn body_budget(&self) -> BodyBudget
Returns the HTTP body byte budget.
Sourcepub fn path_policy(&self) -> UriPathPolicy
pub fn path_policy(&self) -> UriPathPolicy
Returns the URI path policy.
Sourcepub fn fragment_policy(&self) -> UriFragmentPolicy
pub fn fragment_policy(&self) -> UriFragmentPolicy
Returns the URI fragment policy.
Sourcepub const fn json_depth_budget(&self) -> JsonDepthBudget
pub const fn json_depth_budget(&self) -> JsonDepthBudget
Returns the maximum JSON nesting depth for JSON redaction.
Sourcepub const fn unkeyed_json_value_policy(&self) -> UnkeyedJsonValuePolicy
pub const fn unkeyed_json_value_policy(&self) -> UnkeyedJsonValuePolicy
Returns the behavior for root and array JSON scalar values.
Sourcepub const fn rules(&self) -> &RedactionRules
pub const fn rules(&self) -> &RedactionRules
Returns the immutable field rules without diagnostic resource limits.
Sourcepub const fn fields(&self) -> &RedactionRules
pub const fn fields(&self) -> &RedactionRules
Returns the base field policy view.
Sourcepub fn floor(&self) -> Option<&RedactionFloor>
pub fn floor(&self) -> Option<&RedactionFloor>
Returns the attached minimum floor, or None when it was explicitly
disabled.
Sourcepub fn with_floor(self, floor: RedactionFloor) -> Self
pub fn with_floor(self, floor: RedactionFloor) -> Self
Replaces the floor for this immutable policy.
Sourcepub fn disable_floor(self) -> Self
pub fn disable_floor(self) -> Self
Disables every floor for this immutable policy.
§Security
This explicitly removes minimum protection inherited from any source.
Sourcepub fn classify_field<'a>(&'a self, field: &str) -> FieldClassification<'a>
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.
Sourcepub fn sensitivity_for(&self, field: &str) -> Option<Sensitivity>
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.
Sourcepub fn matching(&self) -> FieldNameMatching
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.
Sourcepub fn unknown_field_policy(&self) -> UnknownFieldPolicy
pub fn unknown_field_policy(&self) -> UnknownFieldPolicy
Returns the application layer’s fallback for unclassified fields.
An attached floor applies its own fallback independently.
Sourcepub fn masking(&self) -> &MaskingPolicy
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.
Sourcepub fn application_sensitive_rules(
&self,
) -> impl Iterator<Item = SensitiveFieldRule<'_>>
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.
Sourcepub fn application_allow_rules(&self) -> impl Iterator<Item = AllowRule<'_>>
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
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
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.