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]

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]

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]

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]

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 Drop for Julia[src]

impl Gc for Julia[src]

Auto Trait Implementations

impl RefUnwindSafe for Julia

impl !Send for Julia

impl !Sync for Julia

impl Unpin for Julia

impl UnwindSafe for Julia

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.