Pluggable

Trait Pluggable 

Source
pub trait Pluggable {
    // Provided methods
    fn get<P: Plugin<Self>>(&mut self) -> Result<P::Value, P::Error>
       where P::Value: Clone + Any,
             Self: Extensible { ... }
    fn get_ref<P: Plugin<Self>>(&mut self) -> Result<&P::Value, P::Error>
       where P::Value: Any,
             Self: Extensible { ... }
    fn get_mut<P: Plugin<Self>>(&mut self) -> Result<&mut P::Value, P::Error>
       where P::Value: Any,
             Self: Extensible { ... }
    fn compute<P: Plugin<Self>>(&mut self) -> Result<P::Value, P::Error> { ... }
}
Expand description

An interface for plugins that cache values between calls.

R is the type of the plugin’s return value, which must be cloneable.

Provided Methods§

Source

fn get<P: Plugin<Self>>(&mut self) -> Result<P::Value, P::Error>
where P::Value: Clone + Any, Self: Extensible,

Return a copy of the plugin’s produced value.

The plugin will be created if it doesn’t exist already. If plugin creation fails, an error is returned.

P is the plugin type.

Source

fn get_ref<P: Plugin<Self>>(&mut self) -> Result<&P::Value, P::Error>
where P::Value: Any, Self: Extensible,

Return a reference to the plugin’s produced value.

The plugin will be created if it doesn’t exist already. If plugin creation fails an error is returned.

P is the plugin type.

Source

fn get_mut<P: Plugin<Self>>(&mut self) -> Result<&mut P::Value, P::Error>
where P::Value: Any, Self: Extensible,

Return a mutable reference to the plugin’s produced value.

The plugin will be created if it doesn’t exist already. If plugin creation fail an error is returned.

P is the plugin type.

Source

fn compute<P: Plugin<Self>>(&mut self) -> Result<P::Value, P::Error>

Create and evaluate a once-off instance of a plugin.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§