Skip to main content

EntityAwareInjector

Struct EntityAwareInjector 

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

Entity-aware anomaly injector.

Implementations§

Source§

impl EntityAwareInjector

Source

pub fn new(config: EntityAwareConfig) -> Self

Creates a new entity-aware injector.

Source

pub fn get_rate_multiplier( &self, vendor_ctx: Option<&VendorContext>, employee_ctx: Option<&EmployeeContext>, account_ctx: Option<&AccountContext>, ) -> f64

Gets the combined rate multiplier for a transaction context.

Source

pub fn get_applicable_types( &self, vendor_ctx: Option<&VendorContext>, employee_ctx: Option<&EmployeeContext>, account_ctx: Option<&AccountContext>, ) -> Vec<AnomalyType>

Gets applicable anomaly types for a transaction context.

Source

pub fn should_inject<R: Rng>( &self, base_rate: f64, vendor_ctx: Option<&VendorContext>, employee_ctx: Option<&EmployeeContext>, account_ctx: Option<&AccountContext>, rng: &mut R, ) -> bool

Determines if an anomaly should be injected based on context.

Source

pub fn build_vendor_context( &self, vendor_id: impl Into<String>, creation_date: NaiveDate, last_activity: NaiveDate, current_date: NaiveDate, total_spend: Decimal, is_international: bool, ) -> VendorContext

Builds a vendor context from entity data.

Source

pub fn build_employee_context( &self, employee_id: impl Into<String>, hire_date: NaiveDate, current_date: NaiveDate, daily_transaction_count: u32, weekly_hours: f64, is_covering: bool, ) -> EmployeeContext

Builds an employee context from entity data.

Source

pub fn build_account_context( &self, account_code: impl Into<String>, ) -> AccountContext

Builds an account context from account code.

Source

pub fn config(&self) -> &EntityAwareConfig

Returns the configuration.

Trait Implementations§

Source§

impl Default for EntityAwareInjector

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V