diff options
Diffstat (limited to 'include/grpc++/byte_buffer.h')
-rw-r--r-- | include/grpc++/byte_buffer.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/include/grpc++/byte_buffer.h b/include/grpc++/byte_buffer.h index ceb62622fd..5f419764a5 100644 --- a/include/grpc++/byte_buffer.h +++ b/include/grpc++/byte_buffer.h @@ -38,6 +38,8 @@ #include <grpc/support/log.h> #include <grpc++/config.h> #include <grpc++/slice.h> +#include <grpc++/status.h> +#include <grpc++/impl/serialization_traits.h> #include <vector> @@ -61,7 +63,10 @@ class ByteBuffer GRPC_FINAL { size_t Length(); private: - friend class CallOpBuffer; + friend class SerializationTraits<ByteBuffer, void>; + + ByteBuffer(const ByteBuffer&); + ByteBuffer& operator=(const ByteBuffer&); // takes ownership void set_buffer(grpc_byte_buffer* buf) { @@ -77,6 +82,22 @@ class ByteBuffer GRPC_FINAL { grpc_byte_buffer* buffer_; }; +template <> +class SerializationTraits<ByteBuffer, void> { + public: + static Status Deserialize(grpc_byte_buffer* byte_buffer, ByteBuffer* dest, + int max_message_size) { + dest->set_buffer(byte_buffer); + return Status::OK; + } + static bool Serialize(const ByteBuffer& source, grpc_byte_buffer** buffer, + bool* own_buffer) { + *buffer = source.buffer(); + *own_buffer = false; + return true; + } +}; + } // namespace grpc #endif // GRPCXX_BYTE_BUFFER_H |