GRPC Core  9.0.0
Functions | Variables
stream_compression.cc File Reference
#include <grpc/support/port_platform.h>
#include <grpc/support/log.h>
#include "src/core/lib/compression/stream_compression.h"
#include "src/core/lib/compression/stream_compression_gzip.h"
#include "src/core/lib/slice/slice_utils.h"

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...
 

Variables

const grpc_stream_compression_vtable grpc_stream_compression_identity_vtable
 

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.

Variable Documentation

◆ grpc_stream_compression_identity_vtable

const grpc_stream_compression_vtable grpc_stream_compression_identity_vtable