Value

Struct Value 

Source
#[repr(transparent)]
pub struct Value(pub VALUE);
Expand description

Wraps a plain old Ruby FFI VALUE with much more functionality.

Tuple Fields§

§0: VALUE

Implementations§

Source§

impl Value

Source

pub const NIL: Self

The Ruby nil value.

Source

pub const TRUE: Self

The Ruby true value.

Source

pub const FALSE: Self

The Ruby false value.

Source

pub fn send( &self, method_name: &str, arguments: &[Value], ) -> Result<Value, CaughtException>

Sends a Ruby method and returns the result.

Source

pub unsafe fn send_unprotected( &self, method_name: &str, arguments: &[Value], ) -> Value

Sends a Ruby method without rescuing Ruby unwind.

Source

pub fn constant(&self, constant_name: &str) -> Result<Value, CaughtException>

Gets a constant by name. Equivalent to Object#const_get(constant_name).

Source

pub unsafe fn constant_unprotected(&self, constant_name: &str) -> Value

Gets a constant by name. Equivalent to Object#const_get(constant_name).

Source

pub fn set_constant( &self, constant_name: &str, value: Value, ) -> Result<(), CaughtException>

Sets a constant. Equivalent to Object#const_set(constant_name, value).

Source

pub unsafe fn set_constant_unprotected(&self, constant_name: &str, value: Value)

Sets a constant. Equivalent to Object#const_set(constant_name, value).

Source

pub fn to_s(&self) -> Result<String, CaughtException>

Convert a Ruby value to a Rust string.

Calls Object#to_s and then converts the result to a string.

Source

pub unsafe fn to_s_unprotected(&self) -> String

Convert a Ruby value to a Rust string.

Source

pub fn object_class_name(&self) -> String

Convert a Ruby string to a Rust string. Gets the class name for an object

Source

pub fn inspect(&self) -> Result<Value, CaughtException>

Calls Object#inspect

Source

pub unsafe fn inspect_unprotected(&self) -> Value

Calls Object#inspect

Source

pub fn is_of_value_type(&self, value_type: value_type) -> bool

Checks if this object is of the given value type.

Source

pub fn is_nil(&self) -> bool

Checks if this value is nil.

Source

pub fn convert_array(values: &[Value]) -> &[VALUE]

Trait Implementations§

Source§

impl AsRef<VALUE> for Value

Source§

fn as_ref(&self) -> &VALUE

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for Value

Source§

type Target = VALUE

The resulting type after dereferencing.
Source§

fn deref(&self) -> &VALUE

Dereferences the value.
Source§

impl DerefMut for Value

Source§

fn deref_mut(&mut self) -> &mut VALUE

Mutably dereferences the value.
Source§

impl Display for Value

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<VALUE> for Value

Source§

fn from(v: VALUE) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(b: bool) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Value

Source§

type Err = CaughtException

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, CaughtException>

Parses a string s to return a value of this type. Read more
Source§

impl Into<VALUE> for Value

Source§

fn into(self) -> VALUE

Converts this type into the (usually inferred) input type.
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Value

Source§

impl Eq for Value

Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.