GRPC Core  18.0.0
stream_compression.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2017 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_LIB_COMPRESSION_STREAM_COMPRESSION_H
20 #define GRPC_CORE_LIB_COMPRESSION_STREAM_COMPRESSION_H
21 
23 
24 #include <stdbool.h>
25 
26 #include <grpc/slice_buffer.h>
27 #include <zlib.h>
28 
30 
32 
33 /* Stream compression/decompression context */
37 
45 
52 
55  grpc_slice_buffer* out, size_t* output_size,
56  size_t max_output_size, grpc_stream_compression_flush flush);
59  size_t* output_size, size_t max_output_size,
60  bool* end_of_context);
61  grpc_stream_compression_context* (*context_create)(
64 };
65 
81  size_t* output_size, size_t max_output_size,
83 
93  size_t* output_size, size_t max_output_size,
94  bool* end_of_context);
95 
103 
109 
114  grpc_slice value, bool is_compress, grpc_stream_compression_method* method);
115 
116 #endif
struct grpc_stream_compression_context grpc_stream_compression_context
grpc_stream_compression_method
Definition: stream_compression.h:38
@ GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS
Definition: stream_compression.h:40
@ GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS
Definition: stream_compression.h:42
@ GRPC_STREAM_COMPRESSION_METHOD_COUNT
Definition: stream_compression.h:43
@ GRPC_STREAM_COMPRESSION_GZIP_COMPRESS
Definition: stream_compression.h:41
@ GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS
Definition: stream_compression.h:39
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.
Definition: stream_compression.cc:30
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.
Definition: stream_compression.cc:66
void grpc_stream_compression_context_destroy(grpc_stream_compression_context *ctx)
Destroys a stream compression context.
Definition: stream_compression.cc:61
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.
Definition: stream_compression.cc:38
grpc_stream_compression_flush
Definition: stream_compression.h:46
@ GRPC_STREAM_COMPRESSION_FLUSH_COUNT
Definition: stream_compression.h:50
@ GRPC_STREAM_COMPRESSION_FLUSH_NONE
Definition: stream_compression.h:47
@ GRPC_STREAM_COMPRESSION_FLUSH_FINISH
Definition: stream_compression.h:49
@ GRPC_STREAM_COMPRESSION_FLUSH_SYNC
Definition: stream_compression.h:48
grpc_stream_compression_context * grpc_stream_compression_context_create(grpc_stream_compression_method method)
Creates a stream compression context.
Definition: stream_compression.cc:46
Represents an expandable array of slices, to be interpreted as a single item.
Definition: slice.h:78
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60
Definition: stream_compression.h:34
const grpc_stream_compression_vtable * vtable
Definition: stream_compression.h:35
Definition: stream_compression.h:53
void(* context_destroy)(grpc_stream_compression_context *ctx)
Definition: stream_compression.h:63
bool(* 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)
Definition: stream_compression.h:54
bool(* 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)
Definition: stream_compression.h:57