Struct rhai::GlobalRuntimeState
source · [−]pub struct GlobalRuntimeState<'a> {
pub source: Identifier,
pub num_operations: u64,
pub num_modules_loaded: usize,
pub scope_level: usize,
pub always_search_scope: bool,
pub embedded_module_resolver: Option<Shared<StaticModuleResolver>>,
pub constants: Option<Shared<Locked<BTreeMap<ImmutableString, Dynamic>>>>,
pub tag: Dynamic,
pub debugger: Debugger,
/* private fields */
}
Expand description
(internals) Global runtime states.
Exported under the internals
feature only.
Fields
source: Identifier
Source of the current context.
No source if the string is empty.
num_operations: u64
Number of operations performed.
num_modules_loaded: usize
Number of modules loaded.
scope_level: usize
Level of the current scope.
The global (root) level is zero, a new block (or function call) is one level higher, and so on.
always_search_scope: bool
Force a Scope
search by name.
Normally, access to variables are parsed with a relative offset into the
Scope
to avoid a lookup.
In some situation, e.g. after running an eval
statement, or after a custom syntax
statement, subsequent offsets may become mis-aligned.
When that happens, this flag is turned on.
embedded_module_resolver: Option<Shared<StaticModuleResolver>>
Embedded module resolver.
constants: Option<Shared<Locked<BTreeMap<ImmutableString, Dynamic>>>>
Cache of globally-defined constants.
Interior mutability is needed because it is shared in order to aid in cloning.
tag: Dynamic
Custom state that can be used by the external host.
debugger: Debugger
Debugging interface.
Implementations
sourceimpl GlobalRuntimeState<'_>
impl GlobalRuntimeState<'_>
sourcepub fn new(engine: &Engine) -> Self
pub fn new(engine: &Engine) -> Self
Create a new GlobalRuntimeState
based on an Engine
.
sourcepub fn num_imports(&self) -> usize
pub fn num_imports(&self) -> usize
Get the length of the stack of globally-imported modules.
Not available under no_module
.
Get the globally-imported module at a particular index.
Not available under no_module
.
sourcepub fn find_import(&self, name: &str) -> Option<usize>
pub fn find_import(&self, name: &str) -> Option<usize>
Get the index of a globally-imported module by name.
Not available under no_module
.
sourcepub fn push_import(
&mut self,
name: impl Into<ImmutableString>,
module: impl Into<Shared<Module>>
)
pub fn push_import(
&mut self,
name: impl Into<ImmutableString>,
module: impl Into<Shared<Module>>
)
Push an imported module onto the stack.
Not available under no_module
.
sourcepub fn truncate_imports(&mut self, size: usize)
pub fn truncate_imports(&mut self, size: usize)
Truncate the stack of globally-imported modules to a particular length.
Not available under no_module
.
sourcepub fn iter_imports(&self) -> impl Iterator<Item = (&str, &Module)>
pub fn iter_imports(&self) -> impl Iterator<Item = (&str, &Module)>
Get an iterator to the stack of globally-imported modules in reverse order.
Not available under no_module
.
sourcepub fn scan_imports_raw(
&self
) -> impl Iterator<Item = (&ImmutableString, &Shared<Module>)>
pub fn scan_imports_raw(
&self
) -> impl Iterator<Item = (&ImmutableString, &Shared<Module>)>
Get an iterator to the stack of globally-imported modules in forward order.
Not available under no_module
.
sourcepub fn contains_qualified_fn(&self, hash: u64) -> bool
pub fn contains_qualified_fn(&self, hash: u64) -> bool
Does the specified function hash key exist in the stack of globally-imported modules?
Not available under no_module
.
sourcepub fn get_qualified_fn(
&self,
hash: u64
) -> Option<(&CallableFunction, Option<&str>)>
pub fn get_qualified_fn(
&self,
hash: u64
) -> Option<(&CallableFunction, Option<&str>)>
Get the specified function via its hash key from the stack of globally-imported modules.
Not available under no_module
.
sourcepub fn contains_iter(&self, id: TypeId) -> bool
pub fn contains_iter(&self, id: TypeId) -> bool
Trait Implementations
sourceimpl<'a> Clone for GlobalRuntimeState<'a>
impl<'a> Clone for GlobalRuntimeState<'a>
sourcefn clone(&self) -> GlobalRuntimeState<'a>
fn clone(&self) -> GlobalRuntimeState<'a>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for GlobalRuntimeState<'_>
impl Debug for GlobalRuntimeState<'_>
sourceimpl<K: Into<ImmutableString>, M: Into<Shared<Module>>> Extend<(K, M)> for GlobalRuntimeState<'_>
impl<K: Into<ImmutableString>, M: Into<Shared<Module>>> Extend<(K, M)> for GlobalRuntimeState<'_>
sourcefn extend<T: IntoIterator<Item = (K, M)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, M)>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<'a> IntoIterator for &'a GlobalRuntimeState<'_>
impl<'a> IntoIterator for &'a GlobalRuntimeState<'_>
sourceimpl IntoIterator for GlobalRuntimeState<'_>
impl IntoIterator for GlobalRuntimeState<'_>
Auto Trait Implementations
impl<'a> !RefUnwindSafe for GlobalRuntimeState<'a>
impl<'a> !Send for GlobalRuntimeState<'a>
impl<'a> !Sync for GlobalRuntimeState<'a>
impl<'a> Unpin for GlobalRuntimeState<'a>
impl<'a> !UnwindSafe for GlobalRuntimeState<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more