#[repr(transparent)]
pub struct Module<'scope>(_, _);
Expand description

Functionality in Julia can be accessed through its module system. You can get a handle to the three standard modules, Main, Base, and Core and access their submodules through them. If you include your own Julia code with Julia::include, AsyncJulia::include, or AsyncJulia::try_include its contents are made available relative to Main.

The most important methods offered by this wrapper are those that let you access submodules, functions, and other global values defined in the module. These come in two variants: one that roots the result and one that doesn’t. If you never redefine the module, it’s safe to leave named functions, constants and submodules unrooted when you use them from Rust. The same holds true for other global values that are never redefined to point at another value.

Implementations

Returns the name of this module.

Returns the parent of this module.

Returns the parent of this module without rooting it.

Extend the lifetime of this module. This is safe as long as the module is never redefined.

Returns a handle to Julia’s Main-module. If you include your own Julia code with Julia::include, AsyncJulia::include, or AsyncJulia::try_include its contents are made available relative to Main.

Returns a handle to Julia’s Core-module.

Returns a handle to Julia’s Base-module.

Returns true if self has imported sym.

Returns the submodule named name relative to this module. You have to visit this level by level: you can’t access Main.A.B by calling this function with "A.B", but have to access A first and then B.

Returns an error if the submodule doesn’t exist.

Returns the submodule named name relative to this module without rooting it. You have to access this level by level: you can’t access Main.A.B by calling this function with "A.B", but have to access A first and then B.

Returns an error if the submodule doesn’t exist.

Set a global value in this module. Note that if this global already exists, this can make the old value unreachable. If an excection is thrown, it’s caught, rooted and returned.

Safety: Mutating Julia data is generally unsafe because it can’t be guaranteed mutating this value is allowed.

Set a global value in this module. Note that if this global already exists, this can make the old value unreachable. If an exception is thrown it’s caught but not rooted and returned.

Safety: Mutating Julia data is generally unsafe because it can’t be guaranteed mutating this value is allowed.

Set a global value in this module. Note that if this global already exists, this can make the old value unreachable.

Safety: Mutating Julia data is generally unsafe because it can’t be guaranteed mutating this value is allowed.

Set a constant in this module. If Julia throws an exception it’s caught and rooted in the current frame, if the exception can’t be rooted a JlrsError::AllocError is returned. If no exception is thrown an unrooted reference to the constant is returned.

Set a constant in this module. If Julia throws an exception it’s caught. Otherwise an unrooted reference to the constant is returned.

Set a constant in this module. If the constant already exists the process aborts, otherwise an unrooted reference to the constant is returned.

Safety: This method must not throw an error if called from a ccalled function.

Returns the global named name in this module. Returns an error if the global doesn’t exist.

Returns the global named name in this module without rooting it. Returns an error if the global doesn’t exist.

Returns the global named name in this module as a LeakedValue. Returns an error if the global doesn’t exist.

Returns the function named name in this module. Returns an error if the function doesn’t exist or if it’s not a subtype of Function.

Returns the function named name in this module without rooting it. Returns an error if the function doesn’t exist or if it’s not a subtype of Function.

Convert self to a LeakedValue.

Load a module by calling Base.require and return this module if it has been loaded successfully. This method can be used to load parts of the standard library like LinearAlgebra. This requires one slot on the GC stack. Note that the loaded module is not made available in the module used to call this method, you can use Module::set_global to do so.

Note that when you want to call using Submodule in the Main module, you can do so by evaluating the using-statement with Value::eval_string.

Safety: This method can execute arbitrary Julia code depending on the module that is loaded.

Load a module by calling Base.require and return this module if it has been loaded successfully. This method can be used to load parts of the standard library like LinearAlgebra. Unlike Module::require, this method will panic if the module cannot be loaded. Note that the loaded module is not made available in the module used to call this method, you can use Module::set_global to do so.

Note that when you want to call using Submodule in the Main module, you can do so by evaluating the using-statement with Value::eval_string.

Safety: This method can execute arbitrary Julia code depending on the module that is loaded.

Use the Output to extend the lifetime of this data.

Trait Implementations

Returns the Plots module.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Convert the wrapper to a Ref.

Convert the wrapper to a Value.

Convert the wrapper to its display string, i.e. the string that is shown when calling Base.show. Read more

Convert the wrapper to its error string, i.e. the string that is shown when calling Base.showerror. This string can contain ANSI color codes if this is enabled by calling Julia::error_color, AsyncJulia::error_color, or AsyncJulia::try_error_color, . Read more

Convert the wrapper to its display string, i.e. the string that is shown by calling Base.display, or some default value. Read more

Convert the wrapper to its error string, i.e. the string that is shown when this value is thrown as an exception, or some default value. Read more