[][src]Struct artichoke::Artichoke

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

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

impl Artichoke[src]

#[must_use]pub fn new(mrb: NonNull<mrb_state>, state: Box<State>) -> Artichoke[src]

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

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

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.

#[must_use]pub unsafe fn into_raw(interp: Artichoke) -> *mut mrb_state[src]

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.

pub fn close(self)[src]

Consume an interpreter and free all live objects.

impl Artichoke[src]

pub fn all_symbols(&self) -> Result<AllSymbols, InterpreterExtractError>[src]

Return a type that yields all Symbols in the interpreter.

pub fn lookup_symbol_with_trailing_nul(
    &self,
    symbol: Symbol
) -> Result<Option<&[u8]>, Exception>
[src]

Trait Implementations

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

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

impl ClassRegistry for Artichoke[src]

fn def_class<T>(&mut self, spec: Spec) -> Result<(), Exception> where
    T: Any
[src]

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.

fn class_spec<T>(&self) -> Result<Option<&Spec>, Exception> where
    T: Any
[src]

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].

impl Convert<Integer, Value> for Artichoke[src]

impl Convert<Option<Value>, Value> for Artichoke[src]

impl Convert<Option<i64>, Value> for Artichoke[src]

impl Convert<Value, Option<Value>> for Artichoke[src]

impl Convert<Value, Value> for Artichoke[src]

impl Convert<bool, Value> for Artichoke[src]

impl Convert<i16, Value> for Artichoke[src]

impl Convert<i32, Value> for Artichoke[src]

impl Convert<i64, Value> for Artichoke[src]

Converter for Artichoke native integer type.

The Int type alias must be i64.

assert_eq!(mem::size_of::<i64>(), mem::size_of::<Int>());
assert_eq!(i64::min_value(), Int::min_value());
assert_eq!(i64::max_value(), Int::max_value());
assert_eq!(TypeId::of::<i64>(), TypeId::of::<Int>());

impl Convert<i8, Value> for Artichoke[src]

impl Convert<u16, Value> for Artichoke[src]

impl Convert<u32, Value> for Artichoke[src]

impl Convert<u8, Value> for Artichoke[src]

impl<'_> ConvertMut<&'_ [u8], Value> for Artichoke[src]

impl<'_> ConvertMut<&'_ str, Value> for Artichoke[src]

impl<'a> ConvertMut<Cow<'a, [u8]>, Value> for Artichoke[src]

impl<'a> ConvertMut<Cow<'a, str>, Value> for Artichoke[src]

impl ConvertMut<Float, Value> for Artichoke[src]

impl ConvertMut<HashMap<Vec<u8>, Vec<u8>, RandomState>, Value> for Artichoke[src]

impl<'_> ConvertMut<Option<&'_ [u8]>, Value> for Artichoke[src]

impl<'_> ConvertMut<Option<&'_ str>, Value> for Artichoke[src]

impl ConvertMut<Option<HashMap<Vec<u8>, Option<Vec<u8>>, RandomState>>, Value> for Artichoke[src]

impl ConvertMut<Option<String>, Value> for Artichoke[src]

impl ConvertMut<Option<Vec<u8>>, Value> for Artichoke[src]

impl ConvertMut<Outcome, Value> for Artichoke[src]

impl ConvertMut<RandomNumber, Value> for Artichoke[src]

impl ConvertMut<RandomNumber, Value> for Artichoke[src]

impl ConvertMut<String, Value> for Artichoke[src]

impl ConvertMut<Value, Options> for Artichoke[src]

impl ConvertMut<Value, Value> for Artichoke[src]

impl ConvertMut<Vec<(Value, Value)>, Value> for Artichoke[src]

impl ConvertMut<Vec<u8>, Value> for Artichoke[src]

impl ConvertMut<f64, Value> for Artichoke[src]

impl Debug for Artichoke[src]

impl DefineConstant for Artichoke[src]

type Value = Value

Concrete type for Ruby values.

type Error = Exception

Concrete error type for fallible operations.

impl Eval for Artichoke[src]

type Value = Value

Concrete type for return values from eval.

type Error = Exception

Concrete error type for eval functions.

impl Globals for Artichoke[src]

type Value = Value

Concrete value type for global variables.

type Error = Exception

Concrete error type for failures manipulating global variables.

fn unset_global_variable<T>(
    &mut self,
    name: T
) -> Result<(), <Artichoke as Globals>::Error> where
    T: Into<Cow<'static, [u8]>>, 
[src]

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.

impl Intern for Artichoke[src]

type Symbol = Symbol

Concrete type for symbol identifiers. Read more

type Error = Exception

Concrete type for errors returned while interning symbols.

impl Io for Artichoke[src]

type Error = Exception

Concrete error type for errors encountered when reading and writing.

fn print<T>(&mut self, message: T) -> Result<(), <Artichoke as Io>::Error> where
    T: AsRef<[u8]>, 
[src]

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.

fn puts<T>(&mut self, message: T) -> Result<(), <Artichoke as Io>::Error> where
    T: AsRef<[u8]>, 
[src]

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.

impl LoadSources for Artichoke[src]

type Artichoke = Artichoke

Concrete type for interpreter.

type Error = Exception

Concrete type for errors returned from filesystem IO.

type Exception = Exception

Concrete type for errors returned by File::require.

impl ModuleRegistry for Artichoke[src]

fn def_module<T>(&mut self, spec: Spec) -> Result<(), Exception> where
    T: Any
[src]

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.

fn module_spec<T>(&self) -> Result<Option<&Spec>, Exception> where
    T: Any
[src]

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].

impl MrbGarbageCollection for Artichoke[src]

impl Parser for Artichoke[src]

type Context = Context

Concrete type for parser context.

type Error = Exception

Error type for Parser APIs.

impl Prng for Artichoke[src]

type Error = Exception

Concrete type for PRNG errors.

type InternalState = InternalState

Cocnrete type representing the internal state of all PRNG backends.

type Int = i64

Conrete type for integer input and output.

type Float = f64

Concrete type for floating point input and output.

impl Regexp for Artichoke[src]

type Error = InterpreterExtractError

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

impl TopSelf for Artichoke[src]

type Value = Value

Concrete [Value] type.

impl<T, U> TryConvert<T, U> for Artichoke where
    Artichoke: Convert<T, U>, 
[src]

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

type Error = Exception

Error type for failed conversions.

fn try_convert(
    &self,
    value: T
) -> Result<U, <Artichoke as TryConvert<T, U>>::Error>
[src]

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

impl TryConvert<Value, Float> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvert<Value, Integer> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvert<Value, Option<bool>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvert<Value, Option<i64>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvert<Value, bool> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvert<Value, f64> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvert<Value, i64> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvert<Value, u32> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvert<Value, usize> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvert<isize, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvert<u64, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvert<usize, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_, '_> TryConvertMut<&'_ [&'_ [u8]], Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_, '_> TryConvertMut<&'_ [&'_ str], Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_, '_> TryConvertMut<&'_ [Option<&'_ [u8]>], Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_, '_> TryConvertMut<&'_ [Option<&'_ str>], Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_> TryConvertMut<&'_ [Option<Value>], Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_> TryConvertMut<&'_ [Option<Vec<u8>>], Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_> TryConvertMut<&'_ [String], Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_> TryConvertMut<&'_ [Value], Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_> TryConvertMut<&'_ [Vec<u8>], Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_> TryConvertMut<&'_ [i64], Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_> TryConvertMut<&'_ OsStr, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'a> TryConvertMut<&'a mut Value, CaptureExtract<'a>> for Artichoke[src]

type Error = TypeError

Error type for failed conversions.

impl<'a> TryConvertMut<&'a mut Value, IntegerString<'a>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<(Option<Value>, Option<Value>), (Option<Options>, Option<Encoding>)> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<CaptureMatch, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'a> TryConvertMut<Cow<'a, OsStr>, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Option<Value>, Option<Radix>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Option<Value>, RandomNumberMax> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Option<Value>, RandomNumberMax> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Option<Value>, Seed> for Artichoke[src]

type Error = TypeError

Error type for failed conversions.

impl TryConvertMut<OsString, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Scan, Option<Value>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<T, U> TryConvertMut<T, U> for Artichoke where
    Artichoke: ConvertMut<T, U>, 
[src]

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

type Error = Exception

Error type for failed conversions.

fn try_convert_mut(
    &mut self,
    value: T
) -> Result<U, <Artichoke as TryConvertMut<T, U>>::Error>
[src]

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

impl<'a> TryConvertMut<Value, &'a [u8]> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'a> TryConvertMut<Value, &'a str> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Value, Encoding> for Artichoke[src]

type Error = InvalidEncodingError

Error type for failed conversions.

impl<'a> TryConvertMut<Value, Option<&'a [u8]>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'a> TryConvertMut<Value, Option<&'a str>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Value, Option<String>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Value, Option<Vec<u8>>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Value, RandomNumberMax> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Value, RandomNumberMax> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Value, Seed> for Artichoke[src]

type Error = TypeError

Error type for failed conversions.

impl TryConvertMut<Value, String> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'a> TryConvertMut<Value, Vec<&'a [u8]>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'a> TryConvertMut<Value, Vec<&'a str>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Value, Vec<(Value, Value)>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'a> TryConvertMut<Value, Vec<Option<&'a [u8]>>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'a> TryConvertMut<Value, Vec<Option<&'a str>>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Value, Vec<Option<String>>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Value, Vec<Option<Vec<u8>>>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Value, Vec<String>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Value, Vec<Value>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Value, Vec<Vec<u8>>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Value, Vec<i64>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Value, Vec<u8>> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_> TryConvertMut<Vec<&'_ [u8]>, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_> TryConvertMut<Vec<&'_ str>, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Vec<(Vec<u8>, Vec<i64>)>, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_> TryConvertMut<Vec<Option<&'_ [u8]>>, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_> TryConvertMut<Vec<Option<&'_ str>>, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Vec<Option<Vec<u8>>>, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Vec<String>, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Vec<Value>, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_> TryConvertMut<Vec<Vec<Option<&'_ [u8]>>>, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl<'_> TryConvertMut<Vec<Vec<Option<&'_ str>>>, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Vec<Vec<Option<Vec<u8>>>>, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Vec<Vec<u8>>, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl TryConvertMut<Vec<i64>, Value> for Artichoke[src]

type Error = Exception

Error type for failed conversions.

impl Warn for Artichoke[src]

type Error = Exception

Concrete error type for errors encountered when outputting warnings.

Auto Trait Implementations

impl !RefUnwindSafe for Artichoke

impl !Send for Artichoke

impl !Sync for Artichoke

impl Unpin for Artichoke

impl !UnwindSafe for Artichoke

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]