perf: replace dyn trait objects with concrete types to eliminate vtable overhead

Remove async-trait dependency and use native Rust async fn in traits.
Replace Arc<dyn Trait> with Arc<ConcreteType> throughout the codebase
to enable monomorphization and eliminate dynamic dispatch overhead.

Key changes:
- Remove write-behind cache (no implementation existed)
- Fix should_transcode static method call
- Use ContactStorageAdapter directly instead of dyn AddressBookUseCase
- Clean up unused trait imports across services and DI

https://claude.ai/code/session_01EbAFEfyJNLRmJHmmYDX3Tt
This commit is contained in:
Claude
2026-03-03 15:36:42 +00:00
parent efcf88c4d7
commit 1b49135ca9
101 changed files with 346 additions and 576 deletions
+11 -8
View File
@@ -17,6 +17,9 @@ use crate::application::ports::trash_ports::TrashUseCase;
use crate::application::services::folder_service::FolderService;
use crate::common::config::AppConfig;
use crate::common::errors::DomainError;
use crate::application::services::file_management_service::FileManagementService;
use crate::application::services::file_retrieval_service::FileRetrievalService;
use crate::application::services::trash_service::TrashService;
/// Specific errors for batch operations
#[derive(Debug, Error)]
@@ -65,18 +68,18 @@ pub struct BatchStats {
/// Batch operations service
pub struct BatchOperationService {
file_retrieval: Arc<dyn FileRetrievalUseCase>,
file_management: Arc<dyn FileManagementUseCase>,
file_retrieval: Arc<FileRetrievalService>,
file_management: Arc<FileManagementService>,
folder_service: Arc<FolderService>,
trash_service: Option<Arc<dyn TrashUseCase>>,
trash_service: Option<Arc<TrashService>>,
config: AppConfig,
}
impl BatchOperationService {
/// Creates a new instance of the batch operations service
pub fn new(
file_retrieval: Arc<dyn FileRetrievalUseCase>,
file_management: Arc<dyn FileManagementUseCase>,
file_retrieval: Arc<FileRetrievalService>,
file_management: Arc<FileManagementService>,
folder_service: Arc<FolderService>,
config: AppConfig,
) -> Self {
@@ -91,8 +94,8 @@ impl BatchOperationService {
/// Creates a new instance with default configuration
pub fn default(
file_retrieval: Arc<dyn FileRetrievalUseCase>,
file_management: Arc<dyn FileManagementUseCase>,
file_retrieval: Arc<FileRetrievalService>,
file_management: Arc<FileManagementService>,
folder_service: Arc<FolderService>,
) -> Self {
Self::new(
@@ -104,7 +107,7 @@ impl BatchOperationService {
}
/// Set the optional trash service (enables batch trash operations)
pub fn with_trash_service(mut self, trash_service: Arc<dyn TrashUseCase>) -> Self {
pub fn with_trash_service(mut self, trash_service: Arc<TrashService>) -> Self {
self.trash_service = Some(trash_service);
self
}