Skip to main content

VM

Struct VM 

Source
pub struct VM { /* private fields */ }

Implementations§

Source§

impl VM

Source

pub fn new() -> Self

Source

pub fn with_capacity(compile_cap: usize, path_cap: usize) -> Self

Source

pub fn with_registry(registry: Arc<MethodRegistry>) -> Self

Build a VM that shares an existing method registry.

Source

pub fn register_arc(&mut self, name: &str, method: Arc<dyn Method>)

Register a method already wrapped in Arc.

Source

pub fn set_pass_config(&mut self, config: PassConfig)

Replace the pass configuration. The compile cache is not purged, but future lookups key off the new config hash so old entries are effectively invalidated for the new regime.

Source

pub fn pass_config(&self) -> PassConfig

Source

pub fn register( &mut self, name: impl Into<String>, method: impl Method + 'static, )

Register a custom method (callable via .method_name(...) in expressions).

Source

pub fn run_str(&mut self, expr: &str, doc: &Value) -> Result<Value, EvalError>

Parse, compile (cached), and execute expr against doc.

Source

pub fn run_str_with_raw( &mut self, expr: &str, doc: &Value, raw_bytes: Arc<[u8]>, ) -> Result<Value, EvalError>

Parse, compile, and execute with raw JSON source bytes retained so that SIMD byte-scan can short-circuit Opcode::Descendant at the document root.

Source

pub fn execute( &mut self, program: &Program, doc: &Value, ) -> Result<Value, EvalError>

Execute a pre-compiled Program against doc.

Source

pub fn execute_with_raw( &mut self, program: &Program, doc: &Value, raw_bytes: Arc<[u8]>, ) -> Result<Value, EvalError>

Execute with raw JSON source bytes retained on the environment so that descendant opcodes at document root can take the SIMD byte-scan fast path instead of walking the tree.

Source

pub fn execute_val_with_raw( &mut self, program: &Program, root: Val, raw_bytes: Arc<[u8]>, ) -> Result<Value, EvalError>

Execute against a pre-built Val root (skips the Val::from(&Value) conversion on every call). With raw bytes, the doc_hash pointer- cache path is also skipped — byte-scan handles descendants directly and RootChain reads are O(chain length) against the already-built tree.

Source

pub fn execute_val( &mut self, program: &Program, root: Val, ) -> Result<Value, EvalError>

Execute against a pre-built Val root without raw bytes. Skips the Val::from conversion only — path cache and doc hash still behave as in execute().

Source

pub fn execute_val_raw( &mut self, program: &Program, root: Val, ) -> Result<Val, EvalError>

Execute against a pre-built Val root and return the raw Val — no serde_json::Value materialisation. Use when the caller will consume results structurally (further queries, custom walk) and wants to skip a potentially expensive Val → Value conversion.

Source

pub fn execute_with_schema( &mut self, program: &Program, doc: &Value, shape: &Shape, ) -> Result<Value, EvalError>

Execute a compiled program against a document, first specialising against the given shape (turns OptFieldGetField where safe, folds KindCheck where type is known, etc.).

Source

pub fn execute_with_inferred_schema( &mut self, program: &Program, doc: &Value, ) -> Result<Value, EvalError>

Execute a program; infer the shape from the document itself. Costs an O(doc) shape walk before execution; useful when the same compiled program is reused across many docs with similar shapes.

Source

pub fn get_or_compile(&mut self, expr: &str) -> Result<Arc<Program>, EvalError>

Get or compile an expression string (compile cache). Cache key is (pass_config_hash, expr) so that different pass configurations yield different compiled programs.

Source

pub fn cache_stats(&self) -> (usize, usize)

Cache statistics: (compile_entries, path_entries).

Source

pub fn exec(&mut self, program: &Program, env: &Env) -> Result<Val, EvalError>

Execute program in environment env, returning the top-of-stack value.

Trait Implementations§

Source§

impl Default for VM

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for VM

§

impl !RefUnwindSafe for VM

§

impl Send for VM

§

impl Sync for VM

§

impl Unpin for VM

§

impl UnsafeUnpin for VM

§

impl !UnwindSafe for VM

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.