Skip to main content

Engine

Struct Engine 

Source
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

Source

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.

Source

pub fn cache_stats(&self) -> ScanCacheStats

How the cache of recent scans is doing.

Source

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.

Source

pub fn rules(&self) -> Arc<CompiledRules> ⓘ

The rules in use now.

Source

pub fn vault(&self) -> &Arc<dyn Vault> ⓘ

The vault placeholders are kept in.

Source

pub fn scan(&self, text: &str) -> Result<Vec<Match>, Error>

Finds sensitive values without changing anything or touching the vault.

Source

pub fn redact_text( &self, scope: &ScopeId, text: &str, ) -> Result<Redacted, Error>

Replaces every detected value in text with its placeholder.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn restore_json( &self, scope: &ScopeId, value: &mut Value, policy: &dyn KeyPolicy, ) -> Report

Restores every string in value that policy does not skip.

Trait Implementations§

Source§

impl Default for Engine

Source§

fn default() -> Self

The default rules and placeholder format, with an in-memory vault.

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.