Struct jlrs::Julia[][src]

pub struct Julia { /* fields omitted */ }
Expand description

A Julia instance. 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

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 it can race with another crate initializing Julia.

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 doesn’t exist or if Julia has already been initialized. It is unsafe because it can race with another crate initializing Julia.

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();

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();

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

Executes the destructor for this type. Read more

Enable or disable the GC.

Returns true if the GC is enabled.

Force a collection.

Insert a safepoint, a point where the garbage collector may run.

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

Performs the conversion.

Performs the conversion.

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.