pub struct PolicyEngine { /* private fields */ }Expand description
Policy engine for evaluating transaction requests
Implementations§
Source§impl PolicyEngine
impl PolicyEngine
Sourcepub fn new(config: PolicyConfig) -> Self
pub fn new(config: PolicyConfig) -> Self
Create a new policy engine
Sourcepub fn config(&self) -> &PolicyConfig
pub fn config(&self) -> &PolicyConfig
Get the current policy configuration
Sourcepub fn update_config(&mut self, config: PolicyConfig)
pub fn update_config(&mut self, config: PolicyConfig)
Update the policy configuration
Sourcepub fn evaluate(&self, tx: &TransactionRequest) -> Result<PolicyDecision>
pub fn evaluate(&self, tx: &TransactionRequest) -> Result<PolicyDecision>
Evaluate a transaction request against the policy
Sourcepub fn record_transaction(&self, tx: &TransactionRequest) -> Result<()>
pub fn record_transaction(&self, tx: &TransactionRequest) -> Result<()>
Record a successful transaction for spending tracking
Sourcepub fn daily_spending(&self, chain: ChainType) -> u128
pub fn daily_spending(&self, chain: ChainType) -> u128
Get current daily spending for a chain
Sourcepub fn weekly_spending(&self, chain: ChainType) -> u128
pub fn weekly_spending(&self, chain: ChainType) -> u128
Get current weekly spending for a chain
Sourcepub fn reset_spending(&self)
pub fn reset_spending(&self)
Reset all spending trackers
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PolicyEngine
impl !RefUnwindSafe for PolicyEngine
impl Send for PolicyEngine
impl Sync for PolicyEngine
impl Unpin for PolicyEngine
impl !UnwindSafe for PolicyEngine
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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