pub struct ComponentFactory { /* private fields */ }Expand description
Component factory for creating configured instances.
This factory provides a centralized way to create core components with proper configuration injection, ensuring consistent component initialization across the application.
§Examples
use subx_cli::core::ComponentFactory;
use subx_cli::config::ProductionConfigService;
use std::sync::Arc;
let config_service = Arc::new(ProductionConfigService::new()?);
let factory = ComponentFactory::new(config_service.as_ref())?;
// Create components with proper configuration
let match_engine = factory.create_match_engine()?;
let file_manager = factory.create_file_manager();
let ai_provider = factory.create_ai_provider()?;Implementations§
Source§impl ComponentFactory
impl ComponentFactory
Sourcepub fn new(config_service: &dyn ConfigService) -> Result<Self>
pub fn new(config_service: &dyn ConfigService) -> Result<Self>
Sourcepub fn create_match_engine(&self) -> Result<MatchEngine>
pub fn create_match_engine(&self) -> Result<MatchEngine>
Create a match engine with AI configuration.
Returns a properly configured MatchEngine instance using the AI configuration section.
§Errors
Returns an error if AI provider creation fails.
Sourcepub fn create_file_manager(&self) -> FileManager
pub fn create_file_manager(&self) -> FileManager
Create a file manager with general configuration.
Returns a properly configured FileManager instance using the general configuration section.
Sourcepub fn create_ai_provider(&self) -> Result<Box<dyn AIProvider>>
pub fn create_ai_provider(&self) -> Result<Box<dyn AIProvider>>
Create an AI provider with AI configuration.
Returns a properly configured AI provider instance based on the provider type specified in the AI configuration.
§Errors
Returns an error if the provider type is unsupported or provider creation fails.