ids_apis/
kdo.v1.fund.tonic.rs

1// @generated
2/// Generated client implementations.
3pub mod fund_service_client {
4    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
5    use tonic::codegen::http::Uri;
6    use tonic::codegen::*;
7    #[derive(Debug, Clone)]
8    pub struct FundServiceClient<T> {
9        inner: tonic::client::Grpc<T>,
10    }
11    impl FundServiceClient<tonic::transport::Channel> {
12        /// Attempt to create a new client by connecting to a given endpoint.
13        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> FundServiceClient<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        ) -> FundServiceClient<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            FundServiceClient::new(InterceptedService::new(inner, interceptor))
55        }
56        /// Compress requests with the given encoding.
57        ///
58        /// This requires the server to support it otherwise it might respond with an
59        /// error.
60        #[must_use]
61        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
62            self.inner = self.inner.send_compressed(encoding);
63            self
64        }
65        /// Enable decompressing responses.
66        #[must_use]
67        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
68            self.inner = self.inner.accept_compressed(encoding);
69            self
70        }
71        /// Limits the maximum size of a decoded message.
72        ///
73        /// Default: `4MB`
74        #[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        /// Limits the maximum size of an encoded message.
80        ///
81        /// Default: `usize::MAX`
82        #[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_fund(
88            &mut self,
89            request: impl tonic::IntoRequest<super::GetFundRequest>,
90        ) -> std::result::Result<tonic::Response<super::Fund>, 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.fund.FundService/GetFund",
103            );
104            let mut req = request.into_request();
105            req.extensions_mut()
106                .insert(GrpcMethod::new("kdo.v1.fund.FundService", "GetFund"));
107            self.inner.unary(req, path, codec).await
108        }
109        pub async fn list_funds(
110            &mut self,
111            request: impl tonic::IntoRequest<super::ListFundsRequest>,
112        ) -> std::result::Result<
113            tonic::Response<super::ListFundsResponse>,
114            tonic::Status,
115        > {
116            self.inner
117                .ready()
118                .await
119                .map_err(|e| {
120                    tonic::Status::new(
121                        tonic::Code::Unknown,
122                        format!("Service was not ready: {}", e.into()),
123                    )
124                })?;
125            let codec = tonic::codec::ProstCodec::default();
126            let path = http::uri::PathAndQuery::from_static(
127                "/kdo.v1.fund.FundService/ListFunds",
128            );
129            let mut req = request.into_request();
130            req.extensions_mut()
131                .insert(GrpcMethod::new("kdo.v1.fund.FundService", "ListFunds"));
132            self.inner.unary(req, path, codec).await
133        }
134        pub async fn stream_fund_limits(
135            &mut self,
136            request: impl tonic::IntoRequest<super::StreamFundLimitsRequest>,
137        ) -> std::result::Result<
138            tonic::Response<tonic::codec::Streaming<super::FundLimit>>,
139            tonic::Status,
140        > {
141            self.inner
142                .ready()
143                .await
144                .map_err(|e| {
145                    tonic::Status::new(
146                        tonic::Code::Unknown,
147                        format!("Service was not ready: {}", e.into()),
148                    )
149                })?;
150            let codec = tonic::codec::ProstCodec::default();
151            let path = http::uri::PathAndQuery::from_static(
152                "/kdo.v1.fund.FundService/StreamFundLimits",
153            );
154            let mut req = request.into_request();
155            req.extensions_mut()
156                .insert(GrpcMethod::new("kdo.v1.fund.FundService", "StreamFundLimits"));
157            self.inner.server_streaming(req, path, codec).await
158        }
159    }
160}
161/// Generated server implementations.
162pub mod fund_service_server {
163    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
164    use tonic::codegen::*;
165    /// Generated trait containing gRPC methods that should be implemented for use with FundServiceServer.
166    #[async_trait]
167    pub trait FundService: Send + Sync + 'static {
168        async fn get_fund(
169            &self,
170            request: tonic::Request<super::GetFundRequest>,
171        ) -> std::result::Result<tonic::Response<super::Fund>, tonic::Status>;
172        async fn list_funds(
173            &self,
174            request: tonic::Request<super::ListFundsRequest>,
175        ) -> std::result::Result<
176            tonic::Response<super::ListFundsResponse>,
177            tonic::Status,
178        >;
179        /// Server streaming response type for the StreamFundLimits method.
180        type StreamFundLimitsStream: tonic::codegen::tokio_stream::Stream<
181                Item = std::result::Result<super::FundLimit, tonic::Status>,
182            >
183            + Send
184            + 'static;
185        async fn stream_fund_limits(
186            &self,
187            request: tonic::Request<super::StreamFundLimitsRequest>,
188        ) -> std::result::Result<
189            tonic::Response<Self::StreamFundLimitsStream>,
190            tonic::Status,
191        >;
192    }
193    #[derive(Debug)]
194    pub struct FundServiceServer<T: FundService> {
195        inner: Arc<T>,
196        accept_compression_encodings: EnabledCompressionEncodings,
197        send_compression_encodings: EnabledCompressionEncodings,
198        max_decoding_message_size: Option<usize>,
199        max_encoding_message_size: Option<usize>,
200    }
201    impl<T: FundService> FundServiceServer<T> {
202        pub fn new(inner: T) -> Self {
203            Self::from_arc(Arc::new(inner))
204        }
205        pub fn from_arc(inner: Arc<T>) -> Self {
206            Self {
207                inner,
208                accept_compression_encodings: Default::default(),
209                send_compression_encodings: Default::default(),
210                max_decoding_message_size: None,
211                max_encoding_message_size: None,
212            }
213        }
214        pub fn with_interceptor<F>(
215            inner: T,
216            interceptor: F,
217        ) -> InterceptedService<Self, F>
218        where
219            F: tonic::service::Interceptor,
220        {
221            InterceptedService::new(Self::new(inner), interceptor)
222        }
223        /// Enable decompressing requests with the given encoding.
224        #[must_use]
225        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
226            self.accept_compression_encodings.enable(encoding);
227            self
228        }
229        /// Compress responses with the given encoding, if the client supports it.
230        #[must_use]
231        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
232            self.send_compression_encodings.enable(encoding);
233            self
234        }
235        /// Limits the maximum size of a decoded message.
236        ///
237        /// Default: `4MB`
238        #[must_use]
239        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
240            self.max_decoding_message_size = Some(limit);
241            self
242        }
243        /// Limits the maximum size of an encoded message.
244        ///
245        /// Default: `usize::MAX`
246        #[must_use]
247        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
248            self.max_encoding_message_size = Some(limit);
249            self
250        }
251    }
252    impl<T, B> tonic::codegen::Service<http::Request<B>> for FundServiceServer<T>
253    where
254        T: FundService,
255        B: Body + Send + 'static,
256        B::Error: Into<StdError> + Send + 'static,
257    {
258        type Response = http::Response<tonic::body::BoxBody>;
259        type Error = std::convert::Infallible;
260        type Future = BoxFuture<Self::Response, Self::Error>;
261        fn poll_ready(
262            &mut self,
263            _cx: &mut Context<'_>,
264        ) -> Poll<std::result::Result<(), Self::Error>> {
265            Poll::Ready(Ok(()))
266        }
267        fn call(&mut self, req: http::Request<B>) -> Self::Future {
268            match req.uri().path() {
269                "/kdo.v1.fund.FundService/GetFund" => {
270                    #[allow(non_camel_case_types)]
271                    struct GetFundSvc<T: FundService>(pub Arc<T>);
272                    impl<
273                        T: FundService,
274                    > tonic::server::UnaryService<super::GetFundRequest>
275                    for GetFundSvc<T> {
276                        type Response = super::Fund;
277                        type Future = BoxFuture<
278                            tonic::Response<Self::Response>,
279                            tonic::Status,
280                        >;
281                        fn call(
282                            &mut self,
283                            request: tonic::Request<super::GetFundRequest>,
284                        ) -> Self::Future {
285                            let inner = Arc::clone(&self.0);
286                            let fut = async move {
287                                <T as FundService>::get_fund(&inner, request).await
288                            };
289                            Box::pin(fut)
290                        }
291                    }
292                    let accept_compression_encodings = self.accept_compression_encodings;
293                    let send_compression_encodings = self.send_compression_encodings;
294                    let max_decoding_message_size = self.max_decoding_message_size;
295                    let max_encoding_message_size = self.max_encoding_message_size;
296                    let inner = self.inner.clone();
297                    let fut = async move {
298                        let method = GetFundSvc(inner);
299                        let codec = tonic::codec::ProstCodec::default();
300                        let mut grpc = tonic::server::Grpc::new(codec)
301                            .apply_compression_config(
302                                accept_compression_encodings,
303                                send_compression_encodings,
304                            )
305                            .apply_max_message_size_config(
306                                max_decoding_message_size,
307                                max_encoding_message_size,
308                            );
309                        let res = grpc.unary(method, req).await;
310                        Ok(res)
311                    };
312                    Box::pin(fut)
313                }
314                "/kdo.v1.fund.FundService/ListFunds" => {
315                    #[allow(non_camel_case_types)]
316                    struct ListFundsSvc<T: FundService>(pub Arc<T>);
317                    impl<
318                        T: FundService,
319                    > tonic::server::UnaryService<super::ListFundsRequest>
320                    for ListFundsSvc<T> {
321                        type Response = super::ListFundsResponse;
322                        type Future = BoxFuture<
323                            tonic::Response<Self::Response>,
324                            tonic::Status,
325                        >;
326                        fn call(
327                            &mut self,
328                            request: tonic::Request<super::ListFundsRequest>,
329                        ) -> Self::Future {
330                            let inner = Arc::clone(&self.0);
331                            let fut = async move {
332                                <T as FundService>::list_funds(&inner, request).await
333                            };
334                            Box::pin(fut)
335                        }
336                    }
337                    let accept_compression_encodings = self.accept_compression_encodings;
338                    let send_compression_encodings = self.send_compression_encodings;
339                    let max_decoding_message_size = self.max_decoding_message_size;
340                    let max_encoding_message_size = self.max_encoding_message_size;
341                    let inner = self.inner.clone();
342                    let fut = async move {
343                        let method = ListFundsSvc(inner);
344                        let codec = tonic::codec::ProstCodec::default();
345                        let mut grpc = tonic::server::Grpc::new(codec)
346                            .apply_compression_config(
347                                accept_compression_encodings,
348                                send_compression_encodings,
349                            )
350                            .apply_max_message_size_config(
351                                max_decoding_message_size,
352                                max_encoding_message_size,
353                            );
354                        let res = grpc.unary(method, req).await;
355                        Ok(res)
356                    };
357                    Box::pin(fut)
358                }
359                "/kdo.v1.fund.FundService/StreamFundLimits" => {
360                    #[allow(non_camel_case_types)]
361                    struct StreamFundLimitsSvc<T: FundService>(pub Arc<T>);
362                    impl<
363                        T: FundService,
364                    > tonic::server::ServerStreamingService<
365                        super::StreamFundLimitsRequest,
366                    > for StreamFundLimitsSvc<T> {
367                        type Response = super::FundLimit;
368                        type ResponseStream = T::StreamFundLimitsStream;
369                        type Future = BoxFuture<
370                            tonic::Response<Self::ResponseStream>,
371                            tonic::Status,
372                        >;
373                        fn call(
374                            &mut self,
375                            request: tonic::Request<super::StreamFundLimitsRequest>,
376                        ) -> Self::Future {
377                            let inner = Arc::clone(&self.0);
378                            let fut = async move {
379                                <T as FundService>::stream_fund_limits(&inner, request)
380                                    .await
381                            };
382                            Box::pin(fut)
383                        }
384                    }
385                    let accept_compression_encodings = self.accept_compression_encodings;
386                    let send_compression_encodings = self.send_compression_encodings;
387                    let max_decoding_message_size = self.max_decoding_message_size;
388                    let max_encoding_message_size = self.max_encoding_message_size;
389                    let inner = self.inner.clone();
390                    let fut = async move {
391                        let method = StreamFundLimitsSvc(inner);
392                        let codec = tonic::codec::ProstCodec::default();
393                        let mut grpc = tonic::server::Grpc::new(codec)
394                            .apply_compression_config(
395                                accept_compression_encodings,
396                                send_compression_encodings,
397                            )
398                            .apply_max_message_size_config(
399                                max_decoding_message_size,
400                                max_encoding_message_size,
401                            );
402                        let res = grpc.server_streaming(method, req).await;
403                        Ok(res)
404                    };
405                    Box::pin(fut)
406                }
407                _ => {
408                    Box::pin(async move {
409                        Ok(
410                            http::Response::builder()
411                                .status(200)
412                                .header("grpc-status", tonic::Code::Unimplemented as i32)
413                                .header(
414                                    http::header::CONTENT_TYPE,
415                                    tonic::metadata::GRPC_CONTENT_TYPE,
416                                )
417                                .body(empty_body())
418                                .unwrap(),
419                        )
420                    })
421                }
422            }
423        }
424    }
425    impl<T: FundService> Clone for FundServiceServer<T> {
426        fn clone(&self) -> Self {
427            let inner = self.inner.clone();
428            Self {
429                inner,
430                accept_compression_encodings: self.accept_compression_encodings,
431                send_compression_encodings: self.send_compression_encodings,
432                max_decoding_message_size: self.max_decoding_message_size,
433                max_encoding_message_size: self.max_encoding_message_size,
434            }
435        }
436    }
437    impl<T: FundService> tonic::server::NamedService for FundServiceServer<T> {
438        const NAME: &'static str = "kdo.v1.fund.FundService";
439    }
440}