Struct jlrs::wrappers::ptr::module::Module [−][src]
#[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 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 true
if self
has imported sym
.
pub fn submodule<'target, N, F>(
self,
frame: &mut F,
name: N
) -> JlrsResult<Module<'target>> where
N: TemporarySymbol,
F: Frame<'target>,
pub fn submodule<'target, N, F>(
self,
frame: &mut F,
name: N
) -> JlrsResult<Module<'target>> where
N: TemporarySymbol,
F: Frame<'target>,
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.
pub fn submodule_ref<N>(self, name: N) -> JlrsResult<ModuleRef<'scope>> where
N: TemporarySymbol,
pub fn submodule_ref<N>(self, name: N) -> JlrsResult<ModuleRef<'scope>> where
N: TemporarySymbol,
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.
pub fn set_global<'frame, N, F>(
self,
frame: &mut F,
name: N,
value: Value<'_, 'static>
) -> JlrsResult<JuliaResult<'frame, 'static, ValueRef<'scope, 'static>>> where
N: TemporarySymbol,
F: Frame<'frame>,
pub fn set_global<'frame, N, F>(
self,
frame: &mut F,
name: N,
value: Value<'_, 'static>
) -> JlrsResult<JuliaResult<'frame, 'static, ValueRef<'scope, 'static>>> where
N: TemporarySymbol,
F: Frame<'frame>,
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.
pub fn set_global_unrooted<N>(
self,
name: N,
value: Value<'_, 'static>
) -> JuliaResultRef<'scope, 'static> where
N: TemporarySymbol,
pub fn set_global_unrooted<N>(
self,
name: N,
value: Value<'_, 'static>
) -> JuliaResultRef<'scope, 'static> where
N: TemporarySymbol,
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.
pub fn set_global_unchecked<N>(
self,
name: N,
value: Value<'_, 'static>
) -> ValueRef<'scope, 'static> where
N: TemporarySymbol,
pub fn set_global_unchecked<N>(
self,
name: N,
value: Value<'_, 'static>
) -> ValueRef<'scope, 'static> where
N: TemporarySymbol,
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 the process aborts.
pub fn set_const<'frame, N, F>(
self,
frame: &mut F,
name: N,
value: Value<'_, 'static>
) -> JlrsResult<JuliaResult<'frame, 'static, ValueRef<'scope, 'static>>> where
N: TemporarySymbol,
F: Frame<'frame>,
pub fn set_const<'frame, N, F>(
self,
frame: &mut F,
name: N,
value: Value<'_, 'static>
) -> JlrsResult<JuliaResult<'frame, 'static, ValueRef<'scope, 'static>>> where
N: TemporarySymbol,
F: Frame<'frame>,
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.
pub fn set_const_unrooted<N>(
self,
name: N,
value: Value<'_, 'static>
) -> JuliaResultRef<'scope, 'static> where
N: TemporarySymbol,
pub fn set_const_unrooted<N>(
self,
name: N,
value: Value<'_, 'static>
) -> JuliaResultRef<'scope, 'static> where
N: TemporarySymbol,
Set a constant in this module. If Julia throws an exception it’s caught. Otherwise an unrooted reference to the constant is returned.
pub fn set_const_unchecked<N>(
self,
name: N,
value: Value<'_, 'static>
) -> ValueRef<'scope, 'static> where
N: TemporarySymbol,
pub fn set_const_unchecked<N>(
self,
name: N,
value: Value<'_, 'static>
) -> ValueRef<'scope, 'static> where
N: TemporarySymbol,
Set a constant in this module. If the constant already exists the process aborts, otherwise an unrooted reference to the constant is returned.
pub fn global<'target, N, F>(
self,
frame: &mut F,
name: N
) -> JlrsResult<Value<'target, 'static>> where
N: TemporarySymbol,
F: Frame<'target>,
pub fn global<'target, N, F>(
self,
frame: &mut F,
name: N
) -> JlrsResult<Value<'target, 'static>> where
N: TemporarySymbol,
F: Frame<'target>,
Returns the global named name
in this module.
Returns an error if the global doesn’t exist.
pub fn global_ref<N>(self, name: N) -> JlrsResult<ValueRef<'scope, 'static>> where
N: TemporarySymbol,
pub fn global_ref<N>(self, name: N) -> JlrsResult<ValueRef<'scope, 'static>> where
N: TemporarySymbol,
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.
pub fn function<'target, N, F>(
self,
frame: &mut F,
name: N
) -> JlrsResult<Function<'target, 'static>> where
N: TemporarySymbol,
F: Frame<'target>,
pub fn function<'target, N, F>(
self,
frame: &mut F,
name: N
) -> JlrsResult<Function<'target, 'static>> where
N: TemporarySymbol,
F: Frame<'target>,
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
.
pub fn function_ref<N>(
self,
name: N
) -> JlrsResult<FunctionRef<'scope, 'static>> where
N: TemporarySymbol,
pub fn function_ref<N>(
self,
name: N
) -> JlrsResult<FunctionRef<'scope, 'static>> where
N: TemporarySymbol,
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
.
pub fn require<'target, 'current, S, F, N>(
self,
scope: S,
module: N
) -> JlrsResult<S::JuliaResult> where
S: Scope<'target, 'current, 'static, F>,
F: Frame<'current>,
N: TemporarySymbol,
pub fn require<'target, 'current, S, F, N>(
self,
scope: S,
module: N
) -> JlrsResult<S::JuliaResult> where
S: Scope<'target, 'current, 'static, F>,
F: Frame<'current>,
N: TemporarySymbol,
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
.
pub fn require_ref<S>(
self,
global: Global<'scope>,
module: S
) -> ModuleRef<'scope> where
S: TemporarySymbol,
pub fn require_ref<S>(
self,
global: Global<'scope>,
module: S
) -> ModuleRef<'scope> where
S: TemporarySymbol,
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
.
Trait Implementations
Check if the layout of the implementor is compatible with the layout of ty
. This
argument is a Value
to account for the fact that a field type can be a Union
,
UnionAll
or Union{}
. Read more
Auto Trait Implementations
impl<'scope> RefUnwindSafe for Module<'scope>
impl<'scope> UnwindSafe for Module<'scope>
Blanket Implementations
Mutably borrows from an owned value. Read more
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