forked from trpc-group/trpc-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompressor.cc
36 lines (29 loc) · 1008 Bytes
/
compressor.cc
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
34
35
36
//
//
// Tencent is pleased to support the open source community by making tRPC available.
//
// Copyright (C) 2023 THL A29 Limited, a Tencent company.
// All rights reserved.
//
// If you have downloaded a copy of the tRPC source code from Tencent,
// please note that tRPC source code is licensed under the Apache 2.0 License,
// A copy of the Apache 2.0 License is included in this file.
//
//
#include "trpc/compressor/compressor.h"
#include <limits>
namespace trpc::compressor {
uint64_t Compressor::MaxUncompressedLength() const { return std::numeric_limits<uint64_t>::max(); }
bool Compressor::Compress(const NoncontiguousBuffer& in, NoncontiguousBuffer& out, LevelType level) {
if (in.ByteSize() <= MaxUncompressedLength()) {
return DoCompress(in, out, level);
}
return false;
}
bool Compressor::Decompress(const NoncontiguousBuffer& in, NoncontiguousBuffer& out) {
if (in.ByteSize() > 0) {
return DoDecompress(in, out);
}
return false;
}
} // namespace trpc::compressor