generic encapsulator

This commit is contained in:
2025-02-27 22:50:51 +01:00
parent f6620dc522
commit 9fa023f716
5 changed files with 96 additions and 38 deletions

View File

@@ -11,10 +11,17 @@
namespace sp {
namespace option {
struct ZlibCompress {};
struct ZlibCompress {
bool m_Enabled = true;
std::size_t m_CompressionThreshold = 64;
};
} // namespace option
} // namespace sp
#include <sp/io/IOInterface.h>
namespace sp {
namespace zlib {
/**
@@ -33,4 +40,15 @@ DataBuffer Compress(const DataBuffer& buffer, std::size_t a_CompressionThreshold
DataBuffer Decompress(DataBuffer& buffer, std::uint64_t packetLength);
} // namespace zlib
namespace io {
template <>
class MessageEncapsulator<option::ZlibCompress> {
public:
static DataBuffer Encapsulate(const DataBuffer& a_Data, const option::ZlibCompress& a_Option);
static DataBuffer Decapsulate(DataBuffer& a_Data, std::size_t a_Length, const option::ZlibCompress& a_Option);
};
} // namespace io
} // namespace sp