2025-03-19 19:52:12 +01:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
2026-02-14 01:29:34 +01:00
|
|
|
use crate::application::ports::file_ports::{
|
|
|
|
|
FileManagementUseCase, FileRetrievalUseCase, FileUploadUseCase, FileUseCaseFactory,
|
|
|
|
|
};
|
2025-03-19 19:52:12 +01:00
|
|
|
use crate::application::ports::storage_ports::{FileReadPort, FileWritePort};
|
2026-02-14 01:29:34 +01:00
|
|
|
use crate::application::services::file_management_service::FileManagementService;
|
|
|
|
|
use crate::application::services::file_retrieval_service::FileRetrievalService;
|
|
|
|
|
use crate::application::services::file_upload_service::FileUploadService;
|
2025-03-19 19:52:12 +01:00
|
|
|
|
2026-02-12 09:41:25 +01:00
|
|
|
/// Factory for creating file use case implementations
|
2025-03-19 19:52:12 +01:00
|
|
|
pub struct AppFileUseCaseFactory {
|
|
|
|
|
file_read_repository: Arc<dyn FileReadPort>,
|
|
|
|
|
file_write_repository: Arc<dyn FileWritePort>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl AppFileUseCaseFactory {
|
2026-02-12 09:41:25 +01:00
|
|
|
/// Creates a new factory for file use cases
|
2025-03-19 19:52:12 +01:00
|
|
|
pub fn new(
|
|
|
|
|
file_read_repository: Arc<dyn FileReadPort>,
|
2026-02-14 01:29:34 +01:00
|
|
|
file_write_repository: Arc<dyn FileWritePort>,
|
2025-03-19 19:52:12 +01:00
|
|
|
) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
file_read_repository,
|
|
|
|
|
file_write_repository,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl FileUseCaseFactory for AppFileUseCaseFactory {
|
|
|
|
|
fn create_file_upload_use_case(&self) -> Arc<dyn FileUploadUseCase> {
|
|
|
|
|
Arc::new(FileUploadService::new(self.file_write_repository.clone()))
|
|
|
|
|
}
|
2026-02-14 01:29:34 +01:00
|
|
|
|
2025-03-19 19:52:12 +01:00
|
|
|
fn create_file_retrieval_use_case(&self) -> Arc<dyn FileRetrievalUseCase> {
|
|
|
|
|
Arc::new(FileRetrievalService::new(self.file_read_repository.clone()))
|
|
|
|
|
}
|
2026-02-14 01:29:34 +01:00
|
|
|
|
2025-03-19 19:52:12 +01:00
|
|
|
fn create_file_management_use_case(&self) -> Arc<dyn FileManagementUseCase> {
|
2026-02-14 01:29:34 +01:00
|
|
|
Arc::new(FileManagementService::new(
|
|
|
|
|
self.file_write_repository.clone(),
|
|
|
|
|
))
|
2025-03-19 19:52:12 +01:00
|
|
|
}
|
2026-02-14 01:29:34 +01:00
|
|
|
}
|