[][src]Struct jlrs::Julia

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 before you can do anything related to Julia.

Methods

impl Julia[src]

pub unsafe fn init(stack_size: usize) -> JlrsResult<Self>[src]

Initializes Julia, this function can only be called once. If you call it 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.

You have to choose a stack size when calling this function. This will be the total number of slots that will be available on the GC stack. One of these slots will alwas be in use.

This function is unsafe because this crate provides you with a way to execute arbitrary Julia code which can't be checked for correctness.

pub fn set_stack_size(&mut self, stack_size: usize)[src]

Change the stack size to stack_size.

pub fn stack_size(&self) -> usize[src]

Returns the current stack size.

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:

let mut julia = unsafe { Julia::init(16).unwrap() };
julia.include("jlrs.jl").unwrap();

pub fn frame<T, F>(&mut self, capacity: usize, func: F) -> JlrsResult<T> where
    F: FnOnce(&mut StaticFrame) -> JlrsResult<T>, 
[src]

Create a StaticFrame that can hold capacity values, and call the given closure. Returns the result of this closure, or an error if the new frame can't be created because there's not enough space on the GC stack. The number of required slots on the stack is capacity + 2.

Every output and value you create inside the closure using the StaticFrame, either directly or through calling a Value, will reduce the available capacity of the StaticFrame by 1.

Example:

julia.frame(2, |frame| {
    let _i = Value::new(frame, 2u64)?;
    let _j = Value::new(frame, 1u32)?;
    Ok(())
}).unwrap();

pub fn dynamic_frame<T, F>(&mut self, func: F) -> JlrsResult<T> where
    F: FnOnce(&mut DynamicFrame) -> JlrsResult<T>, 
[src]

Create a DynamicFrame and call the given closure. Returns the result of this closure, or an error if the new frame can't be created because the stack is too small. The number of required slots on the stack is 2.

Every output and value you create inside the closure using the DynamicFrame, either directly or through calling a Value, will occupy a single slot on the GC stack.

Example:

julia.dynamic_frame(|frame| {
    let _i = Value::new(frame, 2u64)?;
    let _j = Value::new(frame, 1u32)?;
    Ok(())
}).unwrap();

Trait Implementations

impl Drop 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.