Skip to main content

optimize_compression

Function optimize_compression 

Source
pub fn optimize_compression(
    blob: Blob,
    input_compression: TileCompression,
    target: &TargetCompression,
) -> Result<(Blob, TileCompression)>
Expand description

Optimizes the compression of a data blob based on the target compression settings.

This function attempts to compress or decompress the input blob to match the desired compression settings. It ensures that the resulting blob adheres to the allowed compression algorithms and the specified compression goal.

§Arguments

  • blob - The input data blob to compress or decompress.
  • input_compression - The current compression algorithm of the blob.
  • target - The target compression settings.

§Returns

  • Ok((Blob, TileCompression)) containing the optimized blob and its compression algorithm.
  • Err(anyhow::Error) if the optimization fails.

§Errors

  • If no compression algorithms are allowed in the target.
  • If ‘Uncompressed’ is not included in the allowed compressions.
  • If decompression or compression operations fail.