1pub mod user_service_client {
4 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
5 use tonic::codegen::*;
6 use tonic::codegen::http::Uri;
7 #[derive(Debug, Clone)]
8 pub struct UserServiceClient<T> {
9 inner: tonic::client::Grpc<T>,
10 }
11 impl UserServiceClient<tonic::transport::Channel> {
12 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
14 where
15 D: TryInto<tonic::transport::Endpoint>,
16 D::Error: Into<StdError>,
17 {
18 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
19 Ok(Self::new(conn))
20 }
21 }
22 impl<T> UserServiceClient<T>
23 where
24 T: tonic::client::GrpcService<tonic::body::BoxBody>,
25 T::Error: Into<StdError>,
26 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
27 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
28 {
29 pub fn new(inner: T) -> Self {
30 let inner = tonic::client::Grpc::new(inner);
31 Self { inner }
32 }
33 pub fn with_origin(inner: T, origin: Uri) -> Self {
34 let inner = tonic::client::Grpc::with_origin(inner, origin);
35 Self { inner }
36 }
37 pub fn with_interceptor<F>(
38 inner: T,
39 interceptor: F,
40 ) -> UserServiceClient<InterceptedService<T, F>>
41 where
42 F: tonic::service::Interceptor,
43 T::ResponseBody: Default,
44 T: tonic::codegen::Service<
45 http::Request<tonic::body::BoxBody>,
46 Response = http::Response<
47 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
48 >,
49 >,
50 <T as tonic::codegen::Service<
51 http::Request<tonic::body::BoxBody>,
52 >>::Error: Into<StdError> + Send + Sync,
53 {
54 UserServiceClient::new(InterceptedService::new(inner, interceptor))
55 }
56 #[must_use]
61 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
62 self.inner = self.inner.send_compressed(encoding);
63 self
64 }
65 #[must_use]
67 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
68 self.inner = self.inner.accept_compressed(encoding);
69 self
70 }
71 #[must_use]
75 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
76 self.inner = self.inner.max_decoding_message_size(limit);
77 self
78 }
79 #[must_use]
83 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
84 self.inner = self.inner.max_encoding_message_size(limit);
85 self
86 }
87 pub async fn get_me(
88 &mut self,
89 request: impl tonic::IntoRequest<()>,
90 ) -> std::result::Result<tonic::Response<super::User>, tonic::Status> {
91 self.inner
92 .ready()
93 .await
94 .map_err(|e| {
95 tonic::Status::new(
96 tonic::Code::Unknown,
97 format!("Service was not ready: {}", e.into()),
98 )
99 })?;
100 let codec = tonic::codec::ProstCodec::default();
101 let path = http::uri::PathAndQuery::from_static(
102 "/kdo.v1.user.UserService/GetMe",
103 );
104 let mut req = request.into_request();
105 req.extensions_mut()
106 .insert(GrpcMethod::new("kdo.v1.user.UserService", "GetMe"));
107 self.inner.unary(req, path, codec).await
108 }
109 pub async fn get_user(
110 &mut self,
111 request: impl tonic::IntoRequest<super::GetUserRequest>,
112 ) -> std::result::Result<tonic::Response<super::User>, tonic::Status> {
113 self.inner
114 .ready()
115 .await
116 .map_err(|e| {
117 tonic::Status::new(
118 tonic::Code::Unknown,
119 format!("Service was not ready: {}", e.into()),
120 )
121 })?;
122 let codec = tonic::codec::ProstCodec::default();
123 let path = http::uri::PathAndQuery::from_static(
124 "/kdo.v1.user.UserService/GetUser",
125 );
126 let mut req = request.into_request();
127 req.extensions_mut()
128 .insert(GrpcMethod::new("kdo.v1.user.UserService", "GetUser"));
129 self.inner.unary(req, path, codec).await
130 }
131 pub async fn list_users(
132 &mut self,
133 request: impl tonic::IntoRequest<super::ListUsersRequest>,
134 ) -> std::result::Result<
135 tonic::Response<super::ListUsersResponse>,
136 tonic::Status,
137 > {
138 self.inner
139 .ready()
140 .await
141 .map_err(|e| {
142 tonic::Status::new(
143 tonic::Code::Unknown,
144 format!("Service was not ready: {}", e.into()),
145 )
146 })?;
147 let codec = tonic::codec::ProstCodec::default();
148 let path = http::uri::PathAndQuery::from_static(
149 "/kdo.v1.user.UserService/ListUsers",
150 );
151 let mut req = request.into_request();
152 req.extensions_mut()
153 .insert(GrpcMethod::new("kdo.v1.user.UserService", "ListUsers"));
154 self.inner.unary(req, path, codec).await
155 }
156 }
157}
158pub mod user_service_server {
160 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
161 use tonic::codegen::*;
162 #[async_trait]
164 pub trait UserService: Send + Sync + 'static {
165 async fn get_me(
166 &self,
167 request: tonic::Request<()>,
168 ) -> std::result::Result<tonic::Response<super::User>, tonic::Status>;
169 async fn get_user(
170 &self,
171 request: tonic::Request<super::GetUserRequest>,
172 ) -> std::result::Result<tonic::Response<super::User>, tonic::Status>;
173 async fn list_users(
174 &self,
175 request: tonic::Request<super::ListUsersRequest>,
176 ) -> std::result::Result<
177 tonic::Response<super::ListUsersResponse>,
178 tonic::Status,
179 >;
180 }
181 #[derive(Debug)]
182 pub struct UserServiceServer<T: UserService> {
183 inner: Arc<T>,
184 accept_compression_encodings: EnabledCompressionEncodings,
185 send_compression_encodings: EnabledCompressionEncodings,
186 max_decoding_message_size: Option<usize>,
187 max_encoding_message_size: Option<usize>,
188 }
189 impl<T: UserService> UserServiceServer<T> {
190 pub fn new(inner: T) -> Self {
191 Self::from_arc(Arc::new(inner))
192 }
193 pub fn from_arc(inner: Arc<T>) -> Self {
194 Self {
195 inner,
196 accept_compression_encodings: Default::default(),
197 send_compression_encodings: Default::default(),
198 max_decoding_message_size: None,
199 max_encoding_message_size: None,
200 }
201 }
202 pub fn with_interceptor<F>(
203 inner: T,
204 interceptor: F,
205 ) -> InterceptedService<Self, F>
206 where
207 F: tonic::service::Interceptor,
208 {
209 InterceptedService::new(Self::new(inner), interceptor)
210 }
211 #[must_use]
213 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
214 self.accept_compression_encodings.enable(encoding);
215 self
216 }
217 #[must_use]
219 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
220 self.send_compression_encodings.enable(encoding);
221 self
222 }
223 #[must_use]
227 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
228 self.max_decoding_message_size = Some(limit);
229 self
230 }
231 #[must_use]
235 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
236 self.max_encoding_message_size = Some(limit);
237 self
238 }
239 }
240 impl<T, B> tonic::codegen::Service<http::Request<B>> for UserServiceServer<T>
241 where
242 T: UserService,
243 B: Body + Send + 'static,
244 B::Error: Into<StdError> + Send + 'static,
245 {
246 type Response = http::Response<tonic::body::BoxBody>;
247 type Error = std::convert::Infallible;
248 type Future = BoxFuture<Self::Response, Self::Error>;
249 fn poll_ready(
250 &mut self,
251 _cx: &mut Context<'_>,
252 ) -> Poll<std::result::Result<(), Self::Error>> {
253 Poll::Ready(Ok(()))
254 }
255 fn call(&mut self, req: http::Request<B>) -> Self::Future {
256 match req.uri().path() {
257 "/kdo.v1.user.UserService/GetMe" => {
258 #[allow(non_camel_case_types)]
259 struct GetMeSvc<T: UserService>(pub Arc<T>);
260 impl<T: UserService> tonic::server::UnaryService<()>
261 for GetMeSvc<T> {
262 type Response = super::User;
263 type Future = BoxFuture<
264 tonic::Response<Self::Response>,
265 tonic::Status,
266 >;
267 fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
268 let inner = Arc::clone(&self.0);
269 let fut = async move {
270 <T as UserService>::get_me(&inner, request).await
271 };
272 Box::pin(fut)
273 }
274 }
275 let accept_compression_encodings = self.accept_compression_encodings;
276 let send_compression_encodings = self.send_compression_encodings;
277 let max_decoding_message_size = self.max_decoding_message_size;
278 let max_encoding_message_size = self.max_encoding_message_size;
279 let inner = self.inner.clone();
280 let fut = async move {
281 let method = GetMeSvc(inner);
282 let codec = tonic::codec::ProstCodec::default();
283 let mut grpc = tonic::server::Grpc::new(codec)
284 .apply_compression_config(
285 accept_compression_encodings,
286 send_compression_encodings,
287 )
288 .apply_max_message_size_config(
289 max_decoding_message_size,
290 max_encoding_message_size,
291 );
292 let res = grpc.unary(method, req).await;
293 Ok(res)
294 };
295 Box::pin(fut)
296 }
297 "/kdo.v1.user.UserService/GetUser" => {
298 #[allow(non_camel_case_types)]
299 struct GetUserSvc<T: UserService>(pub Arc<T>);
300 impl<
301 T: UserService,
302 > tonic::server::UnaryService<super::GetUserRequest>
303 for GetUserSvc<T> {
304 type Response = super::User;
305 type Future = BoxFuture<
306 tonic::Response<Self::Response>,
307 tonic::Status,
308 >;
309 fn call(
310 &mut self,
311 request: tonic::Request<super::GetUserRequest>,
312 ) -> Self::Future {
313 let inner = Arc::clone(&self.0);
314 let fut = async move {
315 <T as UserService>::get_user(&inner, request).await
316 };
317 Box::pin(fut)
318 }
319 }
320 let accept_compression_encodings = self.accept_compression_encodings;
321 let send_compression_encodings = self.send_compression_encodings;
322 let max_decoding_message_size = self.max_decoding_message_size;
323 let max_encoding_message_size = self.max_encoding_message_size;
324 let inner = self.inner.clone();
325 let fut = async move {
326 let method = GetUserSvc(inner);
327 let codec = tonic::codec::ProstCodec::default();
328 let mut grpc = tonic::server::Grpc::new(codec)
329 .apply_compression_config(
330 accept_compression_encodings,
331 send_compression_encodings,
332 )
333 .apply_max_message_size_config(
334 max_decoding_message_size,
335 max_encoding_message_size,
336 );
337 let res = grpc.unary(method, req).await;
338 Ok(res)
339 };
340 Box::pin(fut)
341 }
342 "/kdo.v1.user.UserService/ListUsers" => {
343 #[allow(non_camel_case_types)]
344 struct ListUsersSvc<T: UserService>(pub Arc<T>);
345 impl<
346 T: UserService,
347 > tonic::server::UnaryService<super::ListUsersRequest>
348 for ListUsersSvc<T> {
349 type Response = super::ListUsersResponse;
350 type Future = BoxFuture<
351 tonic::Response<Self::Response>,
352 tonic::Status,
353 >;
354 fn call(
355 &mut self,
356 request: tonic::Request<super::ListUsersRequest>,
357 ) -> Self::Future {
358 let inner = Arc::clone(&self.0);
359 let fut = async move {
360 <T as UserService>::list_users(&inner, request).await
361 };
362 Box::pin(fut)
363 }
364 }
365 let accept_compression_encodings = self.accept_compression_encodings;
366 let send_compression_encodings = self.send_compression_encodings;
367 let max_decoding_message_size = self.max_decoding_message_size;
368 let max_encoding_message_size = self.max_encoding_message_size;
369 let inner = self.inner.clone();
370 let fut = async move {
371 let method = ListUsersSvc(inner);
372 let codec = tonic::codec::ProstCodec::default();
373 let mut grpc = tonic::server::Grpc::new(codec)
374 .apply_compression_config(
375 accept_compression_encodings,
376 send_compression_encodings,
377 )
378 .apply_max_message_size_config(
379 max_decoding_message_size,
380 max_encoding_message_size,
381 );
382 let res = grpc.unary(method, req).await;
383 Ok(res)
384 };
385 Box::pin(fut)
386 }
387 _ => {
388 Box::pin(async move {
389 Ok(
390 http::Response::builder()
391 .status(200)
392 .header("grpc-status", tonic::Code::Unimplemented as i32)
393 .header(
394 http::header::CONTENT_TYPE,
395 tonic::metadata::GRPC_CONTENT_TYPE,
396 )
397 .body(empty_body())
398 .unwrap(),
399 )
400 })
401 }
402 }
403 }
404 }
405 impl<T: UserService> Clone for UserServiceServer<T> {
406 fn clone(&self) -> Self {
407 let inner = self.inner.clone();
408 Self {
409 inner,
410 accept_compression_encodings: self.accept_compression_encodings,
411 send_compression_encodings: self.send_compression_encodings,
412 max_decoding_message_size: self.max_decoding_message_size,
413 max_encoding_message_size: self.max_encoding_message_size,
414 }
415 }
416 }
417 impl<T: UserService> tonic::server::NamedService for UserServiceServer<T> {
418 const NAME: &'static str = "kdo.v1.user.UserService";
419 }
420}