pub struct App { /* private fields */ }Expand description
Main application structure with dependency injection support.
This struct provides the new dependency injection-based architecture for the SubX application, allowing for better testability and configuration management.
Implementations§
Source§impl App
impl App
Sourcepub fn new(config_service: Arc<dyn ConfigService>) -> Self
pub fn new(config_service: Arc<dyn ConfigService>) -> Self
Create a new application instance with the provided configuration service.
§Arguments
config_service- The configuration service to use
Sourcepub fn new_with_production_config() -> Result<Self>
pub fn new_with_production_config() -> Result<Self>
Create a new application instance with the production configuration service.
This is the default way to create an application instance for production use.
§Errors
Returns an error if the production configuration service cannot be created.
Sourcepub async fn run(&self) -> Result<()>
pub async fn run(&self) -> Result<()>
Run the application with command-line argument parsing.
This method parses command-line arguments and executes the appropriate command with the configured dependencies.
§Errors
Returns an error if command execution fails.
Sourcepub async fn handle_command(&self, command: Commands) -> Result<()>
pub async fn handle_command(&self, command: Commands) -> Result<()>
Sourcepub fn config_service(&self) -> &Arc<dyn ConfigService>
pub fn config_service(&self) -> &Arc<dyn ConfigService>
Get a reference to the configuration service.
This allows access to the configuration service for testing or advanced use cases.
Sourcepub fn get_config(&self) -> Result<Config>
pub fn get_config(&self) -> Result<Config>
Get the current configuration.
This is a convenience method that retrieves the configuration from the configured service.
§Errors
Returns an error if configuration loading fails.