[][src]Struct artichoke_backend::gc::arena::ArenaIndex

pub struct ArenaIndex<'a> { /* fields omitted */ }

Interpreter guard that acts as a GC arena savepoint.

Arena savepoints ensure mruby objects are reaped even when allocated with the C API.

mruby manages objects created via the C API in a memory construct called the arena. The arena is a stack and objects stored there are permanently alive to avoid having to track lifetimes externally to the interperter.

An ArenaIndex is an index to some position of the stack. When restoring an ArenaIndex, the stack pointer is moved. All objects beyond the pointer are no longer live and are eligible to be collected at the next GC.

ArenaIndex implements Drop, so letting it go out of scope is sufficient to ensure objects get collected eventually.


impl<'a> ArenaIndex<'a>[src]

pub fn new(interp: &'a mut Artichoke) -> Result<Self, ArenaSavepointError>[src]

Create a new arena savepoint.

pub fn restore(self)[src]

Restore the arena stack pointer to its prior index.

pub fn interp(&mut self) -> &mut Artichoke[src]

Access the inner guarded interpreter.

The interpreter is also accessible via Deref, DerefMut, AsRef, and AsMut.

Methods from Deref<Target = Artichoke>

pub fn protect(&mut self, value: Value) -> Value[src]

Prevent the given value from being garbage collected.

Calls sys::mrb_gc_protect on this value which adds it to the GC arena. This object will remain in the arena until ArenaIndex::restore restores the arena to an index before this call to protect.

pub unsafe fn with_ffi_boundary<F, T>(
    &mut self,
    func: F
) -> Result<T, InterpreterExtractError> where
    F: FnOnce(*mut mrb_state) -> T, 

Execute a a closure by moving the State into the mrb instance.

This method prepares this interpreter to cross an FFI boundary. When the Artichoke implementation calls mruby FFI functions, the State must be moved into the sys::mrb_state userdata pointer.


This method moves the State out of this instance into the mrb instance. During this function's execution, this instance may be partially initialized.

This function is only safe to call if the closure only calls FFI functions that use a raw *mut sys::mrb_state.

pub fn lookup_symbol_with_trailing_nul(
    symbol: u32
) -> Result<Option<&[u8]>, Error>

pub fn intern_bytes_with_trailing_nul<T>(
    &mut self,
    bytes: T
) -> Result<u32, Error> where
    T: Into<Cow<'static, [u8]>>, 

pub fn check_interned_bytes_with_trailing_nul(
    bytes: &[u8]
) -> Result<Option<u32>, Error>

Trait Implementations

impl<'a> AsMut<Artichoke> for ArenaIndex<'a>[src]

impl<'a> AsRef<Artichoke> for ArenaIndex<'a>[src]

impl<'a> Debug for ArenaIndex<'a>[src]

impl<'a> Deref for ArenaIndex<'a>[src]

type Target = Artichoke

The resulting type after dereferencing.

impl<'a> DerefMut for ArenaIndex<'a>[src]

impl<'a> Drop for ArenaIndex<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for ArenaIndex<'a>[src]

impl<'a> !Send for ArenaIndex<'a>[src]

impl<'a> !Sync for ArenaIndex<'a>[src]

impl<'a> Unpin for ArenaIndex<'a>[src]

impl<'a> !UnwindSafe for ArenaIndex<'a>[src]

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

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

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,