fuel_data_parser

Trait CompressionStrategy

Source
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.

Required Methods§

Source

fn name(&self) -> &'static str

Returns the name of the compression strategy.

Source

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,

Compresses the provided data asynchronously.

§Arguments
  • uncompressed - A slice of bytes representing the data to be compressed.
§Returns

A Result containing a Vec<u8> of the compressed data or a CompressionError if compression fails.

Source

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,

Decompresses the provided data asynchronously.

§Arguments
  • compressed - A slice of bytes representing the data to be decompressed.
§Returns

A Result containing a Vec<u8> of the decompressed data or a CompressionError if decompression fails.

Implementors§