summaryrefslogtreecommitdiff
path: root/http/zstd_decompressor.hpp
blob: 777a4b8fa90674feb77c7b8b3b4112cf4602788f (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
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright OpenBMC Authors

#pragma once

#ifdef HAVE_ZSTD
#include <zstd.h>
#endif

#include <boost/asio/buffer.hpp>
#include <boost/beast/core/flat_buffer.hpp>

#include <optional>

class ZstdDecompressor
{
    boost::beast::flat_buffer compressionBuf;

#ifdef HAVE_ZSTD
    ZSTD_DCtx* dctx;
#endif

  public:
    ZstdDecompressor(const ZstdDecompressor&) = delete;
    ZstdDecompressor(ZstdDecompressor&&) = delete;
    ZstdDecompressor& operator=(const ZstdDecompressor&) = delete;
    ZstdDecompressor& operator=(ZstdDecompressor&&) = delete;

    ZstdDecompressor();
    std::optional<boost::asio::const_buffer> decompress(
        boost::asio::const_buffer buffIn);
    ~ZstdDecompressor();
};