rust_types/ledger_models/
valuation.rs1pub mod valuation_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 ValuationClient<T> {
8 inner: tonic::client::Grpc<T>,
9 }
10 impl ValuationClient<tonic::transport::Channel> {
11 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
13 where
14 D: std::convert::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> ValuationClient<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 ) -> ValuationClient<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 ValuationClient::new(InterceptedService::new(inner, interceptor))
54 }
55 #[must_use]
60 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
61 self.inner = self.inner.send_compressed(encoding);
62 self
63 }
64 #[must_use]
66 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
67 self.inner = self.inner.accept_compressed(encoding);
68 self
69 }
70 pub async fn echo_security(
71 &mut self,
72 request: impl tonic::IntoRequest<
73 super::super::security::SecurityRequestProto,
74 >,
75 ) -> Result<
76 tonic::Response<super::super::security::SecurityResponseProto>,
77 tonic::Status,
78 > {
79 self.inner
80 .ready()
81 .await
82 .map_err(|e| {
83 tonic::Status::new(
84 tonic::Code::Unknown,
85 format!("Service was not ready: {}", e.into()),
86 )
87 })?;
88 let codec = tonic::codec::ProstCodec::default();
89 let path = http::uri::PathAndQuery::from_static(
90 "/valuation.Valuation/EchoSecurity",
91 );
92 self.inner.unary(request.into_request(), path, codec).await
93 }
94 }
95}
96pub mod valuation_server {
98 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
99 use tonic::codegen::*;
100 #[async_trait]
102 pub trait Valuation: Send + Sync + 'static {
103 async fn echo_security(
104 &self,
105 request: tonic::Request<super::super::security::SecurityRequestProto>,
106 ) -> Result<
107 tonic::Response<super::super::security::SecurityResponseProto>,
108 tonic::Status,
109 >;
110 }
111 #[derive(Debug)]
112 pub struct ValuationServer<T: Valuation> {
113 inner: _Inner<T>,
114 accept_compression_encodings: EnabledCompressionEncodings,
115 send_compression_encodings: EnabledCompressionEncodings,
116 }
117 struct _Inner<T>(Arc<T>);
118 impl<T: Valuation> ValuationServer<T> {
119 pub fn new(inner: T) -> Self {
120 Self::from_arc(Arc::new(inner))
121 }
122 pub fn from_arc(inner: Arc<T>) -> Self {
123 let inner = _Inner(inner);
124 Self {
125 inner,
126 accept_compression_encodings: Default::default(),
127 send_compression_encodings: Default::default(),
128 }
129 }
130 pub fn with_interceptor<F>(
131 inner: T,
132 interceptor: F,
133 ) -> InterceptedService<Self, F>
134 where
135 F: tonic::service::Interceptor,
136 {
137 InterceptedService::new(Self::new(inner), interceptor)
138 }
139 #[must_use]
141 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
142 self.accept_compression_encodings.enable(encoding);
143 self
144 }
145 #[must_use]
147 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
148 self.send_compression_encodings.enable(encoding);
149 self
150 }
151 }
152 impl<T, B> tonic::codegen::Service<http::Request<B>> for ValuationServer<T>
153 where
154 T: Valuation,
155 B: Body + Send + 'static,
156 B::Error: Into<StdError> + Send + 'static,
157 {
158 type Response = http::Response<tonic::body::BoxBody>;
159 type Error = std::convert::Infallible;
160 type Future = BoxFuture<Self::Response, Self::Error>;
161 fn poll_ready(
162 &mut self,
163 _cx: &mut Context<'_>,
164 ) -> Poll<Result<(), Self::Error>> {
165 Poll::Ready(Ok(()))
166 }
167 fn call(&mut self, req: http::Request<B>) -> Self::Future {
168 let inner = self.inner.clone();
169 match req.uri().path() {
170 "/valuation.Valuation/EchoSecurity" => {
171 #[allow(non_camel_case_types)]
172 struct EchoSecuritySvc<T: Valuation>(pub Arc<T>);
173 impl<
174 T: Valuation,
175 > tonic::server::UnaryService<
176 super::super::security::SecurityRequestProto,
177 > for EchoSecuritySvc<T> {
178 type Response = super::super::security::SecurityResponseProto;
179 type Future = BoxFuture<
180 tonic::Response<Self::Response>,
181 tonic::Status,
182 >;
183 fn call(
184 &mut self,
185 request: tonic::Request<
186 super::super::security::SecurityRequestProto,
187 >,
188 ) -> Self::Future {
189 let inner = self.0.clone();
190 let fut = async move {
191 (*inner).echo_security(request).await
192 };
193 Box::pin(fut)
194 }
195 }
196 let accept_compression_encodings = self.accept_compression_encodings;
197 let send_compression_encodings = self.send_compression_encodings;
198 let inner = self.inner.clone();
199 let fut = async move {
200 let inner = inner.0;
201 let method = EchoSecuritySvc(inner);
202 let codec = tonic::codec::ProstCodec::default();
203 let mut grpc = tonic::server::Grpc::new(codec)
204 .apply_compression_config(
205 accept_compression_encodings,
206 send_compression_encodings,
207 );
208 let res = grpc.unary(method, req).await;
209 Ok(res)
210 };
211 Box::pin(fut)
212 }
213 _ => {
214 Box::pin(async move {
215 Ok(
216 http::Response::builder()
217 .status(200)
218 .header("grpc-status", "12")
219 .header("content-type", "application/grpc")
220 .body(empty_body())
221 .unwrap(),
222 )
223 })
224 }
225 }
226 }
227 }
228 impl<T: Valuation> Clone for ValuationServer<T> {
229 fn clone(&self) -> Self {
230 let inner = self.inner.clone();
231 Self {
232 inner,
233 accept_compression_encodings: self.accept_compression_encodings,
234 send_compression_encodings: self.send_compression_encodings,
235 }
236 }
237 }
238 impl<T: Valuation> Clone for _Inner<T> {
239 fn clone(&self) -> Self {
240 Self(self.0.clone())
241 }
242 }
243 impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
244 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
245 write!(f, "{:?}", self.0)
246 }
247 }
248 impl<T: Valuation> tonic::server::NamedService for ValuationServer<T> {
249 const NAME: &'static str = "valuation.Valuation";
250 }
251}