pub trait ModuleRegistry {
    type Value;
    type Error;
    type Spec: 'static;

    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
; 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§

source

type Value

Concrete value type for boxed Ruby values.

source

type Error

Concrete error type for errors encountered when manipulating the module registry.

source

type Spec: 'static

Type representing a module specification.

Required Methods§

source

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.

source

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.

source

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§

source

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.

Implementors§