pub struct EntityAwareInjector { /* private fields */ }Expand description
Entity-aware anomaly injector.
Implementations§
Source§impl EntityAwareInjector
impl EntityAwareInjector
Sourcepub fn new(config: EntityAwareConfig) -> Self
pub fn new(config: EntityAwareConfig) -> Self
Creates a new entity-aware injector.
Sourcepub fn get_rate_multiplier(
&self,
vendor_ctx: Option<&VendorContext>,
employee_ctx: Option<&EmployeeContext>,
account_ctx: Option<&AccountContext>,
) -> f64
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.
Sourcepub fn get_applicable_types(
&self,
vendor_ctx: Option<&VendorContext>,
employee_ctx: Option<&EmployeeContext>,
account_ctx: Option<&AccountContext>,
) -> Vec<AnomalyType>
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.
Sourcepub 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
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.
Sourcepub 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
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.
Sourcepub 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
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.
Sourcepub fn build_account_context(
&self,
account_code: impl Into<String>,
) -> AccountContext
pub fn build_account_context( &self, account_code: impl Into<String>, ) -> AccountContext
Builds an account context from account code.
Sourcepub fn config(&self) -> &EntityAwareConfig
pub fn config(&self) -> &EntityAwareConfig
Returns the configuration.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EntityAwareInjector
impl RefUnwindSafe for EntityAwareInjector
impl Send for EntityAwareInjector
impl Sync for EntityAwareInjector
impl Unpin for EntityAwareInjector
impl UnwindSafe for EntityAwareInjector
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
Mutably borrows from an owned value. Read more