diff options
author | David Garcia Quintas <dgq@google.com> | 2015-06-08 16:31:19 -0700 |
---|---|---|
committer | David Garcia Quintas <dgq@google.com> | 2015-06-08 20:06:17 -0700 |
commit | 59f905d79a109644a0d1f3ec73f34cbae65448fc (patch) | |
tree | 9ca4e84a195b4a8d8332d24362bc6828c74d4dea /include/grpc/byte_buffer.h | |
parent | 237443faa49dce1ba4df2d74000acef2802b3bdd (diff) |
Changes to byte_buffer based on comments.
Diffstat (limited to 'include/grpc/byte_buffer.h')
-rw-r--r-- | include/grpc/byte_buffer.h | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/include/grpc/byte_buffer.h b/include/grpc/byte_buffer.h index eb9608a14e..6d08474d8c 100644 --- a/include/grpc/byte_buffer.h +++ b/include/grpc/byte_buffer.h @@ -34,45 +34,44 @@ #ifndef GRPC_BYTE_BUFFER_H #define GRPC_BYTE_BUFFER_H +#include <grpc/compression.h> #include <grpc/support/slice_buffer.h> -typedef enum { - GRPC_BB_SLICE_BUFFER, +#ifdef __cplusplus +extern "C" { +#endif - /* Keep the GRPC_BB_COMPRESSED_* entries in the same order as the - * grpc_compression_algorithm enum entries. */ - GRPC_BB_COMPRESSED_NONE, /* for overriding otherwise compressed channels */ - GRPC_BB_COMPRESSED_DEFLATE, - GRPC_BB_COMPRESSED_GZIP +typedef enum { + GRPC_BB_RAW + /* Future types may include GRPC_BB_PROTOBUF, etc. */ } grpc_byte_buffer_type; -/* byte buffers are containers for messages passed in from the public api's */ struct grpc_byte_buffer { grpc_byte_buffer_type type; union { - gpr_slice_buffer slice_buffer; + struct { + grpc_compression_algorithm compression; + gpr_slice_buffer slice_buffer; + } raw; } data; }; typedef struct grpc_byte_buffer grpc_byte_buffer; -/** Returns the grpc_compression_algorithm enum value for a - * grpc_byte_buffer_type GRPC_BB_COMPRESSED_* value. */ -#define GRPC_COMPRESS_ALGORITHM_FROM_BB_TYPE(bb_type) \ - (bb_type - GRPC_BB_COMPRESSED_NONE) - -/** Returns a byte buffer instance over the given slices (up to \a nslices) of - * \a type type. +/** Returns a RAW byte buffer instance over the given slices (up to \a nslices). * - * Increases the reference count for all \a slices processed. + * Increases the reference count for all \a slices processed. The user is + * responsible for invoking grpc_byte_buffer_destroy on the returned instance.*/ +grpc_byte_buffer *grpc_raw_byte_buffer_create(gpr_slice *slices, + size_t nslices); + +/** Returns a *compressed* RAW byte buffer instance over the given slices (up to + * \a nslices). The \a compression argument defines the compression algorithm + * used to generate the data in \a slices. * - * The user is responsible for invoking grpc_byte_buffer_destroy on - * the returned instance. */ -grpc_byte_buffer *grpc_byte_buffer_typed_create(gpr_slice *slices, - size_t nslices, - grpc_byte_buffer_type type); -/** Convenience method for creating GRPC_BB_SLICE_BUFFER byte buffers. \sa - * grpc_byte_buffer_typed_create */ -grpc_byte_buffer *grpc_byte_buffer_create(gpr_slice *slices, size_t nslices); + * Increases the reference count for all \a slices processed. The user is + * responsible for invoking grpc_byte_buffer_destroy on the returned instance.*/ +grpc_byte_buffer *grpc_raw_compressed_byte_buffer_create( + gpr_slice *slices, size_t nslices, grpc_compression_algorithm compression); /** Copies input byte buffer \a bb. * @@ -104,4 +103,8 @@ void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader); int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader, gpr_slice *slice); +#ifdef __cplusplus +} +#endif + #endif /* GRPC_BYTE_BUFFER_H */ |