pub struct RedactionPolicyBuilder { /* private fields */ }Expand description
Mutable construction state for an immutable RedactionPolicy.
Configuration setters are available through the grouped views returned by
Self::fields and Self::limits, with feature-specific HTTP and URI
views when those formats are enabled.
Duplicate consuming setters are intentionally not available at this level:
use qubit_redact::{RedactionPolicy, Sensitivity};
let _ = RedactionPolicy::builder().raise("token", Sensitivity::Secret);§Examples
use qubit_redact::RedactionPolicy;
let policy = RedactionPolicy::builder()
.fields(|fields| {
let _ = fields.secret_sensitive("api_token");
})
.expect("valid field rules")
.build()
.expect("valid policy");
assert!(policy.sensitivity_for("api_token").is_some());Implementations§
Source§impl RedactionPolicyBuilder
impl RedactionPolicyBuilder
Sourcepub fn fields<F>(self, configure: F) -> Result<Self, PolicyError>where
F: FnOnce(&mut FieldsBuilder<'_>),
pub fn fields<F>(self, configure: F) -> Result<Self, PolicyError>where
F: FnOnce(&mut FieldsBuilder<'_>),
Configures base field sensitivity rules transactionally.
The closure writes into a temporary field draft. Field names are
validated after the closure returns and the draft is applied only when
every field is valid. The configuration methods inside the closure are
therefore infallible and can be chained without a trailing Ok(()).
§Errors
Returns PolicyError when a field name is empty after
canonicalization. The builder remains unchanged on error.
Sourcepub fn http<F>(self, configure: F) -> Result<Self, PolicyError>where
F: FnOnce(&mut HttpPolicyBuilderView<'_>),
pub fn http<F>(self, configure: F) -> Result<Self, PolicyError>where
F: FnOnce(&mut HttpPolicyBuilderView<'_>),
Configures HTTP policy through an isolated draft.
The draft replaces this namespace only after the closure returns, so a failed build never partially updates the caller’s builder.
§Errors
Returns PolicyError when the HTTP view records an invalid field
rule. The original builder remains unchanged.
Sourcepub fn uri<F>(self, configure: F) -> Result<Self, PolicyError>where
F: FnOnce(&mut UriPolicyBuilderView<'_>),
pub fn uri<F>(self, configure: F) -> Result<Self, PolicyError>where
F: FnOnce(&mut UriPolicyBuilderView<'_>),
Configures URI policy through an isolated draft.
§Errors
This operation is currently infallible. The result preserves the transactional shape shared by feature-specific builder views.
Sourcepub fn limits<F>(self, configure: F) -> Result<Self, PolicyError>where
F: FnOnce(&mut RedactionLimitsBuilder),
pub fn limits<F>(self, configure: F) -> Result<Self, PolicyError>where
F: FnOnce(&mut RedactionLimitsBuilder),
Configures transaction limits through a draft that is applied atomically.
The closure mutates only a temporary limits builder. Once it returns, the completed limits replace this builder’s limits as one update.
§Errors
Returns PolicyError when the completed limit set violates a
platform collection capacity limit. No invalid limit snapshot is
installed.
Sourcepub const fn unkeyed_json_value_policy(
self,
policy: UnkeyedJsonValuePolicy,
) -> Self
pub const fn unkeyed_json_value_policy( self, policy: UnkeyedJsonValuePolicy, ) -> Self
Sets behavior for root and array JSON scalar values.
This setter remains on the root builder because the JSON feature does not expose a separate grouped builder.
Sourcepub fn validate_field_name(field: &str) -> Result<(), PolicyError>
pub fn validate_field_name(field: &str) -> Result<(), PolicyError>
Validates that field has a non-empty canonical application-rule name.
§Errors
Returns PolicyError::EmptyFieldName at
PolicyLocation::Rules when canonicalization leaves no name.
Sourcepub fn build(self) -> Result<RedactionPolicy, PolicyError>
pub fn build(self) -> Result<RedactionPolicy, PolicyError>
Validates and returns the immutable policy snapshot.
§Errors
Returns a PolicyError when final policy validation fails.
Trait Implementations§
Source§impl Clone for RedactionPolicyBuilder
impl Clone for RedactionPolicyBuilder
Source§fn clone(&self) -> RedactionPolicyBuilder
fn clone(&self) -> RedactionPolicyBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more