Skip to main content

JsonEvent

Struct JsonEvent 

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

Zero-copy event backed by serde_json::Value.

Supports both borrowed (&Value) and owned (Value) backing via Cow. This is the primary implementation for JSON/NDJSON input.

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

Implementations§

Source§

impl<'a> JsonEvent<'a>

Source

pub fn borrow(v: &'a Value) -> Self

Wrap a borrowed JSON value as an event.

Source

pub fn owned(v: Value) -> Self

Wrap an owned JSON value as an event.

Trait Implementations§

Source§

impl<'a> Debug for JsonEvent<'a>

Source§

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

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

impl<'a> Event for JsonEvent<'a>

Source§

fn get_field(&self, path: &str) -> Option<EventValue<'_>>

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§

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§

fn all_string_values(&self) -> Vec<Cow<'_, 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§

fn to_json(&self) -> Value

Materialize the event as a serde_json::Value.
Source§

impl<'a> From<&'a Value> for JsonEvent<'a>

Source§

fn from(v: &'a Value) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for JsonEvent<'static>

Source§

fn from(v: Value) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for JsonEvent<'a>

§

impl<'a> RefUnwindSafe for JsonEvent<'a>

§

impl<'a> Send for JsonEvent<'a>

§

impl<'a> Sync for JsonEvent<'a>

§

impl<'a> Unpin for JsonEvent<'a>

§

impl<'a> UnsafeUnpin for JsonEvent<'a>

§

impl<'a> UnwindSafe for JsonEvent<'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.