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§
Sourcefn invoke(
&self,
config: Value,
ctx: ComponentContext,
) -> Result<Box<dyn AnyComponent>, FactoryError>
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§
impl<F> FactoryInvoker for Fwhere
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.