pub struct RedactionPolicy { /* private fields */ }Expand description
Immutable field classification, masking, format, and resource policy.
A disabled policy intentionally restores original values while retaining resource limits. It is a deliberate debugging escape hatch whose authorization belongs to downstream code.
§Warning
Disabling this policy opts out of confidentiality redaction. Every supported
format, derived field mode, and redaction-specific skip path may publish its
original value. Resource limits and diagnostic control-character escaping
still apply, but they do not make the output redacted. The framework
faithfully executes the chosen policy; it cannot and does not attempt to
prevent downstream code from deliberately or accidentally disabling
redaction. Callers own the authorization, environment, timing, and
consequences of that choice. They can observe it through
crate::RedactionSummary::is_redaction_disabled and
crate::RedactionInspection::is_redaction_disabled.
§Examples
use qubit_redact::RedactionPolicy;
let mut policy = RedactionPolicy::disabled();
assert!(policy.is_disabled());
policy.set_disabled(false);
assert!(!policy.is_disabled());Implementations§
Source§impl RedactionPolicy
impl RedactionPolicy
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 disabled() -> Self
pub fn disabled() -> Self
Returns the standard policy with confidentiality redaction globally disabled.
§Warning
Outputs produced with this policy may contain every original value. Limits and control-character escaping remain active, but masking and redaction-specific field decisions do not. This deliberate debugging capability transfers confidentiality responsibility to the caller.
Sourcepub const fn is_disabled(&self) -> bool
pub const fn is_disabled(&self) -> bool
Returns whether this policy publishes original values while retaining limits and control-character escaping.
A true result means confidentiality redaction is disabled.
Sourcepub fn set_disabled(&mut self, disabled: bool) -> &mut Self
pub fn set_disabled(&mut self, disabled: bool) -> &mut Self
Changes the global redaction switch and returns this policy for chaining.
§Warning
Passing true allows every supported redaction entry to publish its
original value. The caller owns authorization and operational controls;
the framework does not distinguish debugging use from misuse.
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 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 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 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 more