[−][src]Struct jlrs::value::module::Module
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
, its contents are made available
relative to Main
.
This struct implements JuliaTypecheck
and Cast
. It can be used in combination with
DataType::is
and Value::is
; if the check returns true
the Value
can be cast to
Module
.
Implementations
impl<'base> Module<'base>
[src]
pub fn name(self) -> Symbol<'base>
[src]
Returns the name of this module.
pub fn parent(self) -> Option<Self>
[src]
Returns the parent of this module.
pub fn extend<'global>(self, _: Global<'global>) -> Module<'global>
[src]
Extend the lifetime of this module; if self
has originally been created by calling some
Julia function the lifetime will be limited to the frame the function is called with. This
can be extended to the lifetime of Global
by calling this method.
pub fn main(_: Global<'base>) -> Self
[src]
Returns a handle to Julia's Main
-module. If you include your own Julia code by calling
Julia::include
, handles to functions, globals, and submodules defined in these
included files are available through this module.
pub fn core(_: Global<'base>) -> Self
[src]
Returns a handle to Julia's Core
-module.
pub fn base(_: Global<'base>) -> Self
[src]
Returns a handle to Julia's Base
-module.
pub fn submodule<N>(self, name: N) -> JlrsResult<Self> where
N: TemporarySymbol,
[src]
N: TemporarySymbol,
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 unsafe fn set_global<'frame, N>(
self,
name: N,
value: Value<'frame, 'static>
) -> Value<'base, 'static> where
N: TemporarySymbol,
[src]
self,
name: N,
value: Value<'frame, 'static>
) -> Value<'base, 'static> where
N: TemporarySymbol,
Set a global value in this module. This is unsafe because if another global value was previously assigned to this name, this previous value can become eligible for garbage collection. Don't use the previous value after calling this method.
pub fn set_const<'frame, N>(
self,
name: N,
value: Value<'frame, 'static>
) -> JlrsResult<Value<'base, 'static>> where
N: TemporarySymbol,
[src]
self,
name: N,
value: Value<'frame, 'static>
) -> JlrsResult<Value<'base, 'static>> where
N: TemporarySymbol,
Set a constant in this module.
pub fn global<N>(self, name: N) -> JlrsResult<Value<'base, 'static>> where
N: TemporarySymbol,
[src]
N: TemporarySymbol,
Returns the global named name
in this module.
Returns an error if the global doesn't exist.
pub fn function<N>(self, name: N) -> JlrsResult<Value<'base, 'static>> where
N: TemporarySymbol,
[src]
N: TemporarySymbol,
Returns the function named name
in this module. Note that all globals defined within the
module will be successfully resolved into a function; Julia will throw an exception if you
try to call something that isn't a function. This means that this method is just an alias
for Module::global
.
Returns an error if th function doesn't exist.
pub fn as_value(self) -> Value<'base, 'static>
[src]
Convert self
to a Value
.
pub fn require<'frame, F, S>(
self,
frame: &mut F,
module: S
) -> JlrsResult<CallResult<'frame, 'static, Self>> where
F: Frame<'frame>,
S: TemporarySymbol,
[src]
self,
frame: &mut F,
module: S
) -> JlrsResult<CallResult<'frame, 'static, Self>> where
F: Frame<'frame>,
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
. 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.
pub fn require_or_panic<S>(
self,
global: Global<'base>,
module: S
) -> JlrsResult<Self> where
S: TemporarySymbol,
[src]
self,
global: Global<'base>,
module: S
) -> JlrsResult<Self> 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.
Trait Implementations
impl<'frame, 'data> Cast<'frame, 'data> for Module<'frame>
[src]
type Output = Self
pub fn cast(value: Value<'frame, 'data>) -> JlrsResult<Self::Output>
[src]
pub unsafe fn cast_unchecked(value: Value<'frame, 'data>) -> Self::Output
[src]
impl<'base> Clone for Module<'base>
[src]
impl<'base> Copy for Module<'base>
[src]
impl<'frame, 'data> Debug for Module<'frame>
[src]
impl<'base> Into<Value<'base, 'static>> for Module<'base>
[src]
impl<'frame> JuliaType for Module<'frame>
[src]
pub unsafe fn julia_type() -> *mut jl_datatype_t
[src]
impl<'frame> JuliaTypecheck for Module<'frame>
[src]
pub unsafe fn julia_typecheck(t: DataType<'_>) -> bool
[src]
impl<'frame> ValidLayout for Module<'frame>
[src]
pub unsafe fn valid_layout(v: Value<'_, '_>) -> bool
[src]
Auto Trait Implementations
impl<'base> RefUnwindSafe for Module<'base>
[src]
impl<'base> !Send for Module<'base>
[src]
impl<'base> !Sync for Module<'base>
[src]
impl<'base> Unpin for Module<'base>
[src]
impl<'base> UnwindSafe for Module<'base>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,