Skip to main content

RedactionPolicyBuilder

Struct RedactionPolicyBuilder 

Source
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

Source

pub fn new() -> Self

Creates an empty application-rule builder with the standard floor.

Source

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.

Source

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.

Source

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.

Source

pub fn limits<F>(self, configure: F) -> Result<Self, PolicyError>

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> RedactionPolicyBuilder

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 RedactionPolicyBuilder

Source§

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

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

impl Default for RedactionPolicyBuilder

Source§

fn default() -> Self

Creates a builder with the standard floor and default limits.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.