artichoke_backend::core

Trait Value

Source
pub trait Value {
    type Artichoke;
    type Arg;
    type Value: Value;
    type Block;
    type Error;

    // Required methods
    fn funcall(
        &self,
        interp: &mut Self::Artichoke,
        func: &str,
        args: &[Self::Arg],
        block: Option<Self::Block>,
    ) -> Result<Self::Value, Self::Error>;
    fn freeze(
        &mut self,
        interp: &mut Self::Artichoke,
    ) -> Result<(), Self::Error>;
    fn is_frozen(&self, interp: &mut Self::Artichoke) -> bool;
    fn is_nil(&self) -> bool;
    fn respond_to(
        &self,
        interp: &mut Self::Artichoke,
        method: &str,
    ) -> Result<bool, Self::Error>;
    fn inspect(&self, interp: &mut Self::Artichoke) -> Vec<u8> ;
    fn to_s(&self, interp: &mut Self::Artichoke) -> Vec<u8> ;
    fn ruby_type(&self) -> Ruby;

    // Provided methods
    fn try_convert_into<T>(
        self,
        interp: &Self::Artichoke,
    ) -> Result<T, Self::Error>
       where Self: Sized,
             Self::Artichoke: TryConvert<Self, T, Error = Self::Error> { ... }
    fn try_convert_into_mut<T>(
        self,
        interp: &mut Self::Artichoke,
    ) -> Result<T, Self::Error>
       where Self: Sized,
             Self::Artichoke: TryConvertMut<Self, T, Error = Self::Error> { ... }
}
Expand description

A boxed Ruby value owned by the interpreter.

Value is equivalent to an RValue in MRI or mrb_value in mruby.

Required Associated Types§

Source

type Artichoke

Concrete type for Artichoke interpreter.

Source

type Arg

Concrete type for arguments passed to funcall.

Source

type Value: Value

Concrete type for results from funcall.

Source

type Block

Concrete type for blocks passed to funcall.

Source

type Error

Concrete error type for funcall errors.

Required Methods§

Source

fn funcall( &self, interp: &mut Self::Artichoke, func: &str, args: &[Self::Arg], block: Option<Self::Block>, ) -> Result<Self::Value, Self::Error>

Call a method on this Value with arguments and an optional block.

§Errors

If an exception is raised on the interpreter, then an error is returned.

If a TryConvert conversion fails, then an error is returned.

Source

fn freeze(&mut self, interp: &mut Self::Artichoke) -> Result<(), Self::Error>

Call #freeze on this Value.

§Errors

If an exception is raised on the interpreter, then an error is returned.

Source

fn is_frozen(&self, interp: &mut Self::Artichoke) -> bool

Call #frozen? on this Value.

Source

fn is_nil(&self) -> bool

Whether self is nil

Source

fn respond_to( &self, interp: &mut Self::Artichoke, method: &str, ) -> Result<bool, Self::Error>

Whether self responds to a method.

Equivalent to invoking #respond_to? on this Value.

§Errors

If an exception is raised on the interpreter, then an error is returned.

Source

fn inspect(&self, interp: &mut Self::Artichoke) -> Vec<u8>

Call #inspect on this Value.

This function can never fail.

Source

fn to_s(&self, interp: &mut Self::Artichoke) -> Vec<u8>

Call #to_s on this Value.

This function can never fail.

Source

fn ruby_type(&self) -> Ruby

Return this values Rust-mapped type tag.

Provided Methods§

Source

fn try_convert_into<T>(self, interp: &Self::Artichoke) -> Result<T, Self::Error>
where Self: Sized, Self::Artichoke: TryConvert<Self, T, Error = Self::Error>,

Consume self and try to convert self to type T using a TryConvert conversion.

§Errors

If a TryConvert conversion fails, then an error is returned.

Source

fn try_convert_into_mut<T>( self, interp: &mut Self::Artichoke, ) -> Result<T, Self::Error>
where Self: Sized, Self::Artichoke: TryConvertMut<Self, T, Error = Self::Error>,

Consume self and try to convert self to type T using a TryConvertMut conversion.

§Errors

If a TryConvertMut conversion fails, then an error is returned.

Implementors§