xref: /openbmc/bmcweb/http/zstd_decompressor.hpp (revision b25390694f7015224fbf02de247faec4c50429aa)
1*b2539069SEd Tanous // SPDX-License-Identifier: Apache-2.0
2*b2539069SEd Tanous // SPDX-FileCopyrightText: Copyright OpenBMC Authors
3*b2539069SEd Tanous 
4*b2539069SEd Tanous #pragma once
5*b2539069SEd Tanous 
6*b2539069SEd Tanous #ifdef HAVE_ZSTD
7*b2539069SEd Tanous #include <zstd.h>
8*b2539069SEd Tanous #endif
9*b2539069SEd Tanous 
10*b2539069SEd Tanous #include <boost/asio/buffer.hpp>
11*b2539069SEd Tanous #include <boost/beast/core/flat_buffer.hpp>
12*b2539069SEd Tanous 
13*b2539069SEd Tanous #include <optional>
14*b2539069SEd Tanous 
15*b2539069SEd Tanous class ZstdDecompressor
16*b2539069SEd Tanous {
17*b2539069SEd Tanous     boost::beast::flat_buffer compressionBuf;
18*b2539069SEd Tanous 
19*b2539069SEd Tanous #ifdef HAVE_ZSTD
20*b2539069SEd Tanous     ZSTD_DCtx* dctx;
21*b2539069SEd Tanous #endif
22*b2539069SEd Tanous 
23*b2539069SEd Tanous   public:
24*b2539069SEd Tanous     ZstdDecompressor(const ZstdDecompressor&) = delete;
25*b2539069SEd Tanous     ZstdDecompressor(ZstdDecompressor&&) = delete;
26*b2539069SEd Tanous     ZstdDecompressor& operator=(const ZstdDecompressor&) = delete;
27*b2539069SEd Tanous     ZstdDecompressor& operator=(ZstdDecompressor&&) = delete;
28*b2539069SEd Tanous 
29*b2539069SEd Tanous     ZstdDecompressor();
30*b2539069SEd Tanous     std::optional<boost::asio::const_buffer> decompress(
31*b2539069SEd Tanous         boost::asio::const_buffer buffIn);
32*b2539069SEd Tanous     ~ZstdDecompressor();
33*b2539069SEd Tanous };
34