Files
projectmycelium/src/services/factory.rs

36 lines
1.2 KiB
Rust

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 Mycelium Marketplace 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
}
}