Skip to main content

RuleCondition

Enum RuleCondition 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

PatternExists

True when the pattern has any match state.

Fields

§pattern_id: u32

Pattern table index.

§

PatternCountGt

True when the pattern count is strictly greater than threshold.

Fields

§pattern_id: u32

Pattern table index.

§threshold: u32

Exclusive lower bound.

§

PatternCountGte

True when the pattern count is greater than or equal to threshold.

Fields

§pattern_id: u32

Pattern table index.

§threshold: u32

Inclusive lower bound.

§

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.

Fields

§field: Arc<str>

Source field name.

§pattern: Arc<str>

Regular expression pattern.

§

SubstringMatch

True when haystack contains needle.

Fields

§haystack: Arc<str>

Source text or field name.

§needle: Arc<str>

Required substring.

§

PrefixMatch

True when value starts with prefix.

Fields

§value: Arc<str>

Source text or field name.

§prefix: Arc<str>

Required prefix.

§

SuffixMatch

True when value ends with suffix.

Fields

§value: Arc<str>

Source text or field name.

§suffix: Arc<str>

Required suffix.

§

RangeMatch

True when value falls inside the inclusive numeric range.

Fields

§value: u64

Observed value.

§min: u64

Inclusive lower bound.

§max: u64

Inclusive upper bound.

§

SetMembership

True when value is present in set.

Fields

§value: Arc<str>

Candidate value.

§set: SmallVec<[Arc<str>; 4]>

Accepted set members.

§

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

§field: Arc<str>

Context field name to look up (e.g. "detector_id").

§set: SmallVec<[Arc<str>; 4]>

Accepted set members.

§

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

Source

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

Source§

fn clone(&self) -> RuleCondition

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RuleCondition

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for RuleCondition

Source§

impl PartialEq for RuleCondition

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more