pub struct Redactor { /* private fields */ }Expand description
Applies one immutable policy to scalar values and string maps.
Implementations§
Source§impl Redactor
impl Redactor
Sourcepub const fn new(policy: RedactionPolicy) -> Self
pub const fn new(policy: RedactionPolicy) -> Self
Sourcepub fn strict() -> Self
pub fn strict() -> Self
Creates a redactor with the strict policy for untrusted scalar data.
Unknown fields are masked at Sensitivity::Secret.
Sourcepub const fn policy(&self) -> &RedactionPolicy
pub const fn policy(&self) -> &RedactionPolicy
Returns the immutable policy used by this redactor.
§Returns
A borrowed view of the redactor’s policy snapshot.
Sourcepub fn redact_field<'a>(
&self,
field: &str,
value: &'a str,
) -> FieldRedaction<'a>
pub fn redact_field<'a>( &self, field: &str, value: &'a str, ) -> FieldRedaction<'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.
This method classifies only field; it never scans value for secret
syntax. Do not pass an arbitrary error message or complete diagnostic
under a generic field name and expect embedded credentials to be found.
Use structured fields, Self::redact_at for an opaque value whose
sensitivity is already known, or a fixed safe public summary with the
original error retained only as an error source.
§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
A typed result that distinguishes masked values from pass-through values while borrowing safe input where possible.
Sourcepub fn redact_field_with_session<'a>(
&self,
session: &RedactionSession<'_>,
field: &str,
value: &'a str,
) -> FieldRedaction<'a>
pub fn redact_field_with_session<'a>( &self, session: &RedactionSession<'_>, field: &str, value: &'a str, ) -> FieldRedaction<'a>
Redacts one field while consuming the supplied operation session.
This is the composition entry point for diagnostics that contain more than one field-producing adapter. Input accounting happens before the value is inspected, and generated masks are charged to the same session.
Sourcepub fn redact_at<'a>(
&self,
level: Sensitivity,
value: &'a str,
) -> RedactedText<'a>
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.
Sourcepub fn redact_at_with_session<'a>(
&self,
session: &RedactionSession<'_>,
level: Sensitivity,
value: &'a str,
) -> RedactedText<'a>
pub fn redact_at_with_session<'a>( &self, session: &RedactionSession<'_>, level: Sensitivity, value: &'a str, ) -> RedactedText<'a>
Redacts an explicitly sensitive value through an existing session.
Sourcepub fn redact_keyed<'value, T: ?Sized>(
&self,
key: &'value str,
value: &'value T,
) -> RedactedKeyedValue<'value, '_, T>
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.
Sourcepub fn redact_map<M, K: ?Sized, V: ?Sized>(&self, map: &M) -> Mwhere
M: Clone + RedactMapValueMut<K, V>,
pub fn redact_map<M, K: ?Sized, V: ?Sized>(&self, map: &M) -> Mwhere
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.