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

source

pub fn new() -> Self

Create a new module environment with no contents.

source

pub fn heap(&self) -> &Heap

Get the heap on which values are allocated by this module.

source

pub fn frozen_heap(&self) -> &FrozenHeap

Get the frozen heap on which frozen values are allocated by this module.

source

pub fn names(&self) -> impl Iterator<Item = FrozenStringValue> + '_

Iterate through all the names defined in this module. Only includes symbols that are publicly exposed.

source

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.

source

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.

source

pub fn freeze(self) -> Result<FrozenModule>

Freeze the environment, all its value will become immutable afterwards.

source

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.

source

pub fn import_public_symbols(&self, module: &FrozenModule)

Import symbols from a module, similar to what is done during load().

source

pub fn set_extra_value<'v>(&'v self, v: Value<'v>)

Field that can be used for any purpose you want.

source

pub fn extra_value<'v>(&'v self) -> Option<Value<'v>>

Field that can be used for any purpose you want.

Trait Implementations§

source§

impl Debug for Module

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Module

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Module

§

impl Send for Module

§

impl !Sync for Module

§

impl Unpin for Module

§

impl !UnwindSafe for Module

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> ToAst for T

source§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

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.