Struct jlrs::CCall [−][src]
When you call Rust from Julia through ccall
, Julia has already been initialized and trying to
initialize it again would cause a crash. In order to still be able to call Julia from Rust
and to borrow arrays (if you pass them as Array
rather than Ptr{Array}
), you'll need to
create a frame first. You can use this struct to do so. It must never be used outside
functions called through ccall
.
If you only need to use a frame to borrow array data, you can use CCall::null
and
CCall::null_frame
. Unlike Julia
, CCall
postpones the allocation of the stack that is
used for managing the GC until a static or dynamic frame is created. In the case of a null
frame, this stack isn't allocated at all. Unlike the other frame types null frames can't be
nested.
Implementations
impl CCall
[src]
pub unsafe fn new(stack_size: usize) -> Self
[src]
Create a new CCall
that provides a stack with stack_size
slots. This functions the
same way as Julia::init
does. This function must never be called outside a function
called through ccall
from Julia and must only be called once during that call. The stack
is not allocated untl a static or dynamic frame is created.
pub unsafe fn null() -> Self
[src]
Create a new CCall
that provides a stack with no slots. This means only creating a null
frame is supported. This function must never be called outside a function
called through ccall
from Julia and must only be called once during that call. The stack
is not allocated untl a static or dynamic frame is created.
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 frame<'base, 'julia: 'base, T, F>(
&'julia mut self,
capacity: usize,
func: F
) -> JlrsResult<T> where
F: FnOnce(Global<'base>, &mut StaticFrame<'base, Sync>) -> JlrsResult<T>,
[src]
&'julia mut self,
capacity: usize,
func: F
) -> JlrsResult<T> where
F: FnOnce(Global<'base>, &mut StaticFrame<'base, Sync>) -> JlrsResult<T>,
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.
pub fn dynamic_frame<'base, 'julia: 'base, T, F>(
&'julia mut self,
func: F
) -> JlrsResult<T> where
F: FnOnce(Global<'base>, &mut DynamicFrame<'base, Sync>) -> JlrsResult<T>,
[src]
&'julia mut self,
func: F
) -> JlrsResult<T> where
F: FnOnce(Global<'base>, &mut DynamicFrame<'base, Sync>) -> JlrsResult<T>,
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.
pub fn null_frame<'base, 'julia: 'base, T, F>(
&'julia mut self,
func: F
) -> JlrsResult<T> where
F: FnOnce(&mut NullFrame<'base>) -> JlrsResult<T>,
[src]
&'julia mut self,
func: F
) -> JlrsResult<T> where
F: FnOnce(&mut NullFrame<'base>) -> JlrsResult<T>,
Auto Trait Implementations
impl RefUnwindSafe for CCall
[src]
impl !Send for CCall
[src]
impl !Sync for CCall
[src]
impl Unpin for CCall
[src]
impl UnwindSafe for CCall
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,