pub struct Engine { /* private fields */ }Expand description
Finds sensitive values, replaces them with placeholders and puts the real
values back. Build one with Engine::builder.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn builder() -> EngineBuilder
pub fn builder() -> EngineBuilder
Starts building an engine. With nothing set, it uses the default
rules, the [{TYPE}_{N}] placeholder format and an in-memory vault.
Sourcepub fn cache_stats(&self) -> ScanCacheStats
pub fn cache_stats(&self) -> ScanCacheStats
How the cache of recent scans is doing.
Sourcepub fn set_rules(&self, rules: CompiledRules)
pub fn set_rules(&self, rules: CompiledRules)
Swaps in new rules. Calls already running finish with the old ones. Scans made with the old rules are dropped: they can’t be reused.
Sourcepub fn rules(&self) -> Arc<CompiledRules> ⓘ
pub fn rules(&self) -> Arc<CompiledRules> ⓘ
The rules in use now.
Sourcepub fn scan(&self, text: &str) -> Result<Vec<Match>, Error>
pub fn scan(&self, text: &str) -> Result<Vec<Match>, Error>
Finds sensitive values without changing anything or touching the vault.
Sourcepub fn redact_text(
&self,
scope: &ScopeId,
text: &str,
) -> Result<Redacted, Error>
pub fn redact_text( &self, scope: &ScopeId, text: &str, ) -> Result<Redacted, Error>
Replaces every detected value in text with its placeholder.
Sourcepub fn redact_json(
&self,
scope: &ScopeId,
body: &mut Value,
policy: &dyn KeyPolicy,
) -> Result<Report, Error>
pub fn redact_json( &self, scope: &ScopeId, body: &mut Value, policy: &dyn KeyPolicy, ) -> Result<Report, Error>
Redacts every string in body that policy does not skip.
Sourcepub fn scan_json(
&self,
body: &Value,
policy: &dyn KeyPolicy,
) -> Result<Report, Error>
pub fn scan_json( &self, body: &Value, policy: &dyn KeyPolicy, ) -> Result<Report, Error>
Counts what would be redacted in body without changing it (audit mode).
Each match is reported to the recorder as sent unchanged.
Sourcepub fn restore_text(&self, scope: &ScopeId, text: &str) -> Restored
pub fn restore_text(&self, scope: &ScopeId, text: &str) -> Restored
Replaces every known placeholder in text with its real value.
Unknown placeholders are left as they are and counted.
Sourcepub fn restore_with(
&self,
scope: &ScopeId,
text: &str,
escape: impl Fn(&str) -> String,
) -> Restored
pub fn restore_with( &self, scope: &ScopeId, text: &str, escape: impl Fn(&str) -> String, ) -> Restored
Like Engine::restore_text, but passes each real value through
escape first, e.g. to restore inside raw JSON text.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Engine
impl !RefUnwindSafe for Engine
impl !UnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
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
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