RosyObject

Struct RosyObject 

Source
pub struct RosyObject<R> { /* private fields */ }
Expand description

An instance of a Ruby object that wraps around Rust data.

See the documentation for Rosy for more information.

Implementations§

Source§

impl<R: Rosy> RosyObject<R>

Source

pub fn as_data(&self) -> &R

Returns a reference to the inner Rosy value.

Trait Implementations§

Source§

impl<R: Rosy> AsRef<AnyObject> for RosyObject<R>

Source§

fn as_ref(&self) -> &AnyObject

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

impl<R> Clone for RosyObject<R>

Source§

fn clone(&self) -> Self

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<R: Rosy> Debug for RosyObject<R>

Source§

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

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

impl<R: Rosy> Display for RosyObject<R>

Source§

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

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

impl<R: Rosy> From<Box<R>> for RosyObject<R>

Source§

fn from(rosy: Box<R>) -> Self

Converts to this type from the input type.
Source§

impl<R: Rosy> From<R> for RosyObject<R>

Source§

fn from(rosy: R) -> Self

Converts to this type from the input type.
Source§

impl<R: Rosy> From<RosyObject<R>> for AnyObject

Source§

fn from(obj: RosyObject<R>) -> Self

Converts to this type from the input type.
Source§

impl<R: Rosy> Object for RosyObject<R>

Source§

fn unique_id() -> Option<u128>

Returns a unique identifier for an object type to facilitate casting. Read more
Source§

fn cast<A: Object>(obj: A) -> Option<Self>

Attempts to create an instance by casting obj. Read more
Source§

fn class(self) -> Class<Self>

Returns the Class for self. Read more
Source§

unsafe fn from_raw(raw: usize) -> Self

Creates a new object from raw without checking. Read more
Source§

unsafe fn cast_unchecked(obj: impl Object) -> Self

Casts obj to Self without checking its type.
Source§

fn into_any_object(self) -> AnyObject

Returns self as an AnyObject.
Source§

fn as_any_object(&self) -> &AnyObject

Returns a reference to self as an AnyObject.
Source§

fn as_any_slice(&self) -> &[AnyObject]

Returns self as a reference to a single-element slice.
Source§

fn raw(self) -> usize

Returns the raw object pointer.
Source§

unsafe fn as_unchecked<O: Object>(&self) -> &O

Casts self to O without checking whether it is one.
Source§

unsafe fn into_unchecked<O: Object>(self) -> O

Converts self to O without checking whether it is one.
Source§

fn id(self) -> u64

Returns the object’s identifier.
Source§

fn ty(self) -> Ty

Returns the virtual type of self.
Source§

fn is_ty(self, ty: Ty) -> bool

Returns whether the virtual type of self is ty.
Source§

fn singleton_class(self) -> Class<Self>

Returns the singleton Class of self, creating one if it doesn’t exist already. Read more
Source§

fn mark(self)

Marks self for Ruby to avoid garbage collecting it.
Source§

unsafe fn force_recycle(self)

Forces the garbage collector to free the contents of self. Read more
Source§

fn def_singleton_method<N, F>(self, name: N, f: F) -> Result
where N: Into<SymbolId>, F: MethodFn<Self>,

Defines a method for name on the singleton class of self that calls f when invoked.
Source§

unsafe fn def_singleton_method_unchecked<N, F>(self, name: N, f: F)
where N: Into<SymbolId>, F: MethodFn<Self>,

Defines a method for name on the singleton class of self that calls f when invoked. Read more
Source§

unsafe fn call(self, method: impl Into<SymbolId>) -> AnyObject

Calls method on self and returns its output. Read more
Source§

unsafe fn call_protected(self, method: impl Into<SymbolId>) -> Result<AnyObject>

Calls method on self and returns its output, or an exception if one is raised. Read more
Source§

unsafe fn call_with( self, method: impl Into<SymbolId>, args: &[impl Object], ) -> AnyObject

Calls method on self with args and returns its output. Read more
Source§

unsafe fn call_with_protected( self, method: impl Into<SymbolId>, args: &[impl Object], ) -> Result<AnyObject>

Calls method on self with args and returns its output, or an exception if one is raised. Read more
Source§

unsafe fn call_public(self, method: impl Into<SymbolId>) -> AnyObject

Calls the public method on self and returns its output. Read more
Source§

unsafe fn call_public_protected( self, method: impl Into<SymbolId>, ) -> Result<AnyObject>

Calls the public method on self and returns its output, or an exception if one is raised. Read more
Source§

unsafe fn call_public_with( self, method: impl Into<SymbolId>, args: &[impl Object], ) -> AnyObject

Calls the public method on self with args and returns its output. Read more
Source§

unsafe fn call_public_with_protected( self, method: impl Into<SymbolId>, args: &[impl Object], ) -> Result<AnyObject>

Calls the public method on self with args and returns its output, or an exception if one is raised. Read more
Source§

fn inspect(self) -> String

Returns a printable string representation of self. Read more
Source§

fn to_s(self) -> String

Returns the result of calling the to_s method on self.
Source§

fn is_frozen(self) -> bool

Returns whether modifications can be made to self.
Source§

fn freeze(self)

Freezes self, preventing any further mutations.
Source§

fn is_eql<O: Object>(self, other: &O) -> bool

Returns whether self is equal to other in terms of the eql? method.
Source§

fn get_attr<N: Into<SymbolId>>(self, name: N) -> AnyObject

Returns the value for the attribute of self associated with name.
Source§

unsafe fn eval(self, args: impl EvalArgs) -> AnyObject

Evaluates args in the context of self. Read more
Source§

unsafe fn eval_protected(self, args: impl EvalArgs) -> Result<AnyObject>

Evaluates args in the context of self, returning any raised exceptions. Read more
Source§

impl<R: Rosy> PartialEq<AnyObject> for RosyObject<R>

Source§

fn eq(&self, obj: &AnyObject) -> 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<R> Copy for RosyObject<R>

Auto Trait Implementations§

§

impl<R> Freeze for RosyObject<R>

§

impl<R> RefUnwindSafe for RosyObject<R>
where R: RefUnwindSafe,

§

impl<R> !Send for RosyObject<R>

§

impl<R> !Sync for RosyObject<R>

§

impl<R> Unpin for RosyObject<R>
where R: Unpin,

§

impl<R> UnwindSafe for RosyObject<R>
where R: UnwindSafe,

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