pub struct Rule {Show 13 fields
pub id: String,
pub name: String,
pub description: Option<String>,
pub priority: Priority,
pub condition: ConditionExpr,
pub action: Action,
pub enabled: bool,
pub tags: Vec<String>,
pub cooldown_ms: Option<u64>,
pub rate_limit: Option<RateLimit>,
pub stop_on_match: bool,
pub created_at: u64,
pub updated_at: u64,
}Expand description
A complete rule definition
Fields§
§id: StringUnique rule ID
name: StringHuman-readable name
description: Option<String>Description
priority: PriorityRule priority
condition: ConditionExprCondition expression
action: ActionAction to execute when condition matches
enabled: boolWhether rule is enabled
Tags for categorization
cooldown_ms: Option<u64>Cooldown between executions (milliseconds)
rate_limit: Option<RateLimit>Maximum executions per time window
stop_on_match: boolStop processing further rules if this one matches
created_at: u64Created timestamp
updated_at: u64Updated timestamp
Implementations§
Source§impl Rule
impl Rule
Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Set description
Sourcepub fn with_priority(self, priority: Priority) -> Self
pub fn with_priority(self, priority: Priority) -> Self
Set priority
Sourcepub fn with_condition(self, condition: ConditionExpr) -> Self
pub fn with_condition(self, condition: ConditionExpr) -> Self
Set condition
Sourcepub fn with_action(self, action: Action) -> Self
pub fn with_action(self, action: Action) -> Self
Set action
Sourcepub fn with_cooldown(self, cooldown_ms: u64) -> Self
pub fn with_cooldown(self, cooldown_ms: u64) -> Self
Set cooldown
Sourcepub fn with_rate_limit(self, max_executions: u32, window_secs: u32) -> Self
pub fn with_rate_limit(self, max_executions: u32, window_secs: u32) -> Self
Set rate limit
Sourcepub fn stop_on_match(self) -> Self
pub fn stop_on_match(self) -> Self
Stop processing further rules on match
Sourcepub fn matches(&self, context: &RuleContext) -> bool
pub fn matches(&self, context: &RuleContext) -> bool
Check if rule matches context
Trait Implementations§
impl StructuralPartialEq for Rule
Auto Trait Implementations§
impl Freeze for Rule
impl RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnsafeUnpin for Rule
impl UnwindSafe for Rule
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