#[non_exhaustive]pub enum RuleCondition {
Show 19 variants
PatternExists {
pattern_id: u32,
},
PatternCountGt {
pattern_id: u32,
threshold: u32,
},
PatternCountGte {
pattern_id: u32,
threshold: u32,
},
FileSizeLt(u64),
FileSizeLte(u64),
FileSizeGt(u64),
FileSizeGte(u64),
FileSizeEq(u64),
FileSizeNe(u64),
LiteralTrue,
LiteralFalse,
RegexMatch {
field: Arc<str>,
pattern: Arc<str>,
},
SubstringMatch {
haystack: Arc<str>,
needle: Arc<str>,
},
PrefixMatch {
value: Arc<str>,
prefix: Arc<str>,
},
SuffixMatch {
value: Arc<str>,
suffix: Arc<str>,
},
RangeMatch {
value: u64,
min: u64,
max: u64,
},
SetMembership {
value: Arc<str>,
set: SmallVec<[Arc<str>; 4]>,
},
FieldInSet {
field: Arc<str>,
set: SmallVec<[Arc<str>; 4]>,
},
Opaque(Arc<dyn RuleConditionExt>),
}Expand description
A typed rule leaf condition.
pattern_id indexes the rule_bitmaps and rule_counts buffers used by
RuleFormula::to_program. File-size thresholds are accepted as u64;
thresholds above the current scalar IR file-size range are folded to their
mathematically forced result.
§Examples
use vyre_libs::rule::RuleCondition;
let condition = RuleCondition::PatternCountGte {
pattern_id: 7,
threshold: 2,
};
assert!(matches!(condition, RuleCondition::PatternCountGte { .. }));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
PatternExists
True when the pattern has any match state.
PatternCountGt
True when the pattern count is strictly greater than threshold.
PatternCountGte
True when the pattern count is greater than or equal to threshold.
FileSizeLt(u64)
True when the file size is less than the threshold.
FileSizeLte(u64)
True when the file size is less than or equal to the threshold.
FileSizeGt(u64)
True when the file size is greater than the threshold.
FileSizeGte(u64)
True when the file size is greater than or equal to the threshold.
FileSizeEq(u64)
True when the file size equals the threshold.
FileSizeNe(u64)
True when the file size does not equal the threshold.
LiteralTrue
Constant true leaf.
LiteralFalse
Constant false leaf.
RegexMatch
True when text matched by field satisfies pattern.
SubstringMatch
True when haystack contains needle.
PrefixMatch
True when value starts with prefix.
SuffixMatch
True when value ends with suffix.
RangeMatch
True when value falls inside the inclusive numeric range.
SetMembership
True when value is present in set.
FieldInSet
True when the value of context field field is present in
set. Differs from Self::SetMembership: this variant
dereferences field against the evaluation context, while
SetMembership compares a static value payload.
Lets a rule express “detector_id is one of …” without
emulating it via a regex alternation.
Fields
Opaque(Arc<dyn RuleConditionExt>)
Extension-declared rule condition.
Downstream crates supply an Arc<dyn RuleConditionExt> with its
own evaluator + required-buffer contract. The core rule builder
rejects opaque conditions because it cannot lower them truthfully;
extension-aware builders can call RuleConditionExt::required_buffers
when wiring the extension to concrete IR.
Implementations§
Source§impl RuleCondition
impl RuleCondition
Sourcepub fn required_extension_buffers(&self) -> Vec<BufferDecl>
pub fn required_extension_buffers(&self) -> Vec<BufferDecl>
Return the buffer declarations this condition requires.
Frozen conditions need only the six canonical rule buffers
(rule_ids, pattern_ids, rule_bitmaps, rule_counts,
file_size, verdicts). Extension conditions contribute extra
buffers via RuleConditionExt::required_buffers - callers merge
the results.
Trait Implementations§
Source§impl Clone for RuleCondition
impl Clone for RuleCondition
Source§fn clone(&self) -> RuleCondition
fn clone(&self) -> RuleCondition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RuleCondition
impl Debug for RuleCondition
impl Eq for RuleCondition
Auto Trait Implementations§
impl !RefUnwindSafe for RuleCondition
impl !UnwindSafe for RuleCondition
impl Freeze for RuleCondition
impl Send for RuleCondition
impl Sync for RuleCondition
impl Unpin for RuleCondition
impl UnsafeUnpin for RuleCondition
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> ⓘ
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> ⓘ
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