grpcio_proto/
proto.rs

1// Copyright 2022 TiKV Project Authors. Licensed under Apache-2.0.
2
3#[cfg(feature = "prost-codec")]
4pub mod prost {
5    pub mod example {
6        pub mod helloworld;
7        pub mod routeguide;
8    }
9    pub mod google {
10        pub mod rpc {
11            #[path = "google.rpc.rs"]
12            mod status;
13
14            pub use status::*;
15        }
16    }
17    #[path = "testing/grpc.testing.rs"]
18    pub mod testing;
19
20    use testing::*;
21
22    impl Mark {
23        fn default_instance() -> &'static Mark {
24            static MARK: Mark = Mark { reset: false };
25            &MARK
26        }
27    }
28
29    impl ClientConfig {
30        fn default_instance() -> &'static ClientConfig {
31            static CLIENT_CONFIG: ClientConfig = ClientConfig {
32                server_targets: Vec::new(),
33                client_type: 0,
34                security_params: None,
35                outstanding_rpcs_per_channel: 0,
36                client_channels: 0,
37                async_client_threads: 0,
38                rpc_type: 0,
39                load_params: None,
40                payload_config: None,
41                histogram_params: None,
42                core_list: Vec::new(),
43                core_limit: 0,
44                other_client_api: String::new(),
45                channel_args: Vec::new(),
46                threads_per_cq: 0,
47                messages_per_stream: 0,
48            };
49            &CLIENT_CONFIG
50        }
51    }
52
53    impl ServerConfig {
54        fn default_instance() -> &'static ServerConfig {
55            static SERVER_CONFIG: ServerConfig = ServerConfig {
56                server_type: 0,
57                security_params: None,
58                port: 0,
59                async_server_threads: 0,
60                core_limit: 0,
61                payload_config: None,
62                core_list: Vec::new(),
63                other_server_api: String::new(),
64                threads_per_cq: 0,
65                resource_quota_size: 0,
66                channel_args: Vec::new(),
67            };
68            &SERVER_CONFIG
69        }
70    }
71
72    impl ClosedLoopParams {
73        fn default_instance() -> &'static ClosedLoopParams {
74            static CLOSED_LOOP_PARAMS: ClosedLoopParams = ClosedLoopParams {};
75            &CLOSED_LOOP_PARAMS
76        }
77    }
78
79    impl PoissonParams {
80        fn default_instance() -> &'static PoissonParams {
81            static POISSON_PARAMS: PoissonParams = PoissonParams { offered_load: 0f64 };
82            &POISSON_PARAMS
83        }
84    }
85
86    impl SimpleProtoParams {
87        fn default_instance() -> &'static SimpleProtoParams {
88            static SIMPLE_PROTO_PARAMS: SimpleProtoParams = SimpleProtoParams {
89                req_size: 0,
90                resp_size: 0,
91            };
92            &SIMPLE_PROTO_PARAMS
93        }
94    }
95
96    impl ByteBufferParams {
97        fn default_instance() -> &'static ByteBufferParams {
98            static BYTE_BUFFER_PARAMS: ByteBufferParams = ByteBufferParams {
99                req_size: 0,
100                resp_size: 0,
101            };
102            &BYTE_BUFFER_PARAMS
103        }
104    }
105
106    // Wrapper functions for oneof fields.
107    impl ClientArgs {
108        pub fn get_mark(&self) -> &Mark {
109            match &self.argtype {
110                ::std::option::Option::Some(client_args::Argtype::Mark(v)) => v,
111                _ => Mark::default_instance(),
112            }
113        }
114        pub fn get_setup(&self) -> &ClientConfig {
115            match &self.argtype {
116                ::std::option::Option::Some(client_args::Argtype::Setup(v)) => v,
117                _ => ClientConfig::default_instance(),
118            }
119        }
120    }
121    impl ServerArgs {
122        pub fn get_mark(&self) -> &Mark {
123            match &self.argtype {
124                ::std::option::Option::Some(server_args::Argtype::Mark(v)) => v,
125                _ => Mark::default_instance(),
126            }
127        }
128        pub fn get_setup(&self) -> &ServerConfig {
129            match &self.argtype {
130                ::std::option::Option::Some(server_args::Argtype::Setup(v)) => v,
131                _ => ServerConfig::default_instance(),
132            }
133        }
134    }
135    impl ChannelArg {
136        pub fn get_str_value(&self) -> &str {
137            match &self.value {
138                ::std::option::Option::Some(channel_arg::Value::StrValue(v)) => v,
139                _ => "",
140            }
141        }
142        pub fn get_int_value(&self) -> i32 {
143            match self.value {
144                ::std::option::Option::Some(channel_arg::Value::IntValue(v)) => v,
145                _ => 0,
146            }
147        }
148        pub fn has_str_value(&self) -> bool {
149            match self.value {
150                ::std::option::Option::Some(channel_arg::Value::StrValue(_)) => true,
151                _ => false,
152            }
153        }
154        pub fn has_int_value(&self) -> bool {
155            match self.value {
156                ::std::option::Option::Some(channel_arg::Value::IntValue(_)) => true,
157                _ => false,
158            }
159        }
160    }
161    impl LoadParams {
162        pub fn get_closed_loop(&self) -> &ClosedLoopParams {
163            match &self.load {
164                ::std::option::Option::Some(load_params::Load::ClosedLoop(v)) => v,
165                _ => ClosedLoopParams::default_instance(),
166            }
167        }
168        pub fn get_poisson(&self) -> &PoissonParams {
169            match &self.load {
170                ::std::option::Option::Some(load_params::Load::Poisson(v)) => v,
171                _ => PoissonParams::default_instance(),
172            }
173        }
174        pub fn has_poisson(&self) -> bool {
175            match self.load {
176                ::std::option::Option::Some(load_params::Load::Poisson(_)) => true,
177                _ => false,
178            }
179        }
180    }
181    impl PayloadConfig {
182        pub fn get_simple_params(&self) -> &SimpleProtoParams {
183            match &self.payload {
184                ::std::option::Option::Some(payload_config::Payload::SimpleParams(v)) => v,
185                _ => SimpleProtoParams::default_instance(),
186            }
187        }
188        pub fn get_bytebuf_params(&self) -> &ByteBufferParams {
189            match &self.payload {
190                ::std::option::Option::Some(payload_config::Payload::BytebufParams(v)) => v,
191                _ => ByteBufferParams::default_instance(),
192            }
193        }
194        pub fn has_bytebuf_params(&self) -> bool {
195            match self.payload {
196                ::std::option::Option::Some(payload_config::Payload::BytebufParams(_)) => true,
197                _ => false,
198            }
199        }
200    }
201}
202
203#[cfg(any(feature = "protobuf-codec", feature = "protobufv3-codec"))]
204#[cfg_attr(feature = "protobuf-codec", path = "proto/protobuf")]
205#[cfg_attr(feature = "protobufv3-codec", path = "proto/protobuf_v3")]
206#[allow(deprecated)]
207pub mod protobuf {
208    pub mod example {
209        pub mod helloworld;
210        pub mod helloworld_grpc;
211
212        pub mod route_guide;
213        pub mod route_guide_grpc;
214    }
215    pub mod google {
216        pub mod rpc {
217            pub mod status;
218
219            pub use status::*;
220        }
221    }
222    pub mod testing {
223        pub mod control;
224        pub mod empty;
225        pub mod messages;
226        pub mod payloads;
227        pub mod services;
228        pub mod services_grpc;
229        pub mod stats;
230        pub mod test;
231        pub mod test_grpc;
232    }
233}