userver: userver/compression/zstd.hpp Source File
Loading...
Searching...
No Matches
zstd.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/compression/zstd.hpp
4/// @brief @copybrief compression::zstd::Decompress
5/// @ingroup userver_universal
6
7#include <string_view>
8
9#include <userver/compression/error.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13/// @brief Zstandard (de)compression helpers.
14namespace compression::zstd {
15
16extern const int kDefaultCompressionLevel;
17
18/// @brief Decompresses all Zstandard frames in the input, ignoring skippable frames.
19/// @throws std::runtime_error if the input is invalid or truncated.
20/// @throws compression::TooBigError if the combined output exceeds `max_size`.
21std::string Decompress(std::string_view compressed, size_t max_size);
22
23/// @brief Compresses the string using the specified compression level.
24std::string Compress(std::string_view data, int compression_level = kDefaultCompressionLevel);
25
26} // namespace compression::zstd
27
28USERVER_NAMESPACE_END