Struct starlark::environment::Module
source · pub struct Module { /* private fields */ }
Expand description
A container for user values, used during execution.
A module contains both a FrozenHeap
and Heap
on which different values are allocated.
You can get references to these heaps with frozen_heap
and
heap
. Be careful not to use these values after the Module
has been
released unless you obtain a reference to the frozen heap.
Implementations§
source§impl Module
impl Module
sourcepub fn frozen_heap(&self) -> &FrozenHeap
pub fn frozen_heap(&self) -> &FrozenHeap
Get the frozen heap on which frozen values are allocated by this module.
sourcepub fn names(&self) -> impl Iterator<Item = FrozenStringValue> + '_
pub fn names(&self) -> impl Iterator<Item = FrozenStringValue> + '_
Iterate through all the names defined in this module. Only includes symbols that are publicly exposed.
sourcepub fn names_and_visibilities(
&self
) -> impl Iterator<Item = (FrozenStringValue, Visibility)> + '_
pub fn names_and_visibilities( &self ) -> impl Iterator<Item = (FrozenStringValue, Visibility)> + '_
Iterate through all the names defined in this module, including those that are private.
sourcepub fn get<'v>(&'v self, name: &str) -> Option<Value<'v>>
pub fn get<'v>(&'v self, name: &str) -> Option<Value<'v>>
Get the value of the exported variable name
.
Returns None
if the variable isn’t defined in the module or it is private.
sourcepub fn freeze(self) -> Result<FrozenModule>
pub fn freeze(self) -> Result<FrozenModule>
Freeze the environment, all its value will become immutable afterwards.
sourcepub fn set<'v>(&'v self, name: &str, value: Value<'v>)
pub fn set<'v>(&'v self, name: &str, value: Value<'v>)
Set the value of a variable in the environment. Modifying these variables while executing is ongoing can have surprising effects.
sourcepub fn import_public_symbols(&self, module: &FrozenModule)
pub fn import_public_symbols(&self, module: &FrozenModule)
Import symbols from a module, similar to what is done during load()
.
sourcepub fn set_extra_value<'v>(&'v self, v: Value<'v>)
pub fn set_extra_value<'v>(&'v self, v: Value<'v>)
Field that can be used for any purpose you want.
sourcepub fn extra_value<'v>(&'v self) -> Option<Value<'v>>
pub fn extra_value<'v>(&'v self) -> Option<Value<'v>>
Field that can be used for any purpose you want.