[−][src]Struct rosy::Module
An instance of Ruby's Module
type.
Methods
impl Module
[src]
pub fn extend(self, object: impl Object) -> Result
[src]
Extends object
with the contents of self
.
pub unsafe fn extend_unchecked(self, object: impl Object)
[src]
Extends object
with the contents of self
.
Safety
The caller must ensure that self
is not frozen or else a FrozenError
exception will be raised.
pub fn def(name: impl Into<SymbolId>) -> Result<Self, DefMixinError>
[src]
Defines a new top-level module with name
.
Examples
Defining a new module is straightforward:
let my_mod = rosy::Module::def("MyMod").unwrap();
Attempting to define an existing module will result in an error:
use rosy::Module; let math = Module::def("Math").unwrap_err().existing_object(); assert_eq!(Module::math(), math.unwrap());
pub fn get(name: impl Into<SymbolId>) -> Option<Self>
[src]
Retrieves an existing top-level Module
defined by name
.
pub unsafe fn get_unchecked(name: impl Into<SymbolId>) -> Self
[src]
Retrieves an existing top-level Module
defined by name
.
Safety
This method does not:
- Check whether an item for
name
exists (an exception will be thrown if this is the case) - Check whether the returned item for
name
is actually aModule
pub fn get_or_def(name: impl Into<SymbolId>) -> Result<Self, DefMixinError>
[src]
Retrieves an existing top-level Module
defined by name
or defines
one if it doesn't exist.
pub fn name(self) -> Option<String>
[src]
Returns the name of self
or nil
if anonymous.
pub fn ancestors(self) -> Array<Module>
[src]
Returns the ancestors of this module, including itself.
impl Module
[src]
Built-in modules.
pub fn kernel() -> Self
[src]
The Kernel
module.
pub fn comparable() -> Self
[src]
The Comparable
module.
pub fn enumerable() -> Self
[src]
The Enumerable
module.
pub fn errno() -> Self
[src]
The Errno
module.
pub fn file_test() -> Self
[src]
The FileTest
module.
pub fn gc() -> Self
[src]
The GC
module.
pub fn math() -> Self
[src]
The Math
module.
pub fn process() -> Self
[src]
The Process
module.
pub fn wait_readable() -> Self
[src]
The WaitReadable
module.
pub fn wait_writable() -> Self
[src]
The WaitWritable
module.
Trait Implementations
impl Classify for Module
[src]
impl Mixin for Module
[src]
fn to_class(self) -> Result<Class, Module>
[src]
fn to_module(self) -> Result<Module, Class>
[src]
fn include(self, module: Module)
[src]
Embeds the contents of module
in self
.
#[must_use]
fn includes(self, module: Module) -> bool
[src]
Returns whether self
or one of its ancestors includes module
. Read more
fn included_modules(self) -> Array<Module>
[src]
Returns an array of the modules included in self
.
fn prepend(self, module: Module)
[src]
Prepends module
in self
.
fn def_class(self, name: impl Into<SymbolId>) -> Result<Class, DefMixinError>
[src]
Defines a new class under self
with name
.
fn def_subclass<S: Object>(
self,
superclass: Class<S>,
name: impl Into<SymbolId>
) -> Result<Class, DefMixinError>
[src]
self,
superclass: Class<S>,
name: impl Into<SymbolId>
) -> Result<Class, DefMixinError>
Defines a new subclass of superclass
under self
with name
.
fn get_class(self, name: impl Into<SymbolId>) -> Option<Class>
[src]
Returns the existing Class
with name
in self
.
unsafe fn get_class_unchecked(self, name: impl Into<SymbolId>) -> Class
[src]
Returns the existing Class
with name
in self
. Read more
fn def_module(self, name: impl Into<SymbolId>) -> Result<Module, DefMixinError>
[src]
Defines a new module under self
with name
.
fn get_module(self, name: impl Into<SymbolId>) -> Option<Module>
[src]
Returns the existing Module
with name
in self
.
unsafe fn get_module_unchecked(self, name: impl Into<SymbolId>) -> Module
[src]
Returns the existing Module
with name
in self
. Read more
fn has_const(self, name: impl Into<SymbolId>) -> bool
[src]
Returns whether a constant for name
is defined in self
, or in some parent class if not self
. Read more
fn get_const(self, name: impl Into<SymbolId>) -> AnyObject
[src]
Returns the constant value for name
in self
, or in some parent class if not self
. Read more
fn set_const(self, name: impl Into<SymbolId>, val: impl Into<AnyObject>)
[src]
Sets the value a constant for name
in self
to val
.
fn remove_const(self, name: impl Into<SymbolId>) -> AnyObject
[src]
Removes the constant value for name
, returning it. Read more
fn has_class_var(self, var: impl Into<SymbolId>) -> bool
[src]
Returns whether the class-level var
is defined in self
.
fn get_class_var(self, var: impl Into<SymbolId>) -> AnyObject
[src]
Returns the class-level var
in self
. Read more
fn set_class_var<K, V>(self, key: K, val: V) -> Result where
K: Into<SymbolId>,
V: Into<AnyObject>,
[src]
K: Into<SymbolId>,
V: Into<AnyObject>,
Sets the class-level var
in self
to val
.
unsafe fn set_class_var_unchecked<K, V>(self, key: K, val: V) where
K: Into<SymbolId>,
V: Into<AnyObject>,
[src]
K: Into<SymbolId>,
V: Into<AnyObject>,
Sets the class-level var for key
in self
to val
. Read more
fn def_attr_reader<N: Into<SymbolId>>(self, name: N) -> Result
[src]
Defines an read-only attribute on self
with name
.
unsafe fn def_attr_reader_unchecked<N: Into<SymbolId>>(self, name: N)
[src]
Defines an read-only attribute on self
with name
. Read more
fn def_attr_writer<N: Into<SymbolId>>(self, name: N) -> Result
[src]
Defines a write-only attribute on self
with name
.
unsafe fn def_attr_writer_unchecked<N: Into<SymbolId>>(self, name: N)
[src]
Defines a write-only attribute on self
with name
. Read more
fn def_attr_accessor<N: Into<SymbolId>>(self, name: N) -> Result
[src]
Defines a read-write attribute on self
with name
.
unsafe fn def_attr_accessor_unchecked<N: Into<SymbolId>>(self, name: N)
[src]
Defines a read-write attribute on self
with name
. Read more
unsafe fn eval(self, args: impl EvalArgs) -> AnyObject
[src]
Evaluates args
in the context of self
. Read more
unsafe fn eval_protected(self, args: impl EvalArgs) -> Result<AnyObject>
[src]
Evaluates args
in the context of self
, returning any raised exceptions. Read more
impl Object for Module
[src]
fn unique_id() -> Option<u128>
[src]
fn cast<A: Object>(obj: A) -> Option<Self>
[src]
fn ty(self) -> Ty
[src]
fn is_ty(self, ty: Ty) -> bool
[src]
unsafe fn from_raw(raw: usize) -> Self
[src]
Creates a new object from raw
without checking. Read more
unsafe fn cast_unchecked(obj: impl Object) -> Self
[src]
Casts obj
to Self
without checking its type.
fn into_any_object(self) -> AnyObject
[src]
Returns self
as an AnyObject
.
fn as_any_object(&self) -> &AnyObject
[src]
Returns a reference to self
as an AnyObject
.
fn as_any_slice(&self) -> &[AnyObject]
[src]
Returns self
as a reference to a single-element slice.
fn raw(self) -> usize
[src]
Returns the raw object pointer.
unsafe fn as_unchecked<O: Object>(&self) -> &O
[src]
Casts self
to O
without checking whether it is one.
unsafe fn into_unchecked<O: Object>(self) -> O
[src]
Converts self
to O
without checking whether it is one.
fn id(self) -> u64
[src]
Returns the object's identifier.
fn class(self) -> Class<Self>
[src]
Returns the Class
for self
. Read more
fn singleton_class(self) -> Class<Self>
[src]
Returns the singleton Class
of self
, creating one if it doesn't exist already. Read more
fn mark(self)
[src]
Marks self
for Ruby to avoid garbage collecting it.
unsafe fn force_recycle(self)
[src]
Forces the garbage collector to free the contents of self
. Read more
fn def_singleton_method<N, F>(self, name: N, f: F) -> Result where
N: Into<SymbolId>,
F: MethodFn<Self>,
[src]
N: Into<SymbolId>,
F: MethodFn<Self>,
Defines a method for name
on the singleton class of self
that calls f
when invoked. Read more
unsafe fn def_singleton_method_unchecked<N, F>(self, name: N, f: F) where
N: Into<SymbolId>,
F: MethodFn<Self>,
[src]
N: Into<SymbolId>,
F: MethodFn<Self>,
Defines a method for name
on the singleton class of self
that calls f
when invoked. Read more
unsafe fn call(self, method: impl Into<SymbolId>) -> AnyObject
[src]
Calls method
on self
and returns its output. Read more
unsafe fn call_protected(self, method: impl Into<SymbolId>) -> Result<AnyObject>
[src]
Calls method
on self
and returns its output, or an exception if one is raised. Read more
unsafe fn call_with(
self,
method: impl Into<SymbolId>,
args: &[impl Object]
) -> AnyObject
[src]
self,
method: impl Into<SymbolId>,
args: &[impl Object]
) -> AnyObject
Calls method
on self
with args
and returns its output. Read more
unsafe fn call_with_protected(
self,
method: impl Into<SymbolId>,
args: &[impl Object]
) -> Result<AnyObject>
[src]
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
unsafe fn call_public(self, method: impl Into<SymbolId>) -> AnyObject
[src]
Calls the public method
on self
and returns its output. Read more
unsafe fn call_public_protected(
self,
method: impl Into<SymbolId>
) -> Result<AnyObject>
[src]
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
unsafe fn call_public_with(
self,
method: impl Into<SymbolId>,
args: &[impl Object]
) -> AnyObject
[src]
self,
method: impl Into<SymbolId>,
args: &[impl Object]
) -> AnyObject
Calls the public method
on self
with args
and returns its output. Read more
unsafe fn call_public_with_protected(
self,
method: impl Into<SymbolId>,
args: &[impl Object]
) -> Result<AnyObject>
[src]
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
fn inspect(self) -> String
[src]
Returns a printable string representation of self
. Read more
fn to_s(self) -> String
[src]
Returns the result of calling the to_s
method on self
.
fn is_frozen(self) -> bool
[src]
Returns whether modifications can be made to self
.
fn freeze(self)
[src]
Freezes self
, preventing any further mutations.
fn is_eql<O: Object>(self, other: &O) -> bool
[src]
Returns whether self
is equal to other
in terms of the eql?
method. Read more
fn get_attr<N: Into<SymbolId>>(self, name: N) -> AnyObject
[src]
Returns the value for the attribute of self
associated with name
.
unsafe fn eval(self, args: impl EvalArgs) -> AnyObject
[src]
Evaluates args
in the context of self
. Read more
unsafe fn eval_protected(self, args: impl EvalArgs) -> Result<AnyObject>
[src]
Evaluates args
in the context of self
, returning any raised exceptions. Read more
impl Eq for Module
[src]
impl<O: Object> PartialEq<O> for Module
[src]
fn eq(&self, other: &O) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Copy for Module
[src]
impl Clone for Module
[src]
fn clone(&self) -> Module
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl AsRef<AnyObject> for Module
[src]
impl From<Module> for AnyObject
[src]
impl Debug for Module
[src]
impl Display for Module
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,