Struct rhai::EvalContext

source ·
pub struct EvalContext<'a, 's, 'ps, 'g, 'c, 't> { /* private fields */ }
Expand description

Context of a script evaluation process.

Implementations§

source§

impl<'a, 's, 'ps, 'g, 'c, 't> EvalContext<'a, 's, 'ps, 'g, 'c, 't>

source

pub fn new( engine: &'a Engine, global: &'g mut GlobalRuntimeState, caches: &'c mut Caches, scope: &'s mut Scope<'ps>, this_ptr: Option<&'t mut Dynamic> ) -> Self

Create a new EvalContext.

source

pub const fn engine(&self) -> &'a Engine

The current Engine.

source

pub fn source(&self) -> Option<&str>

The current source.

source

pub const fn scope(&self) -> &Scope<'ps>

The current Scope.

source

pub fn scope_mut(&mut self) -> &mut Scope<'ps>

Get a mutable reference to the current Scope.

source

pub fn iter_imports(&self) -> impl Iterator<Item = (&str, &Module)>

Get an iterator over the current set of modules imported via import statements, in reverse order (i.e. modules imported last come first).

source

pub const fn tag(&self) -> &Dynamic

Custom state kept in a Dynamic.

source

pub fn tag_mut(&mut self) -> &mut Dynamic

Mutable reference to the custom state kept in a Dynamic.

source

pub const fn global_runtime_state(&self) -> &GlobalRuntimeState

(internals) The current GlobalRuntimeState. Exported under the internals feature only.

source

pub fn global_runtime_state_mut(&mut self) -> &mut GlobalRuntimeState

(internals) Get a mutable reference to the current GlobalRuntimeState. Exported under the internals feature only.

source

pub fn iter_namespaces(&self) -> impl Iterator<Item = &Module>

Get an iterator over the namespaces containing definition of all script-defined functions.

Not available under no_function.

source

pub fn namespaces(&self) -> &[Shared<Module>]

(internals) The current set of namespaces containing definitions of all script-defined functions. Exported under the internals feature only.

Not available under no_function.

source

pub fn this_ptr(&self) -> Option<&Dynamic>

The current bound this pointer, if any.

source

pub fn this_ptr_mut(&mut self) -> Option<&mut Dynamic>

Mutable reference to the current bound this pointer, if any.

source

pub const fn call_level(&self) -> usize

The current nesting level of function calls.

source

pub fn eval_expression_tree( &mut self, expr: &Expression<'_> ) -> Result<Dynamic, Box<EvalAltResult>>

Evaluate an expression tree within this evaluation context.

§WARNING - Low Level API

This function is very low level. It evaluates an expression from an AST.

source

pub fn eval_expression_tree_raw( &mut self, expr: &Expression<'_>, rewind_scope: bool ) -> Result<Dynamic, Box<EvalAltResult>>

👎Deprecated: This API is NOT deprecated, but it is considered volatile and may change in the future.

Evaluate an expression tree within this evaluation context.

The following option is available:

  • whether to rewind the Scope after evaluation if the expression is a StmtBlock
§WARNING - Unstable API

This API is volatile and may change in the future.

§WARNING - Low Level API

This function is extremely low level. It evaluates an expression from an AST.

Auto Trait Implementations§

§

impl<'a, 's, 'ps, 'g, 'c, 't> Freeze for EvalContext<'a, 's, 'ps, 'g, 'c, 't>

§

impl<'a, 's, 'ps, 'g, 'c, 't> !RefUnwindSafe for EvalContext<'a, 's, 'ps, 'g, 'c, 't>

§

impl<'a, 's, 'ps, 'g, 'c, 't> !Send for EvalContext<'a, 's, 'ps, 'g, 'c, 't>

§

impl<'a, 's, 'ps, 'g, 'c, 't> !Sync for EvalContext<'a, 's, 'ps, 'g, 'c, 't>

§

impl<'a, 's, 'ps, 'g, 'c, 't> Unpin for EvalContext<'a, 's, 'ps, 'g, 'c, 't>

§

impl<'a, 's, 'ps, 'g, 'c, 't> !UnwindSafe for EvalContext<'a, 's, 'ps, 'g, 'c, 't>

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

§

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

§

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.