init projectmycelium
This commit is contained in:
35
src/services/factory.rs
Normal file
35
src/services/factory.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use std::sync::Arc;
|
||||
use crate::services::{
|
||||
currency::CurrencyService,
|
||||
user_persistence::UserPersistence,
|
||||
};
|
||||
|
||||
/// Service factory for single source of truth service instantiation
|
||||
///
|
||||
/// This factory consolidates repeated service instantiations throughout
|
||||
/// the Project Mycelium codebase, focusing on persistent data access
|
||||
/// and eliminating mock data usage in favor of user_data/ directory.
|
||||
///
|
||||
/// Usage:
|
||||
/// ```rust,ignore
|
||||
/// let currency_service = ServiceFactory::currency_service();
|
||||
/// ```
|
||||
pub struct ServiceFactory;
|
||||
|
||||
impl ServiceFactory {
|
||||
/// Creates a new CurrencyService instance using persistent data
|
||||
///
|
||||
/// This replaces scattered CurrencyService instantiations throughout the codebase
|
||||
/// with a single source of truth, using persistent data instead of mock data.
|
||||
pub fn currency_service() -> Arc<CurrencyService> {
|
||||
Arc::new(CurrencyService::builder().build().unwrap())
|
||||
}
|
||||
|
||||
/// Provides access to UserPersistence for persistent data operations
|
||||
///
|
||||
/// This provides centralized access to persistent user data from user_data/
|
||||
/// directory, eliminating the need for mock data services.
|
||||
pub fn user_persistence() -> UserPersistence {
|
||||
UserPersistence
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user