Skip to main content

ComponentFactory

Trait ComponentFactory 

Source
pub trait ComponentFactory: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn kind(&self) -> &'static str;
    fn depends_on(&self) -> Vec<String>;
    fn build<'life0, 'async_trait>(
        self: Box<Self>,
        config: Value,
        ctx: &'life0 ComponentContext,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AnyComponent>, RegistryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Type-erased factory for a concrete Component type. The registry holds factories as Box<dyn ComponentFactory> so it can drive heterogeneous types uniformly.

Required Methods§

Source

fn name(&self) -> &str

User-assigned instance name.

Source

fn kind(&self) -> &'static str

Component kind identifier (e.g. "provider.openai").

Source

fn depends_on(&self) -> Vec<String>

Names of components this component depends on.

Source

fn build<'life0, 'async_trait>( self: Box<Self>, config: Value, ctx: &'life0 ComponentContext, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AnyComponent>, RegistryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Build an AnyComponent from the raw configuration value.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§