pub struct SecretRedactor { /* private fields */ }Expand description
Registry of resolved secret values and the text that replaces each one.
All state is behind one lock: registration takes it for writing, redaction for reading, so both are safe from any thread.
Implementations§
Source§impl SecretRedactor
impl SecretRedactor
pub const fn new() -> Self
Sourcepub fn register(&self, reference: &str, value: &str)
pub fn register(&self, reference: &str, value: &str)
Registers value, resolved from reference, and the forms of it
that a connector or a formatter can derive: see the module
documentation.
Sourcepub fn register_credential(&self, value: &str)
pub fn register_credential(&self, value: &str)
Adds a schema-declared credential. A reference registered for the same value, before or after this call, takes precedence over the marker. The global length floor applies here too.
Sourcepub fn redact<'a>(&self, text: &'a str) -> Cow<'a, str>
pub fn redact<'a>(&self, text: &'a str) -> Cow<'a, str>
Replaces every registered value in text.
A value is replaced where it stands as a whole token: a secret that is a common word, such as a user name, does not rewrite the longer identifiers that contain it.
Sourcepub fn redact_for_panic<'a>(&self, text: &'a str) -> Cow<'a, str>
pub fn redact_for_panic<'a>(&self, text: &'a str) -> Cow<'a, str>
Redacts a panic payload without waiting for a registry writer. The panic may have interrupted that writer on this thread. While a writer holds the lock, omit the payload; the hook keeps its location and backtrace. A lock poisoned by an earlier panic still holds a usable registry.
Sourcepub fn redact_bytes<'a>(&self, bytes: &'a [u8]) -> Cow<'a, [u8]>
pub fn redact_bytes<'a>(&self, bytes: &'a [u8]) -> Cow<'a, [u8]>
Replaces every registered value in bytes, read as UTF-8.
Sourcepub fn redact_json(&self, value: &mut Value)
pub fn redact_json(&self, value: &mut Value)
Replaces every registered value in the strings of value, keys
included.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SecretRedactor
impl Forget for SecretRedactor
impl Move for SecretRedactor
impl RefUnwindSafe for SecretRedactor
impl Send for SecretRedactor
impl Sync for SecretRedactor
impl Unpin for SecretRedactor
impl UnsafeUnpin for SecretRedactor
impl UnwindSafe for SecretRedactor
Blanket Implementations§
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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 more