Module async_compression

Module async_compression 

Source
Expand description

Async compression adapter (wraps sync domain trait for async contexts)

§Async Compression Adapter

This module provides an async adapter for the synchronous CompressionService 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 CompressionService trait (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::AsyncCompressionAdapter;
use adaptive_pipeline::infrastructure::adapters::MultiAlgoCompression;

// Create sync implementation
let sync_service = Arc::new(MultiAlgoCompression::new());

// Wrap in async adapter
let async_service = AsyncCompressionAdapter::new(sync_service);

// Use in async context
let result = async_service.compress_chunk_async(chunk, &config, &mut context).await?;

Structs§

AsyncCompressionAdapter
Async adapter for CompressionService