| 78 | } |
| 79 | |
| 80 | bool ParseFromCompressedData(const butil::IOBuf& data, |
| 81 | google::protobuf::Message* msg, |
| 82 | CompressType compress_type) { |
| 83 | if (compress_type == COMPRESS_TYPE_NONE) { |
| 84 | return ParsePbFromIOBuf(msg, data); |
| 85 | } |
| 86 | const CompressHandler* handler = FindCompressHandler(compress_type); |
| 87 | if (NULL == handler) { |
| 88 | return false; |
| 89 | } |
| 90 | |
| 91 | Deserializer deserializer([msg](google::protobuf::io::ZeroCopyInputStream* input) { |
| 92 | return msg->ParseFromZeroCopyStream(input); |
| 93 | }); |
| 94 | return handler->Decompress(data, &deserializer); |
| 95 | } |
| 96 | |
| 97 | bool SerializeAsCompressedData(const google::protobuf::Message& msg, |
| 98 | butil::IOBuf* buf, CompressType compress_type) { |
no test coverage detected