Struct jlrs::Julia [−][src]
pub struct Julia { /* fields omitted */ }
This struct can be created only once during the lifetime of your program. You must create it
with Julia::init
or Julia::init_with_image
before you can do anything related to
Julia. While this struct exists Julia is active, dropping it causes the shutdown code to be
called but this doesn’t leave Julia in a state from which it can be reinitialized.
Implementations
impl Julia
[src]
impl Julia
[src]pub unsafe fn init() -> JlrsResult<Self>
[src]
Initialize Julia, this method can only be called once. If it’s called a second time it will return an error. If this struct is dropped, you will need to restart your program to be able to call Julia code again.
This method is unsafe because this crate provides you with a way to execute arbitrary Julia code which can’t be checked for correctness.
pub unsafe fn init_with_image<P: AsRef<Path>, Q: AsRef<Path>>(
julia_bindir: P,
image_path: Q
) -> JlrsResult<Self>
[src]
julia_bindir: P,
image_path: Q
) -> JlrsResult<Self>
This method is similar to Julia::init
except that it loads a custom system image. A
custom image can be generated with the PackageCompiler
package for Julia. The main
advantage of using a custom image over the default one is that it allows you to avoid much
of the compilation overhead often associated with Julia.
Two arguments are required to call this method compared to Julia::init
;
julia_bindir
and image_relative_path
. The first must be the absolute path to a
directory that contains a compatible Julia binary (eg ${JULIA_DIR}/bin
), the second must
be either an absolute or a relative path to a system image.
This method will return an error if either of the two paths does not exist or if Julia has already been initialized. It is unsafe because this crate provides you with a way to execute arbitrary Julia code which can’t be checked for correctness.
pub fn include<P: AsRef<Path>>(&mut self, path: P) -> JlrsResult<()>
[src]
Calls include
in the Main
module in Julia, which executes the file’s contents in that
module. This has the same effect as calling include
in the Julia REPL.
Example:
julia.include("Path/To/MyJuliaCode.jl").unwrap();
pub fn scope<T, F>(&mut self, func: F) -> JlrsResult<T> where
F: FnOnce(Global<'base>, &mut GcFrame<'base, Sync>) -> JlrsResult<T>,
[src]
F: FnOnce(Global<'base>, &mut GcFrame<'base, Sync>) -> JlrsResult<T>,
This method is a main entrypoint to interact with Julia. It takes a closure with two
arguments, a Global
and a mutable reference to a GcFrame
, and can return arbitrary
results.
Example:
julia.scope(|_global, frame| { let _i = Value::new(&mut *frame, 1u64)?; Ok(()) }).unwrap();
pub fn scope_with_slots<T, F>(&mut self, slots: usize, func: F) -> JlrsResult<T> where
F: FnOnce(Global<'base>, &mut GcFrame<'base, Sync>) -> JlrsResult<T>,
[src]
F: FnOnce(Global<'base>, &mut GcFrame<'base, Sync>) -> JlrsResult<T>,
This method is a main entrypoint to interact with Julia. It takes a closure with two
arguments, a Global
and a mutable reference to a GcFrame
, and can return arbitrary
results. The frame will preallocate slots
slots.
Example:
julia.scope_with_slots(1, |_global, frame| { // Uses the preallocated slot let _i = Value::new(&mut *frame, 1u64)?; // Allocates a new slot, because only a single slot was preallocated let _j = Value::new(&mut *frame, 1u64)?; Ok(()) }).unwrap();
Trait Implementations
impl Gc for Julia
[src]
impl Gc for Julia
[src]unsafe fn enable_gc(&mut self, on: bool) -> bool
[src]
fn gc_is_enabled(&mut self) -> bool
[src]
unsafe fn gc_collect(&mut self, mode: GcCollection)
[src]
unsafe fn gc_safepoint(&mut self)
[src]
Auto Trait Implementations
impl RefUnwindSafe for Julia
impl RefUnwindSafe for Julia
impl UnwindSafe for Julia
impl UnwindSafe for Julia