pub trait CompressionStrategy:
Sealed
+ Sync
+ Send {
// Required methods
fn name(&self) -> &'static str;
fn compress<'life0, 'life1, 'async_trait>(
&'life0 self,
uncompressed: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, CompressionError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn decompress<'life0, 'life1, 'async_trait>(
&'life0 self,
compressed: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, CompressionError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
The CompressionStrategy
trait defines the interface for compression and decompression strategies.
It is sealed to restrict external implementations.
§Requirements
Implementations must:
- Provide a name for the strategy.
- Implement asynchronous methods for compressing and decompressing data.
§Associated Types
name
- Returns the name of the compression strategy.compress
- Compresses the provided data asynchronously.decompress
- Decompresses the provided data asynchronously.