pub trait ModuleRegistry {
type Value;
type Error;
type Spec: 'static;
// Required methods
fn def_module<T>(&mut self, spec: Self::Spec) -> Result<(), Self::Error>
where T: Any;
fn module_spec<T>(&self) -> Result<Option<&Self::Spec>, Self::Error>
where T: Any;
fn module_of<T>(&mut self) -> Result<Option<Self::Value>, Self::Error>
where T: Any;
// Provided method
fn is_module_defined<T>(&self) -> bool
where T: Any { ... }
}
Expand description
Define and store module specs on an interpreter.
A module spec is a static set of information the interpreter requires to
define a Ruby Module
object.
Required Associated Types§
Required Methods§
sourcefn def_module<T>(&mut self, spec: Self::Spec) -> Result<(), Self::Error>where
T: Any,
fn def_module<T>(&mut self, spec: Self::Spec) -> Result<(), Self::Error>where
T: Any,
Create a module definition bound to a Rust type T
.
Module definitions have the same lifetime as the interpreter.
§Errors
If the module registry state is inaccessible, an error is returned.
sourcefn module_spec<T>(&self) -> Result<Option<&Self::Spec>, Self::Error>where
T: Any,
fn module_spec<T>(&self) -> Result<Option<&Self::Spec>, Self::Error>where
T: Any,
Retrieve a module definition from the interpreter bound to Rust type T
.
This function returns None
if type T
has not had a module spec
registered for it using ModuleRegistry::def_module
.
§Errors
If the module registry state is inaccessible, an error is returned.
sourcefn module_of<T>(&mut self) -> Result<Option<Self::Value>, Self::Error>where
T: Any,
fn module_of<T>(&mut self) -> Result<Option<Self::Value>, Self::Error>where
T: Any,
Retrieve a boxed Ruby value containing a Module
object for the
Module
bound to Rust type T
.
If the interpreter cannot find or load a module associated with T
,
Ok(None)
is returned.
§Errors
If the module registry state is inaccessible, an error is returned.
Provided Methods§
sourcefn is_module_defined<T>(&self) -> boolwhere
T: Any,
fn is_module_defined<T>(&self) -> boolwhere
T: Any,
Retrieve whether a module definition exists from the interpreter bound
to Rust type T
If the interpreter cannot find or load a module associated with T
,
Ok(None)
is returned.
§Errors
If the module registry state is inaccessible, an error is returned.