Struct rhai::GlobalRuntimeState
source · pub struct GlobalRuntimeState {
pub lib: ThinVec<Shared<Module>>,
pub source: Option<ImmutableString>,
pub num_operations: u64,
pub num_modules_loaded: usize,
pub level: 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,
/* private fields */
}
Expand description
(internals) Global runtime states.
Exported under the internals
feature only.
Fields§
§lib: ThinVec<Shared<Module>>
The current stack of loaded modules containing script-defined functions.
source: Option<ImmutableString>
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.
level: usize
The current nesting level of function calls.
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.
Implementations§
source§impl GlobalRuntimeState
impl GlobalRuntimeState
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 iter_imports_raw(
&self
) -> impl Iterator<Item = (&ImmutableString, &Shared<Module>)>
pub fn iter_imports_raw( &self ) -> impl Iterator<Item = (&ImmutableString, &Shared<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,
global_namespace_only: bool
) -> Option<(&RhaiFunc, Option<&ImmutableString>)>
pub fn get_qualified_fn( &self, hash: u64, global_namespace_only: bool ) -> Option<(&RhaiFunc, Option<&ImmutableString>)>
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
sourcepub fn get_iter(
&self,
id: TypeId
) -> Option<&dyn Fn(Dynamic) -> Box<dyn Iterator<Item = Result<Dynamic, Box<EvalAltResult>>>>>
pub fn get_iter( &self, id: TypeId ) -> Option<&dyn Fn(Dynamic) -> Box<dyn Iterator<Item = Result<Dynamic, Box<EvalAltResult>>>>>
sourcepub fn debugger(&self) -> &Debugger
pub fn debugger(&self) -> &Debugger
Return a reference to the debugging interface.
§Panics
Panics if the debugging interface is not set.
sourcepub fn debugger_mut(&mut self) -> &mut Debugger
pub fn debugger_mut(&mut self) -> &mut Debugger
Return a mutable reference to the debugging interface.
§Panics
Panics if the debugging interface is not set.
Trait Implementations§
source§impl Clone for GlobalRuntimeState
impl Clone for GlobalRuntimeState
source§fn clone(&self) -> GlobalRuntimeState
fn clone(&self) -> GlobalRuntimeState
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for GlobalRuntimeState
impl Debug for GlobalRuntimeState
source§impl<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
source§fn extend<T: IntoIterator<Item = (K, M)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, M)>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Auto Trait Implementations§
impl Freeze for GlobalRuntimeState
impl !RefUnwindSafe for GlobalRuntimeState
impl !Send for GlobalRuntimeState
impl !Sync for GlobalRuntimeState
impl Unpin for GlobalRuntimeState
impl !UnwindSafe for GlobalRuntimeState
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Variant for T
impl<T> Variant for T
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Variant
trait object to &mut dyn Any
.source§fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
Variant
trait object to Box<dyn Any>
.