using System.IO.Compression;

namespace ZB.MOM.WW.CBDD.Core.Compression;

/// <summary>
/// Codec abstraction for payload compression and decompression.
/// </summary>
public interface ICompressionCodec
{
    /// <summary>
    /// Codec identifier.
    /// </summary>
    CompressionCodec Codec { get; }

    /// <summary>
    /// Compresses input bytes.
    /// </summary>
    /// <param name="input">Input payload bytes to compress.</param>
    /// <param name="level">Compression level to apply.</param>
    byte[] Compress(ReadOnlySpan<byte> input, CompressionLevel level);

    /// <summary>
    /// Decompresses payload bytes with output bounds validation.
    /// </summary>
    /// <param name="input">Input payload bytes to decompress.</param>
    /// <param name="expectedLength">Expected decompressed length.</param>
    /// <param name="maxDecompressedSizeBytes">Maximum allowed decompressed payload size in bytes.</param>
    byte[] Decompress(ReadOnlySpan<byte> input, int expectedLength, int maxDecompressedSizeBytes);
}
