Skip to main content

Jetro

Struct Jetro 

Source
pub struct Jetro { /* private fields */ }
Expand description

Primary entry point for evaluating Jetro expressions.

Holds a JSON document and evaluates expressions against it. Internally delegates to a thread-local VM so the compile cache and resolution cache accumulate over the lifetime of the thread.

Implementations§

Source§

impl Jetro

Source

pub fn new(document: Value) -> Self

Source

pub fn from_bytes(bytes: Vec<u8>) -> Result<Self, Error>

Parse JSON bytes and retain them alongside the parsed document. Descendant queries ($..key) can then take the SIMD byte-scan path instead of walking the tree.

Source

pub fn from_slice(bytes: &[u8]) -> Result<Self, Error>

Parse JSON from a slice, retaining a copy of the bytes.

Source

pub fn collect<S: AsRef<str>>(&self, expr: S) -> Result<Value, EvalError>

Evaluate expr against the document. Routes through the thread-local VM (compile + path caches); when the Jetro handle carries raw bytes the VM executes on an env with raw_bytes set so Opcode::Descendant can take the SIMD byte-scan fast path.

Source

pub fn collect_val<S: AsRef<str>>(&self, expr: S) -> Result<JetroVal, EvalError>

Evaluate expr and return the raw Val without converting to serde_json::Value. For large structural results (e.g. group_by on 20k+ items) this avoids an expensive materialisation that otherwise dominates runtime. The returned Val supports cheap Arc-clone and shares structure with the source document.

Prefer this over collect when the caller consumes the result structurally (further queries, custom walk, re-evaluation) rather than handing it to serde_json-aware code.

Trait Implementations§

Source§

impl From<Value> for Jetro

Source§

fn from(v: Value) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !Freeze for Jetro

§

impl !RefUnwindSafe for Jetro

§

impl Send for Jetro

§

impl !Sync for Jetro

§

impl Unpin for Jetro

§

impl UnsafeUnpin for Jetro

§

impl UnwindSafe for Jetro

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.