Skip to main content

Event

Struct Event 

Source
pub struct Event<'a> { /* private fields */ }
Expand description

A reference to a JSON event for field access during evaluation.

Flat keys are checked first: "actor.id" as a single key takes precedence over {"actor": {"id": ...}} nested traversal.

Implementations§

Source§

impl<'a> Event<'a>

Source

pub fn from_value(value: &'a Value) -> Self

Wrap a JSON value as an event.

Source

pub fn get_field(&self, path: &str) -> Option<&'a Value>

Get a field value by name, supporting dot-notation for nested access.

Checks for a flat key first (exact match), then falls back to dot-separated traversal. When a path segment yields an array, each element is tried and the first match is returned (OR semantics).

Source

pub fn all_string_values(&self) -> Vec<&'a str>

Iterate over all string values in the event (for keyword detection).

Recursively walks the entire event object and yields every string value found, including inside nested objects and arrays. Traversal is capped at 64 levels of nesting to prevent stack overflow.

Source

pub fn any_string_value(&self, pred: &dyn Fn(&str) -> bool) -> bool

Check if any string value in the event satisfies a predicate.

Short-circuits on the first match, avoiding the allocation of collecting all string values into a Vec.

Source

pub fn as_value(&self) -> &'a Value

Access the underlying JSON value.

Trait Implementations§

Source§

impl<'a> Debug for Event<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Event<'a>

§

impl<'a> RefUnwindSafe for Event<'a>

§

impl<'a> Send for Event<'a>

§

impl<'a> Sync for Event<'a>

§

impl<'a> Unpin for Event<'a>

§

impl<'a> UnsafeUnpin for Event<'a>

§

impl<'a> UnwindSafe for Event<'a>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.