pub struct Condition {
pub field: String,
pub op: CompareOp,
pub value: Value,
pub description: Option<String>,
}Expand description
A single condition to evaluate
Fields§
§field: StringField path to evaluate (dot notation, e.g., “metrics.cpu_usage”)
op: CompareOpComparison operator
value: ValueValue to compare against
description: Option<String>Optional description
Implementations§
Source§impl Condition
impl Condition
Sourcepub fn new(field: impl Into<String>, op: CompareOp, value: Value) -> Self
pub fn new(field: impl Into<String>, op: CompareOp, value: Value) -> Self
Create a new condition
Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Add description
Sourcepub fn evaluate(&self, context: &RuleContext) -> bool
pub fn evaluate(&self, context: &RuleContext) -> bool
Evaluate condition against context
Sourcepub fn ge(field: impl Into<String>, value: impl Into<Value>) -> Self
pub fn ge(field: impl Into<String>, value: impl Into<Value>) -> Self
Field greater than or equal to value
Sourcepub fn le(field: impl Into<String>, value: impl Into<Value>) -> Self
pub fn le(field: impl Into<String>, value: impl Into<Value>) -> Self
Field less than or equal to value
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Condition
impl<'de> Deserialize<'de> for Condition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Condition
Auto Trait Implementations§
impl Freeze for Condition
impl RefUnwindSafe for Condition
impl Send for Condition
impl Sync for Condition
impl Unpin for Condition
impl UnsafeUnpin for Condition
impl UnwindSafe for Condition
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