pub struct Julia { /* private fields */ }
Expand description
A Julia instance.
You must create this instance with RuntimeBuilder::start
before you can start using
Julia from Rust. 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
sourceimpl Julia
impl Julia
sourcepub fn error_color(&mut self, enable: bool) -> JlrsResult<()>
pub fn error_color(&mut self, enable: bool) -> JlrsResult<()>
Enable or disable colored error messages originating from Julia. If this is enabled the
error message in JlrsError::Exception
can contain ANSI color codes. This feature is
disabled by default.
sourcepub unsafe fn include<P: AsRef<Path>>(&mut self, path: P) -> JlrsResult<()>
pub unsafe fn include<P: AsRef<Path>>(&mut self, path: P) -> JlrsResult<()>
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.
This is unsafe because the contents of the file are evaluated.
Example:
unsafe { julia.include("Path/To/MyJuliaCode.jl").unwrap(); }
sourcepub fn scope<T, F>(&mut self, func: F) -> JlrsResult<T> where
for<'base> F: FnOnce(Global<'base>, GcFrame<'base, Sync>) -> JlrsResult<T>,
pub fn scope<T, F>(&mut self, func: F) -> JlrsResult<T> where
for<'base> F: FnOnce(Global<'base>, 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 GcFrame
, and can return arbitrary results.
Example:
julia.scope(|_global, mut frame| {
let _i = Value::new(&mut frame, 1u64)?;
Ok(())
}).unwrap();
sourcepub fn scope_with_capacity<T, F>(
&mut self,
capacity: usize,
func: F
) -> JlrsResult<T> where
for<'base> F: FnOnce(Global<'base>, GcFrame<'base, Sync>) -> JlrsResult<T>,
pub fn scope_with_capacity<T, F>(
&mut self,
capacity: usize,
func: F
) -> JlrsResult<T> where
for<'base> F: FnOnce(Global<'base>, 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 GcFrame
, and can return arbitrary results. The frame will
have capacity for at least capacity
roots.
Example:
julia.scope_with_capacity(1, |_global, mut frame| {
let _i = Value::new(&mut frame, 1u64)?;
Ok(())
}).unwrap();
Trait Implementations
sourceimpl Gc for Julia
impl Gc for Julia
sourcefn enable_gc_logging(&mut self, on: bool)
fn enable_gc_logging(&mut self, on: bool)
Enable or disable GC logging. Read more
sourcefn gc_is_enabled(&mut self) -> bool
fn gc_is_enabled(&mut self) -> bool
Returns true
if the GC is enabled.
sourcefn gc_collect(&mut self, mode: GcCollection)
fn gc_collect(&mut self, mode: GcCollection)
Force a collection.
sourcefn gc_safepoint(&mut self)
fn gc_safepoint(&mut self)
Insert a safepoint, a point where the garbage collector may run.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more