Skip to main content

EngineBuilder

Struct EngineBuilder 

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

Builds an Engine. Start with Engine::builder.

use veil_engine::{Engine, RulesFile, ScopeId};

let engine = Engine::builder().rules(RulesFile::default()).build()?;
let r = engine.redact_text(&ScopeId::new("chat-42"), "Email ana@example.com")?;
assert_eq!(r.text, "Email [EMAIL_1]");

Implementations§

Source§

impl EngineBuilder

Source

pub fn rules(self, rules: RulesFile) -> Self

What to detect. Default: RulesFile::default.

Source

pub fn options(self, options: Options) -> Self

The placeholder format and restoration options. Default: Options::default.

Source

pub fn recognizer(self, recognizer: Arc<dyn EntityRecognizer>) -> Self

The name-detection model, used when the rules turn name detection on. Without one, such rules make every redaction fail rather than send names.

Source

pub fn compiled_rules(self, rules: CompiledRules) -> Self

Rules compiled in advance with CompiledRules::compile, used as they are. Replaces anything given to rules, options and recognizer.

Source

pub fn vault(self, vault: Arc<dyn Vault>) -> Self

Where placeholder mappings are kept. Default: a new MemoryVault.

Source

pub fn recorder(self, recorder: Arc<dyn Recorder>) -> Self

Told about every value that live traffic matched. Default: none.

Source

pub fn scan_cache_bytes(self, bytes: usize) -> Self

Memory for remembering scans between calls, in bytes; 0 scans every call in full. Default: DEFAULT_SCAN_CACHE_BUDGET.

Source

pub fn build(self) -> Result<Engine, RulesError>

Compiles the rules, unless they were given compiled, and builds the engine.

Trait Implementations§

Source§

impl Default for EngineBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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