logo
pub enum EnclosingRubyScope {
    Class(ClassScope),
    Module(ModuleScope),
}
Expand description

Typesafe wrapper for the RClass * of the enclosing scope for an mruby Module or Class.

In Ruby, classes and modules can be defined inside another class or module. mruby only supports resolving RClass pointers relative to an enclosing scope. This can be the top level with mrb_class_get and mrb_module_get or it can be under another class with mrb_class_get_under or module with mrb_module_get_under.

Because there is no C API to resolve class and module names directly, each class-like holds a reference to its enclosing scope so it can recursively resolve its enclosing RClass *.

Variants

Class(ClassScope)

Reference to a Ruby Class enclosing scope.

Module(ModuleScope)

Reference to a Ruby Module enclosing scope.

Implementations

Factory for EnclosingRubyScope::Class that clones a class::Spec.

This function is useful when extracting an enclosing scope from the class registry.

Factory for EnclosingRubyScope::Module that clones a module::Spec.

This function is useful when extracting an enclosing scope from the module registry.

Resolve the RClass * of the wrapped class or module.

Return None if the class-like has no EnclosingRubyScope.

The current implementation results in recursive calls to this function for each enclosing scope.

Safety

This function must be called within an Artichoke::with_ffi_boundary closure because the FFI APIs called in this function may require access to the Artichoke State.

Get the fully-qualified name of the wrapped class or module.

For example, in the following Ruby code, C has a fully-qualified name of A::B::C.

module A
  class B
    module C
      CONST = 1
    end
  end
end

The current implementation results in recursive calls to this function for each enclosing scope.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.