avalanche_types/proto/pb/
sharedmemory.tonic.rs1pub mod shared_memory_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 SharedMemoryClient<T> {
9 inner: tonic::client::Grpc<T>,
10 }
11 impl SharedMemoryClient<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> SharedMemoryClient<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 ) -> SharedMemoryClient<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 SharedMemoryClient::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(
88 &mut self,
89 request: impl tonic::IntoRequest<super::GetRequest>,
90 ) -> std::result::Result<tonic::Response<super::GetResponse>, 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 "/sharedmemory.SharedMemory/Get",
103 );
104 let mut req = request.into_request();
105 req.extensions_mut()
106 .insert(GrpcMethod::new("sharedmemory.SharedMemory", "Get"));
107 self.inner.unary(req, path, codec).await
108 }
109 pub async fn indexed(
110 &mut self,
111 request: impl tonic::IntoRequest<super::IndexedRequest>,
112 ) -> std::result::Result<
113 tonic::Response<super::IndexedResponse>,
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 "/sharedmemory.SharedMemory/Indexed",
128 );
129 let mut req = request.into_request();
130 req.extensions_mut()
131 .insert(GrpcMethod::new("sharedmemory.SharedMemory", "Indexed"));
132 self.inner.unary(req, path, codec).await
133 }
134 pub async fn apply(
135 &mut self,
136 request: impl tonic::IntoRequest<super::ApplyRequest>,
137 ) -> std::result::Result<tonic::Response<super::ApplyResponse>, tonic::Status> {
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 "/sharedmemory.SharedMemory/Apply",
150 );
151 let mut req = request.into_request();
152 req.extensions_mut()
153 .insert(GrpcMethod::new("sharedmemory.SharedMemory", "Apply"));
154 self.inner.unary(req, path, codec).await
155 }
156 }
157}
158pub mod shared_memory_server {
160 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
161 use tonic::codegen::*;
162 #[async_trait]
164 pub trait SharedMemory: Send + Sync + 'static {
165 async fn get(
166 &self,
167 request: tonic::Request<super::GetRequest>,
168 ) -> std::result::Result<tonic::Response<super::GetResponse>, tonic::Status>;
169 async fn indexed(
170 &self,
171 request: tonic::Request<super::IndexedRequest>,
172 ) -> std::result::Result<tonic::Response<super::IndexedResponse>, tonic::Status>;
173 async fn apply(
174 &self,
175 request: tonic::Request<super::ApplyRequest>,
176 ) -> std::result::Result<tonic::Response<super::ApplyResponse>, tonic::Status>;
177 }
178 #[derive(Debug)]
179 pub struct SharedMemoryServer<T: SharedMemory> {
180 inner: _Inner<T>,
181 accept_compression_encodings: EnabledCompressionEncodings,
182 send_compression_encodings: EnabledCompressionEncodings,
183 max_decoding_message_size: Option<usize>,
184 max_encoding_message_size: Option<usize>,
185 }
186 struct _Inner<T>(Arc<T>);
187 impl<T: SharedMemory> SharedMemoryServer<T> {
188 pub fn new(inner: T) -> Self {
189 Self::from_arc(Arc::new(inner))
190 }
191 pub fn from_arc(inner: Arc<T>) -> Self {
192 let inner = _Inner(inner);
193 Self {
194 inner,
195 accept_compression_encodings: Default::default(),
196 send_compression_encodings: Default::default(),
197 max_decoding_message_size: None,
198 max_encoding_message_size: None,
199 }
200 }
201 pub fn with_interceptor<F>(
202 inner: T,
203 interceptor: F,
204 ) -> InterceptedService<Self, F>
205 where
206 F: tonic::service::Interceptor,
207 {
208 InterceptedService::new(Self::new(inner), interceptor)
209 }
210 #[must_use]
212 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
213 self.accept_compression_encodings.enable(encoding);
214 self
215 }
216 #[must_use]
218 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
219 self.send_compression_encodings.enable(encoding);
220 self
221 }
222 #[must_use]
226 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
227 self.max_decoding_message_size = Some(limit);
228 self
229 }
230 #[must_use]
234 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
235 self.max_encoding_message_size = Some(limit);
236 self
237 }
238 }
239 impl<T, B> tonic::codegen::Service<http::Request<B>> for SharedMemoryServer<T>
240 where
241 T: SharedMemory,
242 B: Body + Send + 'static,
243 B::Error: Into<StdError> + Send + 'static,
244 {
245 type Response = http::Response<tonic::body::BoxBody>;
246 type Error = std::convert::Infallible;
247 type Future = BoxFuture<Self::Response, Self::Error>;
248 fn poll_ready(
249 &mut self,
250 _cx: &mut Context<'_>,
251 ) -> Poll<std::result::Result<(), Self::Error>> {
252 Poll::Ready(Ok(()))
253 }
254 fn call(&mut self, req: http::Request<B>) -> Self::Future {
255 let inner = self.inner.clone();
256 match req.uri().path() {
257 "/sharedmemory.SharedMemory/Get" => {
258 #[allow(non_camel_case_types)]
259 struct GetSvc<T: SharedMemory>(pub Arc<T>);
260 impl<T: SharedMemory> tonic::server::UnaryService<super::GetRequest>
261 for GetSvc<T> {
262 type Response = super::GetResponse;
263 type Future = BoxFuture<
264 tonic::Response<Self::Response>,
265 tonic::Status,
266 >;
267 fn call(
268 &mut self,
269 request: tonic::Request<super::GetRequest>,
270 ) -> Self::Future {
271 let inner = Arc::clone(&self.0);
272 let fut = async move { (*inner).get(request).await };
273 Box::pin(fut)
274 }
275 }
276 let accept_compression_encodings = self.accept_compression_encodings;
277 let send_compression_encodings = self.send_compression_encodings;
278 let max_decoding_message_size = self.max_decoding_message_size;
279 let max_encoding_message_size = self.max_encoding_message_size;
280 let inner = self.inner.clone();
281 let fut = async move {
282 let inner = inner.0;
283 let method = GetSvc(inner);
284 let codec = tonic::codec::ProstCodec::default();
285 let mut grpc = tonic::server::Grpc::new(codec)
286 .apply_compression_config(
287 accept_compression_encodings,
288 send_compression_encodings,
289 )
290 .apply_max_message_size_config(
291 max_decoding_message_size,
292 max_encoding_message_size,
293 );
294 let res = grpc.unary(method, req).await;
295 Ok(res)
296 };
297 Box::pin(fut)
298 }
299 "/sharedmemory.SharedMemory/Indexed" => {
300 #[allow(non_camel_case_types)]
301 struct IndexedSvc<T: SharedMemory>(pub Arc<T>);
302 impl<
303 T: SharedMemory,
304 > tonic::server::UnaryService<super::IndexedRequest>
305 for IndexedSvc<T> {
306 type Response = super::IndexedResponse;
307 type Future = BoxFuture<
308 tonic::Response<Self::Response>,
309 tonic::Status,
310 >;
311 fn call(
312 &mut self,
313 request: tonic::Request<super::IndexedRequest>,
314 ) -> Self::Future {
315 let inner = Arc::clone(&self.0);
316 let fut = async move { (*inner).indexed(request).await };
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 inner = inner.0;
327 let method = IndexedSvc(inner);
328 let codec = tonic::codec::ProstCodec::default();
329 let mut grpc = tonic::server::Grpc::new(codec)
330 .apply_compression_config(
331 accept_compression_encodings,
332 send_compression_encodings,
333 )
334 .apply_max_message_size_config(
335 max_decoding_message_size,
336 max_encoding_message_size,
337 );
338 let res = grpc.unary(method, req).await;
339 Ok(res)
340 };
341 Box::pin(fut)
342 }
343 "/sharedmemory.SharedMemory/Apply" => {
344 #[allow(non_camel_case_types)]
345 struct ApplySvc<T: SharedMemory>(pub Arc<T>);
346 impl<
347 T: SharedMemory,
348 > tonic::server::UnaryService<super::ApplyRequest> for ApplySvc<T> {
349 type Response = super::ApplyResponse;
350 type Future = BoxFuture<
351 tonic::Response<Self::Response>,
352 tonic::Status,
353 >;
354 fn call(
355 &mut self,
356 request: tonic::Request<super::ApplyRequest>,
357 ) -> Self::Future {
358 let inner = Arc::clone(&self.0);
359 let fut = async move { (*inner).apply(request).await };
360 Box::pin(fut)
361 }
362 }
363 let accept_compression_encodings = self.accept_compression_encodings;
364 let send_compression_encodings = self.send_compression_encodings;
365 let max_decoding_message_size = self.max_decoding_message_size;
366 let max_encoding_message_size = self.max_encoding_message_size;
367 let inner = self.inner.clone();
368 let fut = async move {
369 let inner = inner.0;
370 let method = ApplySvc(inner);
371 let codec = tonic::codec::ProstCodec::default();
372 let mut grpc = tonic::server::Grpc::new(codec)
373 .apply_compression_config(
374 accept_compression_encodings,
375 send_compression_encodings,
376 )
377 .apply_max_message_size_config(
378 max_decoding_message_size,
379 max_encoding_message_size,
380 );
381 let res = grpc.unary(method, req).await;
382 Ok(res)
383 };
384 Box::pin(fut)
385 }
386 _ => {
387 Box::pin(async move {
388 Ok(
389 http::Response::builder()
390 .status(200)
391 .header("grpc-status", "12")
392 .header("content-type", "application/grpc")
393 .body(empty_body())
394 .unwrap(),
395 )
396 })
397 }
398 }
399 }
400 }
401 impl<T: SharedMemory> Clone for SharedMemoryServer<T> {
402 fn clone(&self) -> Self {
403 let inner = self.inner.clone();
404 Self {
405 inner,
406 accept_compression_encodings: self.accept_compression_encodings,
407 send_compression_encodings: self.send_compression_encodings,
408 max_decoding_message_size: self.max_decoding_message_size,
409 max_encoding_message_size: self.max_encoding_message_size,
410 }
411 }
412 }
413 impl<T: SharedMemory> Clone for _Inner<T> {
414 fn clone(&self) -> Self {
415 Self(Arc::clone(&self.0))
416 }
417 }
418 impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
419 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
420 write!(f, "{:?}", self.0)
421 }
422 }
423 impl<T: SharedMemory> tonic::server::NamedService for SharedMemoryServer<T> {
424 const NAME: &'static str = "sharedmemory.SharedMemory";
425 }
426}