aboutsummaryrefslogtreecommitdiff
path: root/lib/Net.Compression/VNLib.Net.Compression/INativeCompressionLib.cs
blob: 878dc5c77f9c8a6619559ee0c59f37eefa63df0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Copyright (c) 2023 Vaughn Nugent
* 
* Library: VNLib
* Package: VNLib.Net.Compression
* File: INativeCompressionLib.cs 
*
* INativeCompressionLib.cs is part of VNLib.Net.Compression which is part of 
* the larger VNLib collection of libraries and utilities.
*
* VNLib.Net.Compression is free software: you can redistribute it and/or modify 
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 2 of the License,
* or (at your option) any later version.
*
* VNLib.Net.Compression is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License 
* along with VNLib.Net.Compression. If not, see http://www.gnu.org/licenses/.
*/

using System;
using System.IO.Compression;
using System.Runtime.InteropServices;

using VNLib.Net.Http;

namespace VNLib.Net.Compression
{
    /// <summary>
    /// Represents a native compression library that can create native 
    /// compressor instances.
    /// </summary>
    public interface INativeCompressionLib
    {
        /// <summary>
        /// Gets the compression methods supported by the underluing library
        /// </summary>
        /// <returns>The supported compression methods</returns>
        CompressionMethod GetSupportedMethods();

        /// <summary>
        /// Allocates a new <see cref="INativeCompressor"/> implementation that allows for 
        /// compressing stream data.
        /// </summary>
        /// <param name="method">The desired <see cref="CompressionMethod"/>, must be a supported method</param>
        /// <param name="level">The desired <see cref="CompressionLevel"/> to compress blocks with</param>
        /// <returns>The new <see cref="INativeCompressor"/></returns>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="NotSupportedException">The the level or method are not supported by the underlying library</exception>
        INativeCompressor AllocCompressor(CompressionMethod method, CompressionLevel level);

        /// <summary>
        /// Allocates a safe compressor handle to allow native operations if preferred.
        /// </summary>
        ///<param name="method">The desired <see cref="CompressionMethod"/>, must be a supported method</param>
        /// <param name="level">The desired <see cref="CompressionLevel"/> to compress blocks with</param>
        /// <returns>A new <see cref="SafeHandle"/> that holds a pointer to the native compressor context</returns>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="NotSupportedException">The the level or method are not supported by the underlying library</exception>
        SafeHandle AllocSafeCompressorHandle(CompressionMethod method, CompressionLevel level);
    }
}