Expand description
Async encryption adapter (wraps sync domain trait for async contexts)
§Async Encryption Adapter
This module provides an async adapter for the synchronous
EncryptionService domain trait. It demonstrates the proper pattern for
handling sync domain services in async infrastructure contexts.
§Architecture Pattern
Following the hybrid DDD/Clean/Hexagonal architecture:
- Domain: Defines sync
EncryptionServicetrait (business logic) - Infrastructure: Provides async adapter (execution model)
- Separation of Concerns: Domain doesn’t dictate async/sync execution
§Usage
ⓘ
use std::sync::Arc;
use adaptive_pipeline::infrastructure::adapters::AsyncEncryptionAdapter;
use adaptive_pipeline::infrastructure::adapters::MultiAlgoEncryption;
// Create sync implementation
let sync_service = Arc::new(MultiAlgoEncryption::new());
// Wrap in async adapter
let async_service = AsyncEncryptionAdapter::new(sync_service);
// Use in async context
let result = async_service.encrypt_chunk_async(chunk, &config, &key, &mut context).await?;Structs§
- Async
Encryption Adapter - Async adapter for
EncryptionService