GRPC Core  9.0.0
Data Structures | Typedefs | Enumerations | Functions
stream_compression.h File Reference
#include <grpc/support/port_platform.h>
#include <stdbool.h>
#include <grpc/slice_buffer.h>
#include <zlib.h>
#include "src/core/lib/transport/static_metadata.h"

Go to the source code of this file.

Data Structures

struct  grpc_stream_compression_context
 
struct  grpc_stream_compression_vtable
 

Typedefs

typedef struct grpc_stream_compression_vtable grpc_stream_compression_vtable
 
typedef struct grpc_stream_compression_context grpc_stream_compression_context
 
typedef enum grpc_stream_compression_method grpc_stream_compression_method
 
typedef enum grpc_stream_compression_flush grpc_stream_compression_flush
 

Enumerations

enum  grpc_stream_compression_method {
  GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS = 0, GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS, GRPC_STREAM_COMPRESSION_GZIP_COMPRESS, GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS,
  GRPC_STREAM_COMPRESSION_METHOD_COUNT
}
 
enum  grpc_stream_compression_flush { GRPC_STREAM_COMPRESSION_FLUSH_NONE = 0, GRPC_STREAM_COMPRESSION_FLUSH_SYNC, GRPC_STREAM_COMPRESSION_FLUSH_FINISH, GRPC_STREAM_COMPRESSION_FLUSH_COUNT }
 

Functions

bool grpc_stream_compress (grpc_stream_compression_context *ctx, grpc_slice_buffer *in, grpc_slice_buffer *out, size_t *output_size, size_t max_output_size, grpc_stream_compression_flush flush)
 Compress bytes provided in in with a given context, with an optional flush at the end of compression. More...
 
bool grpc_stream_decompress (grpc_stream_compression_context *ctx, grpc_slice_buffer *in, grpc_slice_buffer *out, size_t *output_size, size_t max_output_size, bool *end_of_context)
 Decompress bytes provided in in with a given context. More...
 
grpc_stream_compression_contextgrpc_stream_compression_context_create (grpc_stream_compression_method method)
 Creates a stream compression context. More...
 
void grpc_stream_compression_context_destroy (grpc_stream_compression_context *ctx)
 Destroys a stream compression context. More...
 
int grpc_stream_compression_method_parse (grpc_slice value, bool is_compress, grpc_stream_compression_method *method)
 Parse stream compression method based on algorithm name. More...
 

Typedef Documentation

◆ grpc_stream_compression_context

◆ grpc_stream_compression_flush

◆ grpc_stream_compression_method

◆ grpc_stream_compression_vtable

Enumeration Type Documentation

◆ grpc_stream_compression_flush

Enumerator
GRPC_STREAM_COMPRESSION_FLUSH_NONE 
GRPC_STREAM_COMPRESSION_FLUSH_SYNC 
GRPC_STREAM_COMPRESSION_FLUSH_FINISH 
GRPC_STREAM_COMPRESSION_FLUSH_COUNT 

◆ grpc_stream_compression_method

Enumerator
GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS 
GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS 
GRPC_STREAM_COMPRESSION_GZIP_COMPRESS 
GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS 
GRPC_STREAM_COMPRESSION_METHOD_COUNT 

Function Documentation

◆ grpc_stream_compress()

bool grpc_stream_compress ( grpc_stream_compression_context ctx,
grpc_slice_buffer in,
grpc_slice_buffer out,
size_t *  output_size,
size_t  max_output_size,
grpc_stream_compression_flush  flush 
)

Compress bytes provided in in with a given context, with an optional flush at the end of compression.

Emits at most max_output_size compressed bytes into out. If all the bytes in input buffer in are depleted and flush is not GRPC_STREAM_COMPRESSION_FLUSH_NONE, the corresponding flush method is executed. The total number of bytes emitted is outputted in output_size.

A SYNC flush indicates that the entire messages in in can be decompressed from out. A FINISH flush implies a SYNC flush, and that any further compression will not be dependent on the state of the current context and any previous compressed bytes. It allows corresponding decompression context to be dropped when reaching this boundary.

◆ grpc_stream_compression_context_create()

grpc_stream_compression_context* grpc_stream_compression_context_create ( grpc_stream_compression_method  method)

Creates a stream compression context.

pending_bytes_buffer is the input buffer for compression/decompression operations. method specifies whether the context is for compression or decompression.

◆ grpc_stream_compression_context_destroy()

void grpc_stream_compression_context_destroy ( grpc_stream_compression_context ctx)

Destroys a stream compression context.

◆ grpc_stream_compression_method_parse()

int grpc_stream_compression_method_parse ( grpc_slice  value,
bool  is_compress,
grpc_stream_compression_method method 
)

Parse stream compression method based on algorithm name.

◆ grpc_stream_decompress()

bool grpc_stream_decompress ( grpc_stream_compression_context ctx,
grpc_slice_buffer in,
grpc_slice_buffer out,
size_t *  output_size,
size_t  max_output_size,
bool *  end_of_context 
)

Decompress bytes provided in in with a given context.

Emits at most max_output_size decompressed bytes into out. If decompression process reached the end of a gzip stream, end_of_context is set to true; otherwise it is set to false. The total number of bytes emitted is outputted in output_size.