pub struct RedactionPolicy { /* private fields */ }Implementations§
Source§impl RedactionPolicy
impl RedactionPolicy
Sourcepub fn passthrough() -> Self
pub fn passthrough() -> Self
Permissive policy used by tests that need raw data. No headers, fields, or strings are scrubbed.
Sourcepub fn with_safe_header(self, name: impl Into<String>) -> Self
pub fn with_safe_header(self, name: impl Into<String>) -> Self
Add a header (case-insensitive) to the safe-list. Header
redaction will leave its value untouched even if the name would
otherwise look auth-shaped (e.g. an x-…-key header that is
actually a request-id).
Sourcepub fn with_deny_header_substring(self, fragment: impl Into<String>) -> Self
pub fn with_deny_header_substring(self, fragment: impl Into<String>) -> Self
Add a substring (case-insensitive) that always forces a header
to be treated as sensitive. Useful for product-specific token
header names that the default cookie/authorization/token/secret/key
substring set would miss.
Sourcepub fn with_extra_field(self, name: impl Into<String>) -> Self
pub fn with_extra_field(self, name: impl Into<String>) -> Self
Add a JSON field name (case-insensitive, exact match) that should
always be redacted regardless of value contents. Useful when a
host knows it stores internal_audit_token or similar.
Sourcepub fn with_extra_url_param(self, name: impl Into<String>) -> Self
pub fn with_extra_url_param(self, name: impl Into<String>) -> Self
Add an extra URL query parameter name to redact.
Sourcepub fn disable_string_scan(self) -> Self
pub fn disable_string_scan(self) -> Self
Disable the heuristic free-form string scanner. The scanner adds a small but non-zero cost to every JSON payload walk; turn it off for performance-critical paths that have already been audited.
Sourcepub fn header_is_sensitive(&self, name: &str) -> bool
pub fn header_is_sensitive(&self, name: &str) -> bool
Whether a given HTTP header name should have its value replaced
with REDACTED_HEADER_VALUE.
Host-explicit deny substrings always win, even over the built-in safe-list — that is how a host says “treat my own webhook delivery header as sensitive even though Harn would normally keep it for debugging.”
Sourcepub fn field_is_sensitive(&self, name: &str) -> bool
pub fn field_is_sensitive(&self, name: &str) -> bool
Whether a JSON object field name should be replaced with the redacted placeholder before the value is even inspected.
Sourcepub fn url_param_is_sensitive(&self, name: &str) -> bool
pub fn url_param_is_sensitive(&self, name: &str) -> bool
Whether a URL query parameter name should have its value replaced.
Sourcepub fn redact_headers(
&self,
headers: &BTreeMap<String, String>,
) -> BTreeMap<String, String>
pub fn redact_headers( &self, headers: &BTreeMap<String, String>, ) -> BTreeMap<String, String>
Returns a BTreeMap of headers with sensitive values replaced
by REDACTED_HEADER_VALUE.
Sourcepub fn redact_url(&self, url: &str) -> String
pub fn redact_url(&self, url: &str) -> String
Redact sensitive query parameters and credentials in URL userinfo. Returns the input unchanged if nothing matches or the URL fails to parse.
Sourcepub fn redact_string<'a>(&self, value: &'a str) -> Cow<'a, str>
pub fn redact_string<'a>(&self, value: &'a str) -> Cow<'a, str>
Returns a redacted string. Cheap (Cow::Borrowed) when nothing
matched. Applies, in order: URL-shaped string detection (so the
userinfo or sensitive query params on https://user:pw@…?api_key=…
are scrubbed), then high-confidence secret pattern replacement.
Sourcepub fn redact_json_in_place(&self, value: &mut JsonValue)
pub fn redact_json_in_place(&self, value: &mut JsonValue)
Recursively walk a JSON value, redacting sensitive object fields and string contents in place.
Sourcepub fn redact_json(&self, value: &JsonValue) -> JsonValue
pub fn redact_json(&self, value: &JsonValue) -> JsonValue
Convenience for callers that have an immutable JSON value: clone once and redact.
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 moreSource§impl Debug for RedactionPolicy
impl Debug for RedactionPolicy
Source§impl Default for RedactionPolicy
impl Default for RedactionPolicy
Source§impl PartialEq for RedactionPolicy
impl PartialEq for RedactionPolicy
Source§fn eq(&self, other: &RedactionPolicy) -> bool
fn eq(&self, other: &RedactionPolicy) -> bool
self and other values to be equal, and is used by ==.impl Eq for RedactionPolicy
impl StructuralPartialEq for RedactionPolicy
Auto Trait Implementations§
impl Freeze for RedactionPolicy
impl RefUnwindSafe for RedactionPolicy
impl Send for RedactionPolicy
impl Sync for RedactionPolicy
impl Unpin for RedactionPolicy
impl UnsafeUnpin for RedactionPolicy
impl UnwindSafe for RedactionPolicy
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);