ledger_models/
fintekkers.services.position_service.rs

1/// Generated client implementations.
2pub mod position_client {
3    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
4    use tonic::codegen::*;
5    use tonic::codegen::http::Uri;
6    #[derive(Debug, Clone)]
7    pub struct PositionClient<T> {
8        inner: tonic::client::Grpc<T>,
9    }
10    impl PositionClient<tonic::transport::Channel> {
11        /// Attempt to create a new client by connecting to a given endpoint.
12        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
13        where
14            D: TryInto<tonic::transport::Endpoint>,
15            D::Error: Into<StdError>,
16        {
17            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
18            Ok(Self::new(conn))
19        }
20    }
21    impl<T> PositionClient<T>
22    where
23        T: tonic::client::GrpcService<tonic::body::BoxBody>,
24        T::Error: Into<StdError>,
25        T::ResponseBody: Body<Data = Bytes> + Send + 'static,
26        <T::ResponseBody as Body>::Error: Into<StdError> + Send,
27    {
28        pub fn new(inner: T) -> Self {
29            let inner = tonic::client::Grpc::new(inner);
30            Self { inner }
31        }
32        pub fn with_origin(inner: T, origin: Uri) -> Self {
33            let inner = tonic::client::Grpc::with_origin(inner, origin);
34            Self { inner }
35        }
36        pub fn with_interceptor<F>(
37            inner: T,
38            interceptor: F,
39        ) -> PositionClient<InterceptedService<T, F>>
40        where
41            F: tonic::service::Interceptor,
42            T::ResponseBody: Default,
43            T: tonic::codegen::Service<
44                http::Request<tonic::body::BoxBody>,
45                Response = http::Response<
46                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
47                >,
48            >,
49            <T as tonic::codegen::Service<
50                http::Request<tonic::body::BoxBody>,
51            >>::Error: Into<StdError> + Send + Sync,
52        {
53            PositionClient::new(InterceptedService::new(inner, interceptor))
54        }
55        /// Compress requests with the given encoding.
56        ///
57        /// This requires the server to support it otherwise it might respond with an
58        /// error.
59        #[must_use]
60        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
61            self.inner = self.inner.send_compressed(encoding);
62            self
63        }
64        /// Enable decompressing responses.
65        #[must_use]
66        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
67            self.inner = self.inner.accept_compressed(encoding);
68            self
69        }
70        /// Limits the maximum size of a decoded message.
71        ///
72        /// Default: `4MB`
73        #[must_use]
74        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
75            self.inner = self.inner.max_decoding_message_size(limit);
76            self
77        }
78        /// Limits the maximum size of an encoded message.
79        ///
80        /// Default: `usize::MAX`
81        #[must_use]
82        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
83            self.inner = self.inner.max_encoding_message_size(limit);
84            self
85        }
86        ///    rpc GetByIds (position.QueryPositionRequestProto) returns (position.QueryPositionResponseProto);
87        pub async fn search(
88            &mut self,
89            request: impl tonic::IntoRequest<
90                super::super::super::requests::position::QueryPositionRequestProto,
91            >,
92        ) -> std::result::Result<
93            tonic::Response<
94                tonic::codec::Streaming<
95                    super::super::super::requests::position::QueryPositionResponseProto,
96                >,
97            >,
98            tonic::Status,
99        > {
100            self.inner
101                .ready()
102                .await
103                .map_err(|e| {
104                    tonic::Status::new(
105                        tonic::Code::Unknown,
106                        format!("Service was not ready: {}", e.into()),
107                    )
108                })?;
109            let codec = tonic::codec::ProstCodec::default();
110            let path = http::uri::PathAndQuery::from_static(
111                "/fintekkers.services.position_service.Position/Search",
112            );
113            let mut req = request.into_request();
114            req.extensions_mut()
115                .insert(
116                    GrpcMethod::new(
117                        "fintekkers.services.position_service.Position",
118                        "Search",
119                    ),
120                );
121            self.inner.server_streaming(req, path, codec).await
122        }
123        ///    rpc ValidateCreateOrUpdate (transaction.CreateTransactionRequestProto) returns (util.errors.SummaryProto);
124        pub async fn validate_query_request(
125            &mut self,
126            request: impl tonic::IntoRequest<
127                super::super::super::requests::position::QueryPositionRequestProto,
128            >,
129        ) -> std::result::Result<
130            tonic::Response<super::super::super::requests::util::errors::SummaryProto>,
131            tonic::Status,
132        > {
133            self.inner
134                .ready()
135                .await
136                .map_err(|e| {
137                    tonic::Status::new(
138                        tonic::Code::Unknown,
139                        format!("Service was not ready: {}", e.into()),
140                    )
141                })?;
142            let codec = tonic::codec::ProstCodec::default();
143            let path = http::uri::PathAndQuery::from_static(
144                "/fintekkers.services.position_service.Position/ValidateQueryRequest",
145            );
146            let mut req = request.into_request();
147            req.extensions_mut()
148                .insert(
149                    GrpcMethod::new(
150                        "fintekkers.services.position_service.Position",
151                        "ValidateQueryRequest",
152                    ),
153                );
154            self.inner.unary(req, path, codec).await
155        }
156    }
157}
158/// Generated server implementations.
159pub mod position_server {
160    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
161    use tonic::codegen::*;
162    /// Generated trait containing gRPC methods that should be implemented for use with PositionServer.
163    #[async_trait]
164    pub trait Position: Send + Sync + 'static {
165        /// Server streaming response type for the Search method.
166        type SearchStream: futures_core::Stream<
167                Item = std::result::Result<
168                    super::super::super::requests::position::QueryPositionResponseProto,
169                    tonic::Status,
170                >,
171            >
172            + Send
173            + 'static;
174        ///    rpc GetByIds (position.QueryPositionRequestProto) returns (position.QueryPositionResponseProto);
175        async fn search(
176            &self,
177            request: tonic::Request<
178                super::super::super::requests::position::QueryPositionRequestProto,
179            >,
180        ) -> std::result::Result<tonic::Response<Self::SearchStream>, tonic::Status>;
181        ///    rpc ValidateCreateOrUpdate (transaction.CreateTransactionRequestProto) returns (util.errors.SummaryProto);
182        async fn validate_query_request(
183            &self,
184            request: tonic::Request<
185                super::super::super::requests::position::QueryPositionRequestProto,
186            >,
187        ) -> std::result::Result<
188            tonic::Response<super::super::super::requests::util::errors::SummaryProto>,
189            tonic::Status,
190        >;
191    }
192    #[derive(Debug)]
193    pub struct PositionServer<T: Position> {
194        inner: _Inner<T>,
195        accept_compression_encodings: EnabledCompressionEncodings,
196        send_compression_encodings: EnabledCompressionEncodings,
197        max_decoding_message_size: Option<usize>,
198        max_encoding_message_size: Option<usize>,
199    }
200    struct _Inner<T>(Arc<T>);
201    impl<T: Position> PositionServer<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            let inner = _Inner(inner);
207            Self {
208                inner,
209                accept_compression_encodings: Default::default(),
210                send_compression_encodings: Default::default(),
211                max_decoding_message_size: None,
212                max_encoding_message_size: None,
213            }
214        }
215        pub fn with_interceptor<F>(
216            inner: T,
217            interceptor: F,
218        ) -> InterceptedService<Self, F>
219        where
220            F: tonic::service::Interceptor,
221        {
222            InterceptedService::new(Self::new(inner), interceptor)
223        }
224        /// Enable decompressing requests with the given encoding.
225        #[must_use]
226        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
227            self.accept_compression_encodings.enable(encoding);
228            self
229        }
230        /// Compress responses with the given encoding, if the client supports it.
231        #[must_use]
232        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
233            self.send_compression_encodings.enable(encoding);
234            self
235        }
236        /// Limits the maximum size of a decoded message.
237        ///
238        /// Default: `4MB`
239        #[must_use]
240        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
241            self.max_decoding_message_size = Some(limit);
242            self
243        }
244        /// Limits the maximum size of an encoded message.
245        ///
246        /// Default: `usize::MAX`
247        #[must_use]
248        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
249            self.max_encoding_message_size = Some(limit);
250            self
251        }
252    }
253    impl<T, B> tonic::codegen::Service<http::Request<B>> for PositionServer<T>
254    where
255        T: Position,
256        B: Body + Send + 'static,
257        B::Error: Into<StdError> + Send + 'static,
258    {
259        type Response = http::Response<tonic::body::BoxBody>;
260        type Error = std::convert::Infallible;
261        type Future = BoxFuture<Self::Response, Self::Error>;
262        fn poll_ready(
263            &mut self,
264            _cx: &mut Context<'_>,
265        ) -> Poll<std::result::Result<(), Self::Error>> {
266            Poll::Ready(Ok(()))
267        }
268        fn call(&mut self, req: http::Request<B>) -> Self::Future {
269            let inner = self.inner.clone();
270            match req.uri().path() {
271                "/fintekkers.services.position_service.Position/Search" => {
272                    #[allow(non_camel_case_types)]
273                    struct SearchSvc<T: Position>(pub Arc<T>);
274                    impl<
275                        T: Position,
276                    > tonic::server::ServerStreamingService<
277                        super::super::super::requests::position::QueryPositionRequestProto,
278                    > for SearchSvc<T> {
279                        type Response = super::super::super::requests::position::QueryPositionResponseProto;
280                        type ResponseStream = T::SearchStream;
281                        type Future = BoxFuture<
282                            tonic::Response<Self::ResponseStream>,
283                            tonic::Status,
284                        >;
285                        fn call(
286                            &mut self,
287                            request: tonic::Request<
288                                super::super::super::requests::position::QueryPositionRequestProto,
289                            >,
290                        ) -> Self::Future {
291                            let inner = Arc::clone(&self.0);
292                            let fut = async move { (*inner).search(request).await };
293                            Box::pin(fut)
294                        }
295                    }
296                    let accept_compression_encodings = self.accept_compression_encodings;
297                    let send_compression_encodings = self.send_compression_encodings;
298                    let max_decoding_message_size = self.max_decoding_message_size;
299                    let max_encoding_message_size = self.max_encoding_message_size;
300                    let inner = self.inner.clone();
301                    let fut = async move {
302                        let inner = inner.0;
303                        let method = SearchSvc(inner);
304                        let codec = tonic::codec::ProstCodec::default();
305                        let mut grpc = tonic::server::Grpc::new(codec)
306                            .apply_compression_config(
307                                accept_compression_encodings,
308                                send_compression_encodings,
309                            )
310                            .apply_max_message_size_config(
311                                max_decoding_message_size,
312                                max_encoding_message_size,
313                            );
314                        let res = grpc.server_streaming(method, req).await;
315                        Ok(res)
316                    };
317                    Box::pin(fut)
318                }
319                "/fintekkers.services.position_service.Position/ValidateQueryRequest" => {
320                    #[allow(non_camel_case_types)]
321                    struct ValidateQueryRequestSvc<T: Position>(pub Arc<T>);
322                    impl<
323                        T: Position,
324                    > tonic::server::UnaryService<
325                        super::super::super::requests::position::QueryPositionRequestProto,
326                    > for ValidateQueryRequestSvc<T> {
327                        type Response = super::super::super::requests::util::errors::SummaryProto;
328                        type Future = BoxFuture<
329                            tonic::Response<Self::Response>,
330                            tonic::Status,
331                        >;
332                        fn call(
333                            &mut self,
334                            request: tonic::Request<
335                                super::super::super::requests::position::QueryPositionRequestProto,
336                            >,
337                        ) -> Self::Future {
338                            let inner = Arc::clone(&self.0);
339                            let fut = async move {
340                                (*inner).validate_query_request(request).await
341                            };
342                            Box::pin(fut)
343                        }
344                    }
345                    let accept_compression_encodings = self.accept_compression_encodings;
346                    let send_compression_encodings = self.send_compression_encodings;
347                    let max_decoding_message_size = self.max_decoding_message_size;
348                    let max_encoding_message_size = self.max_encoding_message_size;
349                    let inner = self.inner.clone();
350                    let fut = async move {
351                        let inner = inner.0;
352                        let method = ValidateQueryRequestSvc(inner);
353                        let codec = tonic::codec::ProstCodec::default();
354                        let mut grpc = tonic::server::Grpc::new(codec)
355                            .apply_compression_config(
356                                accept_compression_encodings,
357                                send_compression_encodings,
358                            )
359                            .apply_max_message_size_config(
360                                max_decoding_message_size,
361                                max_encoding_message_size,
362                            );
363                        let res = grpc.unary(method, req).await;
364                        Ok(res)
365                    };
366                    Box::pin(fut)
367                }
368                _ => {
369                    Box::pin(async move {
370                        Ok(
371                            http::Response::builder()
372                                .status(200)
373                                .header("grpc-status", "12")
374                                .header("content-type", "application/grpc")
375                                .body(empty_body())
376                                .unwrap(),
377                        )
378                    })
379                }
380            }
381        }
382    }
383    impl<T: Position> Clone for PositionServer<T> {
384        fn clone(&self) -> Self {
385            let inner = self.inner.clone();
386            Self {
387                inner,
388                accept_compression_encodings: self.accept_compression_encodings,
389                send_compression_encodings: self.send_compression_encodings,
390                max_decoding_message_size: self.max_decoding_message_size,
391                max_encoding_message_size: self.max_encoding_message_size,
392            }
393        }
394    }
395    impl<T: Position> Clone for _Inner<T> {
396        fn clone(&self) -> Self {
397            Self(Arc::clone(&self.0))
398        }
399    }
400    impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
401        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
402            write!(f, "{:?}", self.0)
403        }
404    }
405    impl<T: Position> tonic::server::NamedService for PositionServer<T> {
406        const NAME: &'static str = "fintekkers.services.position_service.Position";
407    }
408}