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.
Sourcepub fn config(&self) -> &Config
pub fn config(&self) -> &Config
Get a reference to the current configuration.
Returns a reference to the configuration used by this factory.
Sourcepub fn create_vad_sync_detector(&self) -> Result<VadSyncDetector>
pub fn create_vad_sync_detector(&self) -> Result<VadSyncDetector>
Create a VAD sync detector with VAD configuration.
Returns a properly configured VadSyncDetector instance using the VAD settings.
§Errors
Returns an error if VAD sync detector creation fails.
Sourcepub fn create_vad_detector(&self) -> Result<LocalVadDetector>
pub fn create_vad_detector(&self) -> Result<LocalVadDetector>
Create a local VAD detector for audio processing.
Returns a properly configured LocalVadDetector instance.
§Errors
Returns an error if local VAD detector initialization fails.
Sourcepub fn create_audio_processor(&self) -> Result<VadAudioProcessor>
pub fn create_audio_processor(&self) -> Result<VadAudioProcessor>
Create an audio processor for VAD operations.
Returns a properly configured VadAudioProcessor instance.
§Errors
Returns an error if audio processor initialization fails.