Skip to main content

Redactor

Struct Redactor 

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

Applies one immutable policy to scalar values and string maps.

Implementations§

Source§

impl Redactor

Source

pub const fn new(policy: RedactionPolicy) -> Self

Creates a redactor using policy.

§Parameters
  • policy - Immutable field classification and masking configuration.
§Returns

A redactor that owns the supplied policy snapshot.

Source

pub const fn policy(&self) -> &RedactionPolicy

Returns the immutable policy used by this redactor.

§Returns

A borrowed view of the redactor’s policy snapshot.

Source

pub fn redact<'a>(&self, field: &str, value: &'a str) -> RedactedText<'a>

Redacts one value according to its field name.

Unknown and explicitly allowed fields retain a borrow of value. Sensitive fields return the value produced by the configured mask.

§Type Parameters
  • 'a - Lifetime of the input and any borrowed redacted result.
§Parameters
  • field - Raw field name to classify.
  • value - Field value to redact when classified as sensitive.
§Returns

Typed redacted text borrowing safe input where possible.

Source

pub fn redact_at<'a>( &self, level: Sensitivity, value: &'a str, ) -> RedactedText<'a>

Redacts one value at an explicit sensitivity level.

This ignores field classification and allow rules. Use it at a boundary where the value is known to be sensitive regardless of its field name.

§Type Parameters
  • 'a - Lifetime of the input and any borrowed redacted result.
§Parameters
  • level - Sensitivity required by the calling boundary.
  • value - Value to mask.
§Returns

Typed redacted text produced by the configured mask for level.

Source

pub fn redact_keyed<'value, T: ?Sized>( &self, key: &'value str, value: &'value T, ) -> RedactedKeyedValue<'value, '_, T>

Creates a lazy redacted view selected by an external key.

The returned view borrows this redactor’s policy snapshot. When its key is sensitive, it masks the complete value through RedactValue. Otherwise it delegates to the value’s recursive redaction contracts.

§Type Parameters
  • 'value - Lifetime of the borrowed key and value.
  • T - Value type rendered or serialized through redaction.
§Parameters
  • key - Field name used only for policy classification.
  • value - Value to render or serialize through the selected policy.
§Returns

A lazy keyed redaction view borrowing key and value.

Source

pub fn redact_map<M, K: ?Sized, V: ?Sized>(&self, map: &M) -> M
where M: Clone + RedactMapValueMut<K, V>,

Creates a redacted copy of a text-keyed, mutable text-valued map.

The source map is never modified. Its concrete collection type is preserved by cloning the collection before applying in-place redaction.

§Type Parameters
  • M - Cloneable map-like collection returned after redaction.
  • K - Runtime key type used for field classification.
  • V - Mutable map-value type redacted in the cloned collection.
§Parameters
  • map - Map whose values are classified by their corresponding keys.
§Returns

A map of the same type containing redacted values.

Source

pub fn redact_map_in_place<M, K: ?Sized, V: ?Sized>(&self, map: &mut M)
where M: RedactMapValueMut<K, V> + ?Sized,

Redacts sensitive values of a text-keyed map in place.

§Type Parameters
  • M - Mutable map-like collection type.
  • K - Runtime key type used for field classification.
  • V - Mutable map-value type redacted in place.
§Parameters
  • map - Mutable map whose values are classified by their keys.

Trait Implementations§

Source§

impl Clone for Redactor

Source§

fn clone(&self) -> Redactor

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 Redactor

Source§

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

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

impl Default for Redactor

Source§

fn default() -> Self

Creates a redactor from the current global default policy snapshot.

§Returns

A redactor that is unaffected by later policy configuration attempts.

Source§

impl Eq for Redactor

Source§

impl PartialEq for Redactor

Source§

fn eq(&self, other: &Redactor) -> 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 Redactor

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.