Struct jlrs::CCall[][src]

pub struct CCall { /* fields omitted */ }

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, and only once for each ccalled function.

If you only need to use a frame to borrow array data, you can use CCall::null_scope. Unlike Julia, CCall postpones the allocation of the stack that is used for managing the GC until a GcFrame is created. In the case of a null scope, this stack isn’t allocated at all.

Implementations

impl CCall[src]

pub unsafe fn new() -> Self[src]

Create a new CCall. 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 until a GcFrame is created.

pub unsafe fn uv_async_send(handle: *mut c_void) -> bool[src]

Wake the task associated with handle. The handle must be the handle field of a Base.AsyncCondition in Julia. This can be used to call a long-running Rust function from Julia with ccall in another thread and wait for it to complete in Julia without blocking, there’s an example available in the repository: ccall_with_threads.

pub fn scope<T, F>(&mut self, func: F) -> JlrsResult<T> where
    F: FnOnce(Global<'base>, &mut GcFrame<'base, Sync>) -> JlrsResult<T>, 
[src]

Creates a GcFrame, calls the given closure, and returns its result.

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]

Creates a GcFrame with slots slots, calls the given closure, and returns its result.

pub fn null_scope<'base, 'julia: 'base, T, F>(
    &'julia mut self,
    func: F
) -> JlrsResult<T> where
    F: FnOnce(&mut NullFrame<'base>) -> JlrsResult<T>, 
[src]

Create a NullFrame and call the given closure. A NullFrame cannot be nested and can only be used to (mutably) borrow array data. Unlike other scope-methods, no Global is provided to the closure.

Auto Trait Implementations

impl RefUnwindSafe for CCall

impl !Send for CCall

impl !Sync for CCall

impl Unpin for CCall

impl UnwindSafe for CCall

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.