Skip to main content

FactoryInvoker

Trait FactoryInvoker 

Source
pub trait FactoryInvoker: Send + Sync {
    // Required method
    fn invoke(
        &self,
        config: Value,
        ctx: ComponentContext,
    ) -> Result<Box<dyn AnyComponent>, FactoryError>;
}
Expand description

A factory invocable — given a JSON config and a ComponentContext, produces a Box<dyn AnyComponent>.

Required Methods§

Source

fn invoke( &self, config: Value, ctx: ComponentContext, ) -> Result<Box<dyn AnyComponent>, FactoryError>

Create a component from the given JSON config.

§Errors

Returns FactoryError::InvalidConfig when deserialization fails, or FactoryError::FactoryFailed when construction fails.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<F> FactoryInvoker for F
where F: Fn(Value, ComponentContext) -> Result<Box<dyn AnyComponent>, FactoryError> + Send + Sync + 'static,

Blanket implementation so that any matching closure can be used as a FactoryInvoker directly.