Struct SecretSentinel

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

The main entry point for secret detection and redaction.

  • WHAT – Holds a collection of RedactionRules.
  • HOW – Provides methods to scrub a string (scrub_text) and to simply check whether any secret is present (contains_secrets).
  • WHY – Centralising the rules in a struct enables reuse and makes testing straightforward.

Implementations§

Source§

impl SecretSentinel

Source

pub fn new_default() -> Self

Constructs a SecretSentinel pre‑populated with a sensible default set of rules.

  • WHAT – Returns a sentinel containing three rules: OpenAI, AWS and a generic secret matcher.
  • HOW – Instantiates RedactionRules using the lazily‑initialised regexes above and stores them in the rules vector.
  • WHY – Provides a ready‑to‑use configuration for typical development environments while still allowing callers to create custom instances.
Source

pub fn scrub_text(&self, input: &str) -> String

Redacts all secrets found in input according to the configured rules.

  • WHAT – Returns a new String where each match has been replaced.
  • HOW – Iterates over the rules and applies replace_all for each.
  • WHY – Performing the replacements sequentially ensures that overlapping patterns are handled deterministically.
Source

pub fn contains_secrets(&self, input: &str) -> bool

Checks whether any of the configured rules match input.

  • WHAT – Returns true if at least one rule’s pattern matches.
  • HOW – Uses Iter::any over self.rules with is_match.
  • WHY – A quick predicate useful for short‑circuiting logging or error handling before performing the full redaction.

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> 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, 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.