GRPC C++  1.39.1
compression_internal.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_COMPRESSION_INTERNAL_H
20 #define GRPC_CORE_LIB_COMPRESSION_COMPRESSION_INTERNAL_H
21 
23 
24 #include <grpc/compression.h>
25 #include <grpc/slice.h>
26 
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 typedef enum {
37  /* TODO(ctiller): snappy */
40 
42 typedef enum {
47 
48 /* Interfaces performing transformation between compression algorithms and
49  * levels. */
50 
54 
58 
59 uint32_t grpc_compression_bitset_to_message_bitset(uint32_t bitset);
60 
61 uint32_t grpc_compression_bitset_to_stream_bitset(uint32_t bitset);
62 
64  uint32_t message_bitset, uint32_t stream_bitset);
65 
67  grpc_compression_algorithm* algorithm,
68  grpc_message_compression_algorithm message_algorithm,
69  grpc_stream_compression_algorithm stream_algorithm);
70 
71 /* Interfaces for message compression. */
72 
74  grpc_message_compression_algorithm algorithm, const char** name);
75 
77  grpc_compression_level level, uint32_t accepted_encodings);
78 
81 
82 /* Interfaces for stream compression. */
83 
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
92  const grpc_compression_options* opts,
93  grpc_compression_algorithm algorithm) {
94  return GPR_BITGET(opts->enabled_algorithms_bitset, algorithm);
95 }
96 
97 #endif /* GRPC_CORE_LIB_COMPRESSION_COMPRESSION_INTERNAL_H */
grpc_message_compression_algorithm
Definition: compression_internal.h:33
@ GRPC_MESSAGE_COMPRESS_NONE
Definition: compression_internal.h:34
@ GRPC_MESSAGE_COMPRESS_DEFLATE
Definition: compression_internal.h:35
@ GRPC_MESSAGE_COMPRESS_GZIP
Definition: compression_internal.h:36
@ GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT
Definition: compression_internal.h:38
int grpc_message_compression_algorithm_name(grpc_message_compression_algorithm algorithm, const char **name)
Definition: compression_internal.cc:176
int grpc_compression_algorithm_from_message_stream_compression_algorithm(grpc_compression_algorithm *algorithm, grpc_message_compression_algorithm message_algorithm, grpc_stream_compression_algorithm stream_algorithm)
Definition: compression_internal.cc:134
grpc_message_compression_algorithm grpc_message_compression_algorithm_for_level(grpc_compression_level level, uint32_t accepted_encodings)
Definition: compression_internal.cc:199
grpc_stream_compression_algorithm
Stream compression algorithms supported by gRPC.
Definition: compression_internal.h:42
@ GRPC_STREAM_COMPRESS_GZIP
Definition: compression_internal.h:44
@ GRPC_STREAM_COMPRESS_NONE
Definition: compression_internal.h:43
@ GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT
Definition: compression_internal.h:45
grpc_message_compression_algorithm grpc_compression_algorithm_to_message_compression_algorithm(grpc_compression_algorithm algo)
Definition: compression_internal.cc:91
int grpc_stream_compression_algorithm_parse(grpc_slice value, grpc_stream_compression_algorithm *algorithm)
Definition: compression_internal.cc:273
grpc_stream_compression_algorithm grpc_compression_algorithm_to_stream_compression_algorithm(grpc_compression_algorithm algo)
Definition: compression_internal.cc:104
int grpc_message_compression_algorithm_parse(grpc_slice value, grpc_message_compression_algorithm *algorithm)
Definition: compression_internal.cc:254
uint32_t grpc_compression_bitset_to_stream_bitset(uint32_t bitset)
Definition: compression_internal.cc:118
uint32_t grpc_compression_bitset_to_message_bitset(uint32_t bitset)
Definition: compression_internal.cc:114
int grpc_compression_options_is_algorithm_enabled_internal(const grpc_compression_options *opts, grpc_compression_algorithm algorithm)
Definition: compression_internal.h:91
uint32_t grpc_compression_bitset_from_message_stream_compression_bitset(uint32_t message_bitset, uint32_t stream_bitset)
Definition: compression_internal.cc:126
grpc_compression_level
Compression levels allow a party with knowledge of its peer's accepted encodings to request compressi...
Definition: compression_types.h:71
grpc_compression_algorithm
The various compression algorithms supported by gRPC (not sorted by compression level)
Definition: compression_types.h:57
Definition: compression_types.h:79
uint32_t enabled_algorithms_bitset
All algs are enabled by default.
Definition: compression_types.h:83
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60
#define GPR_BITGET(i, n)
Get the n-th bit of i.
Definition: useful.h:47