10#include "ll/api/Expected.h"
11#include "ll/api/base/Macro.h"
13namespace ll::inline utils::compress_utils {
15enum class CompressFormat :
int {
20enum class CompressLevel :
int {
27LLNDAPI std::string_view extensionOf(CompressFormat format);
29using SinkFn = std::function<Expected<>(std::string_view)>;
33 std::unique_ptr<Impl> impl;
37 Compressor(SinkFn sink, CompressFormat format = CompressFormat::Gzip, CompressLevel level = CompressLevel::Default);
41 LLAPI Compressor(Compressor&&)
noexcept;
42 LLAPI Compressor& operator=(Compressor&&)
noexcept;
44 LLNDAPI Expected<> status()
const;
46 LLAPI Expected<> write(std::string_view data);
48 LLAPI Expected<> finish();
53 std::unique_ptr<Impl> impl;
56 LLAPI Decompressor(SinkFn sink, CompressFormat format = CompressFormat::Gzip);
58 LLAPI ~Decompressor();
60 LLAPI Decompressor(Decompressor&&)
noexcept;
61 LLAPI Decompressor& operator=(Decompressor&&)
noexcept;
63 LLNDAPI Expected<> status()
const;
65 LLAPI Expected<> write(std::string_view data);
67 LLAPI Expected<> finish();
70LLNDAPI Expected<std::string> compress(
71 std::string_view data,
72 CompressFormat format = CompressFormat::Gzip,
73 CompressLevel level = CompressLevel::Default
76LLNDAPI Expected<std::string>
77 decompress(std::string_view data, CompressFormat format = CompressFormat::Gzip,
size_t maxSize = 0);
79LLNDAPI Expected<> compressFile(
80 std::filesystem::path
const& src,
81 std::filesystem::path
const& dst,
82 CompressFormat format = CompressFormat::Gzip,
83 CompressLevel level = CompressLevel::Default
86LLNDAPI Expected<> decompressFile(
87 std::filesystem::path
const& src,
88 std::filesystem::path
const& dst,
89 CompressFormat format = CompressFormat::Gzip