1#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
3pub struct DecoderCapabilities {
4 #[prost(enumeration = "DecoderFeature", repeated, tag = "1")]
5 pub features: ::prost::alloc::vec::Vec<i32>,
6}
7#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
8pub struct ResetRequest {
9 #[prost(bool, tag = "1")]
11 pub reset_hypergraphs: bool,
12 #[prost(string, tag = "200")]
14 pub custom: ::prost::alloc::string::String,
15}
16#[derive(Clone, PartialEq, ::prost::Message)]
17pub struct DecodingProblem {
18 #[prost(message, optional, tag = "1")]
19 pub hypergraph: ::core::option::Option<DecodingHypergraph>,
20 #[prost(message, optional, tag = "2")]
21 pub syndrome: ::core::option::Option<super::super::util::BitVector>,
22 #[prost(message, optional, tag = "3")]
25 pub loss: ::core::option::Option<LossInfo>,
26 #[prost(uint64, optional, tag = "4")]
28 pub decoder_seed: ::core::option::Option<u64>,
29}
30#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
31pub struct LoadHypergraphResponse {
32 #[prost(uint64, tag = "1")]
34 pub hid: u64,
35}
36#[derive(Clone, PartialEq, ::prost::Message)]
37pub struct LoadedDecodingProblem {
38 #[prost(uint64, tag = "1")]
39 pub hid: u64,
40 #[prost(message, optional, tag = "2")]
41 pub syndrome: ::core::option::Option<super::super::util::BitVector>,
42 #[prost(message, repeated, tag = "3")]
46 pub reweights: ::prost::alloc::vec::Vec<EdgeReweight>,
47 #[prost(message, optional, tag = "4")]
50 pub loss: ::core::option::Option<LossInfo>,
51 #[prost(uint64, optional, tag = "5")]
53 pub decoder_seed: ::core::option::Option<u64>,
54}
55#[derive(Clone, Copy, PartialEq, ::prost::Message)]
59pub struct EdgeReweight {
60 #[prost(uint64, tag = "1")]
61 pub edge: u64,
62 #[prost(double, tag = "2")]
63 pub probability: f64,
64}
65#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
66pub struct ParityFactor {
67 #[prost(uint64, repeated, tag = "1")]
68 pub subgraph: ::prost::alloc::vec::Vec<u64>,
69}
70#[derive(Clone, PartialEq, ::prost::Message)]
71pub struct DecodingHypergraph {
72 #[prost(uint64, tag = "1")]
73 pub vertex_num: u64,
74 #[prost(message, repeated, tag = "2")]
75 pub hyperedges: ::prost::alloc::vec::Vec<Hyperedge>,
76}
77#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
78pub struct ObservableFlips {
79 #[prost(uint64, repeated, tag = "1")]
81 pub indices: ::prost::alloc::vec::Vec<u64>,
82}
83#[derive(Clone, PartialEq, ::prost::Message)]
84pub struct Hyperedge {
85 #[prost(uint64, repeated, tag = "1")]
86 pub vertices: ::prost::alloc::vec::Vec<u64>,
87 #[prost(double, tag = "2")]
90 pub probability: f64,
91 #[prost(message, optional, tag = "3")]
97 pub observable_flips: ::core::option::Option<ObservableFlips>,
98}
99#[derive(Clone, PartialEq, ::prost::Message)]
104pub struct LossInfo {
105 #[prost(message, repeated, tag = "1")]
110 pub sites: ::prost::alloc::vec::Vec<LossSite>,
111}
112#[derive(Clone, PartialEq, ::prost::Message)]
113pub struct LossSite {
114 #[prost(uint64, repeated, tag = "1")]
119 pub source_edges: ::prost::alloc::vec::Vec<u64>,
120 #[prost(uint64, repeated, tag = "2")]
124 pub continuation_edges: ::prost::alloc::vec::Vec<u64>,
125 #[prost(uint64, repeated, tag = "3")]
128 pub children: ::prost::alloc::vec::Vec<u64>,
129 #[prost(double, tag = "4")]
132 pub probability: f64,
133 #[prost(uint64, repeated, tag = "5")]
137 pub heralds: ::prost::alloc::vec::Vec<u64>,
138}
139#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
140#[repr(i32)]
141pub enum DecoderFeature {
142 Unspecified = 0,
143 Reweights = 1,
144 Loss = 2,
145 Seed = 3,
146 Observables = 4,
148}
149impl DecoderFeature {
150 pub fn as_str_name(&self) -> &'static str {
155 match self {
156 Self::Unspecified => "DECODER_FEATURE_UNSPECIFIED",
157 Self::Reweights => "DECODER_FEATURE_REWEIGHTS",
158 Self::Loss => "DECODER_FEATURE_LOSS",
159 Self::Seed => "DECODER_FEATURE_SEED",
160 Self::Observables => "DECODER_FEATURE_OBSERVABLES",
161 }
162 }
163 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
165 match value {
166 "DECODER_FEATURE_UNSPECIFIED" => Some(Self::Unspecified),
167 "DECODER_FEATURE_REWEIGHTS" => Some(Self::Reweights),
168 "DECODER_FEATURE_LOSS" => Some(Self::Loss),
169 "DECODER_FEATURE_SEED" => Some(Self::Seed),
170 "DECODER_FEATURE_OBSERVABLES" => Some(Self::Observables),
171 _ => None,
172 }
173 }
174}
175#[cfg(feature = "cli")]
177pub mod black_box_decoder_client {
178 #![allow(
179 unused_variables,
180 dead_code,
181 missing_docs,
182 clippy::wildcard_imports,
183 clippy::let_unit_value,
184 )]
185 use tonic::codegen::*;
186 use tonic::codegen::http::Uri;
187 #[derive(Debug, Clone)]
188 pub struct BlackBoxDecoderClient<T> {
189 inner: tonic::client::Grpc<T>,
190 }
191 impl BlackBoxDecoderClient<tonic::transport::Channel> {
192 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
194 where
195 D: TryInto<tonic::transport::Endpoint>,
196 D::Error: Into<StdError>,
197 {
198 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
199 Ok(Self::new(conn))
200 }
201 }
202 impl<T> BlackBoxDecoderClient<T>
203 where
204 T: tonic::client::GrpcService<tonic::body::Body>,
205 T::Error: Into<StdError>,
206 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
207 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
208 {
209 pub fn new(inner: T) -> Self {
210 let inner = tonic::client::Grpc::new(inner);
211 Self { inner }
212 }
213 pub fn with_origin(inner: T, origin: Uri) -> Self {
214 let inner = tonic::client::Grpc::with_origin(inner, origin);
215 Self { inner }
216 }
217 pub fn with_interceptor<F>(
218 inner: T,
219 interceptor: F,
220 ) -> BlackBoxDecoderClient<InterceptedService<T, F>>
221 where
222 F: tonic::service::Interceptor,
223 T::ResponseBody: Default,
224 T: tonic::codegen::Service<
225 http::Request<tonic::body::Body>,
226 Response = http::Response<
227 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
228 >,
229 >,
230 <T as tonic::codegen::Service<
231 http::Request<tonic::body::Body>,
232 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
233 {
234 BlackBoxDecoderClient::new(InterceptedService::new(inner, interceptor))
235 }
236 #[must_use]
241 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
242 self.inner = self.inner.send_compressed(encoding);
243 self
244 }
245 #[must_use]
247 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
248 self.inner = self.inner.accept_compressed(encoding);
249 self
250 }
251 #[must_use]
255 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
256 self.inner = self.inner.max_decoding_message_size(limit);
257 self
258 }
259 #[must_use]
263 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
264 self.inner = self.inner.max_encoding_message_size(limit);
265 self
266 }
267 pub async fn get_capabilities(
270 &mut self,
271 request: impl tonic::IntoRequest<()>,
272 ) -> std::result::Result<
273 tonic::Response<super::DecoderCapabilities>,
274 tonic::Status,
275 > {
276 self.inner
277 .ready()
278 .await
279 .map_err(|e| {
280 tonic::Status::unknown(
281 format!("Service was not ready: {}", e.into()),
282 )
283 })?;
284 let codec = tonic_prost::ProstCodec::default();
285 let path = http::uri::PathAndQuery::from_static(
286 "/deq.decoder.blackbox_decoder.BlackBoxDecoder/GetCapabilities",
287 );
288 let mut req = request.into_request();
289 req.extensions_mut()
290 .insert(
291 GrpcMethod::new(
292 "deq.decoder.blackbox_decoder.BlackBoxDecoder",
293 "GetCapabilities",
294 ),
295 );
296 self.inner.unary(req, path, codec).await
297 }
298 pub async fn decode(
302 &mut self,
303 request: impl tonic::IntoRequest<super::DecodingProblem>,
304 ) -> std::result::Result<tonic::Response<super::ParityFactor>, tonic::Status> {
305 self.inner
306 .ready()
307 .await
308 .map_err(|e| {
309 tonic::Status::unknown(
310 format!("Service was not ready: {}", e.into()),
311 )
312 })?;
313 let codec = tonic_prost::ProstCodec::default();
314 let path = http::uri::PathAndQuery::from_static(
315 "/deq.decoder.blackbox_decoder.BlackBoxDecoder/Decode",
316 );
317 let mut req = request.into_request();
318 req.extensions_mut()
319 .insert(
320 GrpcMethod::new(
321 "deq.decoder.blackbox_decoder.BlackBoxDecoder",
322 "Decode",
323 ),
324 );
325 self.inner.unary(req, path, codec).await
326 }
327 pub async fn load_hypergraph(
330 &mut self,
331 request: impl tonic::IntoRequest<super::DecodingHypergraph>,
332 ) -> std::result::Result<
333 tonic::Response<super::LoadHypergraphResponse>,
334 tonic::Status,
335 > {
336 self.inner
337 .ready()
338 .await
339 .map_err(|e| {
340 tonic::Status::unknown(
341 format!("Service was not ready: {}", e.into()),
342 )
343 })?;
344 let codec = tonic_prost::ProstCodec::default();
345 let path = http::uri::PathAndQuery::from_static(
346 "/deq.decoder.blackbox_decoder.BlackBoxDecoder/LoadHypergraph",
347 );
348 let mut req = request.into_request();
349 req.extensions_mut()
350 .insert(
351 GrpcMethod::new(
352 "deq.decoder.blackbox_decoder.BlackBoxDecoder",
353 "LoadHypergraph",
354 ),
355 );
356 self.inner.unary(req, path, codec).await
357 }
358 pub async fn decode_loaded(
360 &mut self,
361 request: impl tonic::IntoRequest<super::LoadedDecodingProblem>,
362 ) -> std::result::Result<tonic::Response<super::ParityFactor>, tonic::Status> {
363 self.inner
364 .ready()
365 .await
366 .map_err(|e| {
367 tonic::Status::unknown(
368 format!("Service was not ready: {}", e.into()),
369 )
370 })?;
371 let codec = tonic_prost::ProstCodec::default();
372 let path = http::uri::PathAndQuery::from_static(
373 "/deq.decoder.blackbox_decoder.BlackBoxDecoder/DecodeLoaded",
374 );
375 let mut req = request.into_request();
376 req.extensions_mut()
377 .insert(
378 GrpcMethod::new(
379 "deq.decoder.blackbox_decoder.BlackBoxDecoder",
380 "DecodeLoaded",
381 ),
382 );
383 self.inner.unary(req, path, codec).await
384 }
385 pub async fn reset(
387 &mut self,
388 request: impl tonic::IntoRequest<super::ResetRequest>,
389 ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
390 self.inner
391 .ready()
392 .await
393 .map_err(|e| {
394 tonic::Status::unknown(
395 format!("Service was not ready: {}", e.into()),
396 )
397 })?;
398 let codec = tonic_prost::ProstCodec::default();
399 let path = http::uri::PathAndQuery::from_static(
400 "/deq.decoder.blackbox_decoder.BlackBoxDecoder/Reset",
401 );
402 let mut req = request.into_request();
403 req.extensions_mut()
404 .insert(
405 GrpcMethod::new(
406 "deq.decoder.blackbox_decoder.BlackBoxDecoder",
407 "Reset",
408 ),
409 );
410 self.inner.unary(req, path, codec).await
411 }
412 }
413}
414pub mod black_box_decoder_server {
416 #![allow(
417 unused_variables,
418 dead_code,
419 missing_docs,
420 clippy::wildcard_imports,
421 clippy::let_unit_value,
422 )]
423 use tonic::codegen::*;
424 #[async_trait]
426 pub trait BlackBoxDecoder: std::marker::Send + std::marker::Sync + 'static {
427 async fn get_capabilities(
430 &self,
431 request: tonic::Request<()>,
432 ) -> std::result::Result<
433 tonic::Response<super::DecoderCapabilities>,
434 tonic::Status,
435 >;
436 async fn decode(
440 &self,
441 request: tonic::Request<super::DecodingProblem>,
442 ) -> std::result::Result<tonic::Response<super::ParityFactor>, tonic::Status>;
443 async fn load_hypergraph(
446 &self,
447 request: tonic::Request<super::DecodingHypergraph>,
448 ) -> std::result::Result<
449 tonic::Response<super::LoadHypergraphResponse>,
450 tonic::Status,
451 >;
452 async fn decode_loaded(
454 &self,
455 request: tonic::Request<super::LoadedDecodingProblem>,
456 ) -> std::result::Result<tonic::Response<super::ParityFactor>, tonic::Status>;
457 async fn reset(
459 &self,
460 request: tonic::Request<super::ResetRequest>,
461 ) -> std::result::Result<tonic::Response<()>, tonic::Status>;
462 }
463 #[derive(Debug)]
464 pub struct BlackBoxDecoderServer<T> {
465 inner: Arc<T>,
466 accept_compression_encodings: EnabledCompressionEncodings,
467 send_compression_encodings: EnabledCompressionEncodings,
468 max_decoding_message_size: Option<usize>,
469 max_encoding_message_size: Option<usize>,
470 }
471 impl<T> BlackBoxDecoderServer<T> {
472 pub fn new(inner: T) -> Self {
473 Self::from_arc(Arc::new(inner))
474 }
475 pub fn from_arc(inner: Arc<T>) -> Self {
476 Self {
477 inner,
478 accept_compression_encodings: Default::default(),
479 send_compression_encodings: Default::default(),
480 max_decoding_message_size: None,
481 max_encoding_message_size: None,
482 }
483 }
484 pub fn with_interceptor<F>(
485 inner: T,
486 interceptor: F,
487 ) -> InterceptedService<Self, F>
488 where
489 F: tonic::service::Interceptor,
490 {
491 InterceptedService::new(Self::new(inner), interceptor)
492 }
493 #[must_use]
495 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
496 self.accept_compression_encodings.enable(encoding);
497 self
498 }
499 #[must_use]
501 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
502 self.send_compression_encodings.enable(encoding);
503 self
504 }
505 #[must_use]
509 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
510 self.max_decoding_message_size = Some(limit);
511 self
512 }
513 #[must_use]
517 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
518 self.max_encoding_message_size = Some(limit);
519 self
520 }
521 }
522 impl<T, B> tonic::codegen::Service<http::Request<B>> for BlackBoxDecoderServer<T>
523 where
524 T: BlackBoxDecoder,
525 B: Body + std::marker::Send + 'static,
526 B::Error: Into<StdError> + std::marker::Send + 'static,
527 {
528 type Response = http::Response<tonic::body::Body>;
529 type Error = std::convert::Infallible;
530 type Future = BoxFuture<Self::Response, Self::Error>;
531 fn poll_ready(
532 &mut self,
533 _cx: &mut Context<'_>,
534 ) -> Poll<std::result::Result<(), Self::Error>> {
535 Poll::Ready(Ok(()))
536 }
537 fn call(&mut self, req: http::Request<B>) -> Self::Future {
538 match req.uri().path() {
539 "/deq.decoder.blackbox_decoder.BlackBoxDecoder/GetCapabilities" => {
540 #[allow(non_camel_case_types)]
541 struct GetCapabilitiesSvc<T: BlackBoxDecoder>(pub Arc<T>);
542 impl<T: BlackBoxDecoder> tonic::server::UnaryService<()>
543 for GetCapabilitiesSvc<T> {
544 type Response = super::DecoderCapabilities;
545 type Future = BoxFuture<
546 tonic::Response<Self::Response>,
547 tonic::Status,
548 >;
549 fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
550 let inner = Arc::clone(&self.0);
551 let fut = async move {
552 <T as BlackBoxDecoder>::get_capabilities(&inner, request)
553 .await
554 };
555 Box::pin(fut)
556 }
557 }
558 let accept_compression_encodings = self.accept_compression_encodings;
559 let send_compression_encodings = self.send_compression_encodings;
560 let max_decoding_message_size = self.max_decoding_message_size;
561 let max_encoding_message_size = self.max_encoding_message_size;
562 let inner = self.inner.clone();
563 let fut = async move {
564 let method = GetCapabilitiesSvc(inner);
565 let codec = tonic_prost::ProstCodec::default();
566 let mut grpc = tonic::server::Grpc::new(codec)
567 .apply_compression_config(
568 accept_compression_encodings,
569 send_compression_encodings,
570 )
571 .apply_max_message_size_config(
572 max_decoding_message_size,
573 max_encoding_message_size,
574 );
575 let res = grpc.unary(method, req).await;
576 Ok(res)
577 };
578 Box::pin(fut)
579 }
580 "/deq.decoder.blackbox_decoder.BlackBoxDecoder/Decode" => {
581 #[allow(non_camel_case_types)]
582 struct DecodeSvc<T: BlackBoxDecoder>(pub Arc<T>);
583 impl<
584 T: BlackBoxDecoder,
585 > tonic::server::UnaryService<super::DecodingProblem>
586 for DecodeSvc<T> {
587 type Response = super::ParityFactor;
588 type Future = BoxFuture<
589 tonic::Response<Self::Response>,
590 tonic::Status,
591 >;
592 fn call(
593 &mut self,
594 request: tonic::Request<super::DecodingProblem>,
595 ) -> Self::Future {
596 let inner = Arc::clone(&self.0);
597 let fut = async move {
598 <T as BlackBoxDecoder>::decode(&inner, request).await
599 };
600 Box::pin(fut)
601 }
602 }
603 let accept_compression_encodings = self.accept_compression_encodings;
604 let send_compression_encodings = self.send_compression_encodings;
605 let max_decoding_message_size = self.max_decoding_message_size;
606 let max_encoding_message_size = self.max_encoding_message_size;
607 let inner = self.inner.clone();
608 let fut = async move {
609 let method = DecodeSvc(inner);
610 let codec = tonic_prost::ProstCodec::default();
611 let mut grpc = tonic::server::Grpc::new(codec)
612 .apply_compression_config(
613 accept_compression_encodings,
614 send_compression_encodings,
615 )
616 .apply_max_message_size_config(
617 max_decoding_message_size,
618 max_encoding_message_size,
619 );
620 let res = grpc.unary(method, req).await;
621 Ok(res)
622 };
623 Box::pin(fut)
624 }
625 "/deq.decoder.blackbox_decoder.BlackBoxDecoder/LoadHypergraph" => {
626 #[allow(non_camel_case_types)]
627 struct LoadHypergraphSvc<T: BlackBoxDecoder>(pub Arc<T>);
628 impl<
629 T: BlackBoxDecoder,
630 > tonic::server::UnaryService<super::DecodingHypergraph>
631 for LoadHypergraphSvc<T> {
632 type Response = super::LoadHypergraphResponse;
633 type Future = BoxFuture<
634 tonic::Response<Self::Response>,
635 tonic::Status,
636 >;
637 fn call(
638 &mut self,
639 request: tonic::Request<super::DecodingHypergraph>,
640 ) -> Self::Future {
641 let inner = Arc::clone(&self.0);
642 let fut = async move {
643 <T as BlackBoxDecoder>::load_hypergraph(&inner, request)
644 .await
645 };
646 Box::pin(fut)
647 }
648 }
649 let accept_compression_encodings = self.accept_compression_encodings;
650 let send_compression_encodings = self.send_compression_encodings;
651 let max_decoding_message_size = self.max_decoding_message_size;
652 let max_encoding_message_size = self.max_encoding_message_size;
653 let inner = self.inner.clone();
654 let fut = async move {
655 let method = LoadHypergraphSvc(inner);
656 let codec = tonic_prost::ProstCodec::default();
657 let mut grpc = tonic::server::Grpc::new(codec)
658 .apply_compression_config(
659 accept_compression_encodings,
660 send_compression_encodings,
661 )
662 .apply_max_message_size_config(
663 max_decoding_message_size,
664 max_encoding_message_size,
665 );
666 let res = grpc.unary(method, req).await;
667 Ok(res)
668 };
669 Box::pin(fut)
670 }
671 "/deq.decoder.blackbox_decoder.BlackBoxDecoder/DecodeLoaded" => {
672 #[allow(non_camel_case_types)]
673 struct DecodeLoadedSvc<T: BlackBoxDecoder>(pub Arc<T>);
674 impl<
675 T: BlackBoxDecoder,
676 > tonic::server::UnaryService<super::LoadedDecodingProblem>
677 for DecodeLoadedSvc<T> {
678 type Response = super::ParityFactor;
679 type Future = BoxFuture<
680 tonic::Response<Self::Response>,
681 tonic::Status,
682 >;
683 fn call(
684 &mut self,
685 request: tonic::Request<super::LoadedDecodingProblem>,
686 ) -> Self::Future {
687 let inner = Arc::clone(&self.0);
688 let fut = async move {
689 <T as BlackBoxDecoder>::decode_loaded(&inner, request).await
690 };
691 Box::pin(fut)
692 }
693 }
694 let accept_compression_encodings = self.accept_compression_encodings;
695 let send_compression_encodings = self.send_compression_encodings;
696 let max_decoding_message_size = self.max_decoding_message_size;
697 let max_encoding_message_size = self.max_encoding_message_size;
698 let inner = self.inner.clone();
699 let fut = async move {
700 let method = DecodeLoadedSvc(inner);
701 let codec = tonic_prost::ProstCodec::default();
702 let mut grpc = tonic::server::Grpc::new(codec)
703 .apply_compression_config(
704 accept_compression_encodings,
705 send_compression_encodings,
706 )
707 .apply_max_message_size_config(
708 max_decoding_message_size,
709 max_encoding_message_size,
710 );
711 let res = grpc.unary(method, req).await;
712 Ok(res)
713 };
714 Box::pin(fut)
715 }
716 "/deq.decoder.blackbox_decoder.BlackBoxDecoder/Reset" => {
717 #[allow(non_camel_case_types)]
718 struct ResetSvc<T: BlackBoxDecoder>(pub Arc<T>);
719 impl<
720 T: BlackBoxDecoder,
721 > tonic::server::UnaryService<super::ResetRequest> for ResetSvc<T> {
722 type Response = ();
723 type Future = BoxFuture<
724 tonic::Response<Self::Response>,
725 tonic::Status,
726 >;
727 fn call(
728 &mut self,
729 request: tonic::Request<super::ResetRequest>,
730 ) -> Self::Future {
731 let inner = Arc::clone(&self.0);
732 let fut = async move {
733 <T as BlackBoxDecoder>::reset(&inner, request).await
734 };
735 Box::pin(fut)
736 }
737 }
738 let accept_compression_encodings = self.accept_compression_encodings;
739 let send_compression_encodings = self.send_compression_encodings;
740 let max_decoding_message_size = self.max_decoding_message_size;
741 let max_encoding_message_size = self.max_encoding_message_size;
742 let inner = self.inner.clone();
743 let fut = async move {
744 let method = ResetSvc(inner);
745 let codec = tonic_prost::ProstCodec::default();
746 let mut grpc = tonic::server::Grpc::new(codec)
747 .apply_compression_config(
748 accept_compression_encodings,
749 send_compression_encodings,
750 )
751 .apply_max_message_size_config(
752 max_decoding_message_size,
753 max_encoding_message_size,
754 );
755 let res = grpc.unary(method, req).await;
756 Ok(res)
757 };
758 Box::pin(fut)
759 }
760 _ => {
761 Box::pin(async move {
762 let mut response = http::Response::new(
763 tonic::body::Body::default(),
764 );
765 let headers = response.headers_mut();
766 headers
767 .insert(
768 tonic::Status::GRPC_STATUS,
769 (tonic::Code::Unimplemented as i32).into(),
770 );
771 headers
772 .insert(
773 http::header::CONTENT_TYPE,
774 tonic::metadata::GRPC_CONTENT_TYPE,
775 );
776 Ok(response)
777 })
778 }
779 }
780 }
781 }
782 impl<T> Clone for BlackBoxDecoderServer<T> {
783 fn clone(&self) -> Self {
784 let inner = self.inner.clone();
785 Self {
786 inner,
787 accept_compression_encodings: self.accept_compression_encodings,
788 send_compression_encodings: self.send_compression_encodings,
789 max_decoding_message_size: self.max_decoding_message_size,
790 max_encoding_message_size: self.max_encoding_message_size,
791 }
792 }
793 }
794 pub const SERVICE_NAME: &str = "deq.decoder.blackbox_decoder.BlackBoxDecoder";
796 impl<T> tonic::server::NamedService for BlackBoxDecoderServer<T> {
797 const NAME: &'static str = SERVICE_NAME;
798 }
799}