Add MessageLite overloads to proto serialization

pull/19091/head
kwasimensah 6 years ago committed by GitHub
parent 12ffbb8a83
commit 51a2280029
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      include/grpcpp/impl/codegen/proto_utils.h

@ -42,7 +42,7 @@ extern CoreCodegenInterface* g_core_codegen_interface;
// ProtoBufferWriter must be a subclass of ::protobuf::io::ZeroCopyOutputStream.
template <class ProtoBufferWriter, class T>
Status GenericSerialize(const grpc::protobuf::Message& msg, ByteBuffer* bb,
Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb,
bool* own_buffer) {
static_assert(std::is_base_of<protobuf::io::ZeroCopyOutputStream,
ProtoBufferWriter>::value,
@ -68,7 +68,7 @@ Status GenericSerialize(const grpc::protobuf::Message& msg, ByteBuffer* bb,
// BufferReader must be a subclass of ::protobuf::io::ZeroCopyInputStream.
template <class ProtoBufferReader, class T>
Status GenericDeserialize(ByteBuffer* buffer, grpc::protobuf::Message* msg) {
Status GenericDeserialize(ByteBuffer* buffer, grpc::protobuf::MessageLite* msg) {
static_assert(std::is_base_of<protobuf::io::ZeroCopyInputStream,
ProtoBufferReader>::value,
"ProtoBufferReader must be a subclass of "
@ -103,14 +103,14 @@ Status GenericDeserialize(ByteBuffer* buffer, grpc::protobuf::Message* msg) {
// be found in include/grpcpp/impl/codegen/serialization_traits.h.
template <class T>
class SerializationTraits<T, typename std::enable_if<std::is_base_of<
grpc::protobuf::Message, T>::value>::type> {
grpc::protobuf::MessageLite, T>::value>::type> {
public:
static Status Serialize(const grpc::protobuf::Message& msg, ByteBuffer* bb,
static Status Serialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb,
bool* own_buffer) {
return GenericSerialize<ProtoBufferWriter, T>(msg, bb, own_buffer);
}
static Status Deserialize(ByteBuffer* buffer, grpc::protobuf::Message* msg) {
static Status Deserialize(ByteBuffer* buffer, grpc::protobuf::MessageLite* msg) {
return GenericDeserialize<ProtoBufferReader, T>(buffer, msg);
}
};

Loading…
Cancel
Save