Struct artichoke_backend::Artichoke[][src]

pub struct Artichoke {
    pub mrb: NonNull<mrb_state>,
    pub state: Option<Box<State>>,
}
Expand description

Interpreter instance.

Functionality is added to the interpreter via traits, for example, garbage collection or eval.

Fields

mrb: NonNull<mrb_state>

Underlying mruby interpreter.

This is an owned reference to the interpreter via a mutable pointer.

state: Option<Box<State>>

Interpreter state.

This field is an Option because the State is moved in and out of the Artichoke struct as the call graph crosses between Rust and C and C to Rust.

Implementations

Create a new interpreter from an underlying mrb and a State.

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.

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.

Safety

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.

Consume an interpreter and return the pointer to the underlying sys::mrb_state.

This function does not free any interpreter resources. Its intended use is to prepare the interpreter to cross over an FFI boundary.

This is an associated function and must be called as Artichoke::into_raw(interp).

Safety

After calling this function, the caller is responsible for properly freeing the memory occupied by the interpreter heap. The easiest way to do this is to call ffi::from_user_data with the returned pointer and then call Artichoke::close.

Consume an interpreter and free all live objects.

Trait Implementations

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Create a class definition bound to a Rust type T.

Class definitions have the same lifetime as the State because the class def owns the mrb_data_type for the type, which must be long-lived.

Retrieve a class definition from the state bound to Rust type T.

This function returns None if type T has not had a class spec registered for it using ClassRegistry::def_class.

Concrete type of boxed Ruby value as inputs to coerce functions.

Concrete float type to coerce values into, e.g. f64.

Concrete error type for errors encountered when coercing values.

Coerce the given Ruby value to a Float. Read more

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Performs the infallible conversion.

Formats the value using the given formatter. Read more

Concrete type for return values from eval.

Return a name for the given value’s type that is suitable for using in an Exception message. Read more

Return the class name for the given value’s type. Read more

Concrete type for Ruby values.

Concrete error type for fallible operations.

Define a global constant. Read more

Define a class constant. Read more

Define a module constant. Read more

Concrete type for return values from eval.

Concrete error type for eval functions.

Eval code on the Artichoke interpreter using the current Context. Read more

Eval code on the Artichoke interpreter using the current Context when given code as an OsStr. Read more

Eval code on the Artichoke interpreter using a new file Context given a file path. Read more

Unset global variable pointed to by name.

Unsetting a global variable removes the name from the global storage table. Unset globals resolve to nil in the Ruby VM.

Unsetting a global that is currently unset is a no-op.

Errors

If the name is not a valid global name, an error is returned.

Concrete value type for global variables.

Concrete error type for failures manipulating global variables.

Set global variable pointed to by name to the given Ruby value. Read more

Get the Ruby value stored in the global variable pointed to by name. Read more

Concrete type for symbol identifiers. Read more

Concrete type for errors returned while interning symbols.

The initial Symbol index returned by the interner. Read more

Store an immutable bytestring for the life of the interpreter. Read more

Check if a bytestring is already interned and return its symbol identifier. Return None if the string has not been interned before. Read more

Retrieve the original byte content of an interned bytestring. Read more

Retrieve the number of unique strings interned. Read more

Store an immutable string for the life of the interpreter. Read more

Check if a string is already interned and return its symbol identifier. Return None if the string has not been interned before. Read more

Writes the given bytes to the interpreter stdout stream.

This implementation delegates to the underlying output strategy.

Errors

If the output stream encounters an error, an error is returned.

Writes the given bytes to the interpreter stdout stream followed by a newline.

This implementation delegates to the underlying output strategy.

Errors

If the output stream encounters an error, an error is returned.

Concrete error type for errors encountered when reading and writing.

Concrete type for interpreter.

Concrete type for errors returned from filesystem IO.

Concrete type for errors returned by File::require.

Add a Rust extension hook to the virtual filesystem. A stub Ruby file is added to the filesystem and File::require will dynamically define Ruby items when invoked via Kernel#require. Read more

Add a Ruby source to the virtual filesystem. Read more

Test for a source file at a path and return the absolute path of the resolved file. Read more

Test for a source file at a path. Read more

Load source located at the given path. Read more

Require source located at the given path. Read more

Retrieve file contents for a source file. Read more

Create a module definition bound to a Rust type T.

Module definitions have the same lifetime as the interpreter because the module def owns the mrb_data_type for the type, which must be long-lived.

Retrieve a module definition from the interpreter bound to Rust type T.

This function returns None if type T has not had a module spec registered for it using ModuleRegistry::def_module.

Create a savepoint in the GC arena. Read more

Retrieve the number of live objects on the interpreter heap. Read more

Mark a Value as reachable in the mruby garbage collector.

Perform an incremental garbage collection. Read more

Perform a full garbage collection. Read more

Enable garbage collection. Read more

Disable garbage collection. Read more

Concrete type for parser context.

Error type for Parser APIs.

Reset parser state to initial values. Read more

Fetch the current line number from the parser state. Read more

Increment line number and return the new value. Read more

Set the currently active context by modifying the parser stack. Read more

Remove the current active context and return it. Read more

Return a reference to the currently active context. Read more

Concrete type for PRNG errors.

Conrete type for the interpreter psuedorandom number generator.

Return a shared reference to the interpreter psuedorandom number generator. Read more

Return a mutable reference to the interpreter psuedorandom number generator. Read more

Concrete error type for errors encountered when manipulating Regexp state. Read more

Retrieve the current number of set Regexp global variables. Read more

Set the current number of set Regexp global variables. Read more

Clear all Regexp state. Read more

Concrete Value type.

Return a Value-wrapped reference to “top self”. Read more

Provide a fallible converter for types that implement an infallible conversion.

Blanket implementation that always succeeds by delegating to Convert::convert.

Error type for failed conversions.

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Provide a mutable fallible converter for types that implement an infallible conversion.

Blanket implementation that always succeeds by delegating to Convert::convert.

Error type for failed conversions.

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Error type for failed conversions.

Performs the fallible conversion. Read more

Concrete error type for errors encountered when outputting warnings.

Emit a warning message using Warning#warn. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Returns an iterator that returns all symbol identifiers stored in an interner as Symbols. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.