1#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
3pub struct UnloadLibrary {
4 #[prost(uint64, repeated, tag = "1")]
5 pub gtype: ::prost::alloc::vec::Vec<u64>,
6 #[prost(uint64, repeated, tag = "2")]
7 pub ctype: ::prost::alloc::vec::Vec<u64>,
8 #[prost(uint64, repeated, tag = "3")]
9 pub etype: ::prost::alloc::vec::Vec<u64>,
10}
11#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
12pub struct ResetRequest {
13 #[prost(bool, tag = "1")]
16 pub reset_library: bool,
17 #[prost(bool, tag = "2")]
21 pub reset_decoder_service: bool,
22 #[prost(string, tag = "200")]
24 pub custom: ::prost::alloc::string::String,
25}
26#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
27pub struct ExecuteResponse {
28 #[prost(uint64, tag = "1")]
31 pub id: u64,
32}
33#[derive(Clone, PartialEq, ::prost::Message)]
34pub struct Outcomes {
35 #[prost(uint64, tag = "1")]
37 pub gid: u64,
38 #[prost(message, optional, tag = "2")]
41 pub outcomes: ::core::option::Option<super::util::BitVector>,
42 #[prost(message, repeated, tag = "3")]
51 pub modifiers: ::prost::alloc::vec::Vec<super::bin::ProbabilityModifier>,
52 #[prost(message, optional, tag = "4")]
60 pub loss_mask: ::core::option::Option<super::util::BitVector>,
61 #[prost(uint64, optional, tag = "5")]
65 pub decoder_seed: ::core::option::Option<u64>,
66}
67#[derive(Clone, PartialEq, ::prost::Message)]
68pub struct Readouts {
69 #[prost(uint64, tag = "1")]
71 pub gid: u64,
72 #[prost(message, optional, tag = "2")]
75 pub readouts: ::core::option::Option<super::util::BitVector>,
76 #[prost(double, repeated, tag = "3")]
80 pub probabilities: ::prost::alloc::vec::Vec<f64>,
81 #[prost(uint64, tag = "4")]
83 pub syndrome_count: u64,
84 #[prost(uint64, tag = "5")]
87 pub correction_count: u64,
88 #[prost(double, tag = "6")]
91 pub correction_weight: f64,
92 #[prost(double, repeated, tag = "7")]
102 pub frame_probabilities: ::prost::alloc::vec::Vec<f64>,
103}
104#[cfg(feature = "cli")]
106pub mod coordinator_client {
107 #![allow(
108 unused_variables,
109 dead_code,
110 missing_docs,
111 clippy::wildcard_imports,
112 clippy::let_unit_value,
113 )]
114 use tonic::codegen::*;
115 use tonic::codegen::http::Uri;
116 #[derive(Debug, Clone)]
117 pub struct CoordinatorClient<T> {
118 inner: tonic::client::Grpc<T>,
119 }
120 impl CoordinatorClient<tonic::transport::Channel> {
121 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
123 where
124 D: TryInto<tonic::transport::Endpoint>,
125 D::Error: Into<StdError>,
126 {
127 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
128 Ok(Self::new(conn))
129 }
130 }
131 impl<T> CoordinatorClient<T>
132 where
133 T: tonic::client::GrpcService<tonic::body::Body>,
134 T::Error: Into<StdError>,
135 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
136 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
137 {
138 pub fn new(inner: T) -> Self {
139 let inner = tonic::client::Grpc::new(inner);
140 Self { inner }
141 }
142 pub fn with_origin(inner: T, origin: Uri) -> Self {
143 let inner = tonic::client::Grpc::with_origin(inner, origin);
144 Self { inner }
145 }
146 pub fn with_interceptor<F>(
147 inner: T,
148 interceptor: F,
149 ) -> CoordinatorClient<InterceptedService<T, F>>
150 where
151 F: tonic::service::Interceptor,
152 T::ResponseBody: Default,
153 T: tonic::codegen::Service<
154 http::Request<tonic::body::Body>,
155 Response = http::Response<
156 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
157 >,
158 >,
159 <T as tonic::codegen::Service<
160 http::Request<tonic::body::Body>,
161 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
162 {
163 CoordinatorClient::new(InterceptedService::new(inner, interceptor))
164 }
165 #[must_use]
170 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
171 self.inner = self.inner.send_compressed(encoding);
172 self
173 }
174 #[must_use]
176 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
177 self.inner = self.inner.accept_compressed(encoding);
178 self
179 }
180 #[must_use]
184 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
185 self.inner = self.inner.max_decoding_message_size(limit);
186 self
187 }
188 #[must_use]
192 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
193 self.inner = self.inner.max_encoding_message_size(limit);
194 self
195 }
196 pub async fn load_library(
199 &mut self,
200 request: impl tonic::IntoRequest<super::super::bin::Library>,
201 ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
202 self.inner
203 .ready()
204 .await
205 .map_err(|e| {
206 tonic::Status::unknown(
207 format!("Service was not ready: {}", e.into()),
208 )
209 })?;
210 let codec = tonic_prost::ProstCodec::default();
211 let path = http::uri::PathAndQuery::from_static(
212 "/deq.coordinator.Coordinator/LoadLibrary",
213 );
214 let mut req = request.into_request();
215 req.extensions_mut()
216 .insert(GrpcMethod::new("deq.coordinator.Coordinator", "LoadLibrary"));
217 self.inner.unary(req, path, codec).await
218 }
219 pub async fn unload(
221 &mut self,
222 request: impl tonic::IntoRequest<super::UnloadLibrary>,
223 ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
224 self.inner
225 .ready()
226 .await
227 .map_err(|e| {
228 tonic::Status::unknown(
229 format!("Service was not ready: {}", e.into()),
230 )
231 })?;
232 let codec = tonic_prost::ProstCodec::default();
233 let path = http::uri::PathAndQuery::from_static(
234 "/deq.coordinator.Coordinator/Unload",
235 );
236 let mut req = request.into_request();
237 req.extensions_mut()
238 .insert(GrpcMethod::new("deq.coordinator.Coordinator", "Unload"));
239 self.inner.unary(req, path, codec).await
240 }
241 pub async fn execute(
244 &mut self,
245 request: impl tonic::IntoRequest<super::super::bin::Instruction>,
246 ) -> std::result::Result<
247 tonic::Response<super::ExecuteResponse>,
248 tonic::Status,
249 > {
250 self.inner
251 .ready()
252 .await
253 .map_err(|e| {
254 tonic::Status::unknown(
255 format!("Service was not ready: {}", e.into()),
256 )
257 })?;
258 let codec = tonic_prost::ProstCodec::default();
259 let path = http::uri::PathAndQuery::from_static(
260 "/deq.coordinator.Coordinator/Execute",
261 );
262 let mut req = request.into_request();
263 req.extensions_mut()
264 .insert(GrpcMethod::new("deq.coordinator.Coordinator", "Execute"));
265 self.inner.unary(req, path, codec).await
266 }
267 pub async fn decode(
271 &mut self,
272 request: impl tonic::IntoRequest<super::Outcomes>,
273 ) -> std::result::Result<tonic::Response<super::Readouts>, tonic::Status> {
274 self.inner
275 .ready()
276 .await
277 .map_err(|e| {
278 tonic::Status::unknown(
279 format!("Service was not ready: {}", e.into()),
280 )
281 })?;
282 let codec = tonic_prost::ProstCodec::default();
283 let path = http::uri::PathAndQuery::from_static(
284 "/deq.coordinator.Coordinator/Decode",
285 );
286 let mut req = request.into_request();
287 req.extensions_mut()
288 .insert(GrpcMethod::new("deq.coordinator.Coordinator", "Decode"));
289 self.inner.unary(req, path, codec).await
290 }
291 pub async fn reset(
293 &mut self,
294 request: impl tonic::IntoRequest<super::ResetRequest>,
295 ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
296 self.inner
297 .ready()
298 .await
299 .map_err(|e| {
300 tonic::Status::unknown(
301 format!("Service was not ready: {}", e.into()),
302 )
303 })?;
304 let codec = tonic_prost::ProstCodec::default();
305 let path = http::uri::PathAndQuery::from_static(
306 "/deq.coordinator.Coordinator/Reset",
307 );
308 let mut req = request.into_request();
309 req.extensions_mut()
310 .insert(GrpcMethod::new("deq.coordinator.Coordinator", "Reset"));
311 self.inner.unary(req, path, codec).await
312 }
313 }
314}
315pub mod coordinator_server {
317 #![allow(
318 unused_variables,
319 dead_code,
320 missing_docs,
321 clippy::wildcard_imports,
322 clippy::let_unit_value,
323 )]
324 use tonic::codegen::*;
325 #[async_trait]
327 pub trait Coordinator: std::marker::Send + std::marker::Sync + 'static {
328 async fn load_library(
331 &self,
332 request: tonic::Request<super::super::bin::Library>,
333 ) -> std::result::Result<tonic::Response<()>, tonic::Status>;
334 async fn unload(
336 &self,
337 request: tonic::Request<super::UnloadLibrary>,
338 ) -> std::result::Result<tonic::Response<()>, tonic::Status>;
339 async fn execute(
342 &self,
343 request: tonic::Request<super::super::bin::Instruction>,
344 ) -> std::result::Result<tonic::Response<super::ExecuteResponse>, tonic::Status>;
345 async fn decode(
349 &self,
350 request: tonic::Request<super::Outcomes>,
351 ) -> std::result::Result<tonic::Response<super::Readouts>, tonic::Status>;
352 async fn reset(
354 &self,
355 request: tonic::Request<super::ResetRequest>,
356 ) -> std::result::Result<tonic::Response<()>, tonic::Status>;
357 }
358 #[derive(Debug)]
359 pub struct CoordinatorServer<T> {
360 inner: Arc<T>,
361 accept_compression_encodings: EnabledCompressionEncodings,
362 send_compression_encodings: EnabledCompressionEncodings,
363 max_decoding_message_size: Option<usize>,
364 max_encoding_message_size: Option<usize>,
365 }
366 impl<T> CoordinatorServer<T> {
367 pub fn new(inner: T) -> Self {
368 Self::from_arc(Arc::new(inner))
369 }
370 pub fn from_arc(inner: Arc<T>) -> Self {
371 Self {
372 inner,
373 accept_compression_encodings: Default::default(),
374 send_compression_encodings: Default::default(),
375 max_decoding_message_size: None,
376 max_encoding_message_size: None,
377 }
378 }
379 pub fn with_interceptor<F>(
380 inner: T,
381 interceptor: F,
382 ) -> InterceptedService<Self, F>
383 where
384 F: tonic::service::Interceptor,
385 {
386 InterceptedService::new(Self::new(inner), interceptor)
387 }
388 #[must_use]
390 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
391 self.accept_compression_encodings.enable(encoding);
392 self
393 }
394 #[must_use]
396 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
397 self.send_compression_encodings.enable(encoding);
398 self
399 }
400 #[must_use]
404 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
405 self.max_decoding_message_size = Some(limit);
406 self
407 }
408 #[must_use]
412 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
413 self.max_encoding_message_size = Some(limit);
414 self
415 }
416 }
417 impl<T, B> tonic::codegen::Service<http::Request<B>> for CoordinatorServer<T>
418 where
419 T: Coordinator,
420 B: Body + std::marker::Send + 'static,
421 B::Error: Into<StdError> + std::marker::Send + 'static,
422 {
423 type Response = http::Response<tonic::body::Body>;
424 type Error = std::convert::Infallible;
425 type Future = BoxFuture<Self::Response, Self::Error>;
426 fn poll_ready(
427 &mut self,
428 _cx: &mut Context<'_>,
429 ) -> Poll<std::result::Result<(), Self::Error>> {
430 Poll::Ready(Ok(()))
431 }
432 fn call(&mut self, req: http::Request<B>) -> Self::Future {
433 match req.uri().path() {
434 "/deq.coordinator.Coordinator/LoadLibrary" => {
435 #[allow(non_camel_case_types)]
436 struct LoadLibrarySvc<T: Coordinator>(pub Arc<T>);
437 impl<
438 T: Coordinator,
439 > tonic::server::UnaryService<super::super::bin::Library>
440 for LoadLibrarySvc<T> {
441 type Response = ();
442 type Future = BoxFuture<
443 tonic::Response<Self::Response>,
444 tonic::Status,
445 >;
446 fn call(
447 &mut self,
448 request: tonic::Request<super::super::bin::Library>,
449 ) -> Self::Future {
450 let inner = Arc::clone(&self.0);
451 let fut = async move {
452 <T as Coordinator>::load_library(&inner, request).await
453 };
454 Box::pin(fut)
455 }
456 }
457 let accept_compression_encodings = self.accept_compression_encodings;
458 let send_compression_encodings = self.send_compression_encodings;
459 let max_decoding_message_size = self.max_decoding_message_size;
460 let max_encoding_message_size = self.max_encoding_message_size;
461 let inner = self.inner.clone();
462 let fut = async move {
463 let method = LoadLibrarySvc(inner);
464 let codec = tonic_prost::ProstCodec::default();
465 let mut grpc = tonic::server::Grpc::new(codec)
466 .apply_compression_config(
467 accept_compression_encodings,
468 send_compression_encodings,
469 )
470 .apply_max_message_size_config(
471 max_decoding_message_size,
472 max_encoding_message_size,
473 );
474 let res = grpc.unary(method, req).await;
475 Ok(res)
476 };
477 Box::pin(fut)
478 }
479 "/deq.coordinator.Coordinator/Unload" => {
480 #[allow(non_camel_case_types)]
481 struct UnloadSvc<T: Coordinator>(pub Arc<T>);
482 impl<
483 T: Coordinator,
484 > tonic::server::UnaryService<super::UnloadLibrary>
485 for UnloadSvc<T> {
486 type Response = ();
487 type Future = BoxFuture<
488 tonic::Response<Self::Response>,
489 tonic::Status,
490 >;
491 fn call(
492 &mut self,
493 request: tonic::Request<super::UnloadLibrary>,
494 ) -> Self::Future {
495 let inner = Arc::clone(&self.0);
496 let fut = async move {
497 <T as Coordinator>::unload(&inner, request).await
498 };
499 Box::pin(fut)
500 }
501 }
502 let accept_compression_encodings = self.accept_compression_encodings;
503 let send_compression_encodings = self.send_compression_encodings;
504 let max_decoding_message_size = self.max_decoding_message_size;
505 let max_encoding_message_size = self.max_encoding_message_size;
506 let inner = self.inner.clone();
507 let fut = async move {
508 let method = UnloadSvc(inner);
509 let codec = tonic_prost::ProstCodec::default();
510 let mut grpc = tonic::server::Grpc::new(codec)
511 .apply_compression_config(
512 accept_compression_encodings,
513 send_compression_encodings,
514 )
515 .apply_max_message_size_config(
516 max_decoding_message_size,
517 max_encoding_message_size,
518 );
519 let res = grpc.unary(method, req).await;
520 Ok(res)
521 };
522 Box::pin(fut)
523 }
524 "/deq.coordinator.Coordinator/Execute" => {
525 #[allow(non_camel_case_types)]
526 struct ExecuteSvc<T: Coordinator>(pub Arc<T>);
527 impl<
528 T: Coordinator,
529 > tonic::server::UnaryService<super::super::bin::Instruction>
530 for ExecuteSvc<T> {
531 type Response = super::ExecuteResponse;
532 type Future = BoxFuture<
533 tonic::Response<Self::Response>,
534 tonic::Status,
535 >;
536 fn call(
537 &mut self,
538 request: tonic::Request<super::super::bin::Instruction>,
539 ) -> Self::Future {
540 let inner = Arc::clone(&self.0);
541 let fut = async move {
542 <T as Coordinator>::execute(&inner, request).await
543 };
544 Box::pin(fut)
545 }
546 }
547 let accept_compression_encodings = self.accept_compression_encodings;
548 let send_compression_encodings = self.send_compression_encodings;
549 let max_decoding_message_size = self.max_decoding_message_size;
550 let max_encoding_message_size = self.max_encoding_message_size;
551 let inner = self.inner.clone();
552 let fut = async move {
553 let method = ExecuteSvc(inner);
554 let codec = tonic_prost::ProstCodec::default();
555 let mut grpc = tonic::server::Grpc::new(codec)
556 .apply_compression_config(
557 accept_compression_encodings,
558 send_compression_encodings,
559 )
560 .apply_max_message_size_config(
561 max_decoding_message_size,
562 max_encoding_message_size,
563 );
564 let res = grpc.unary(method, req).await;
565 Ok(res)
566 };
567 Box::pin(fut)
568 }
569 "/deq.coordinator.Coordinator/Decode" => {
570 #[allow(non_camel_case_types)]
571 struct DecodeSvc<T: Coordinator>(pub Arc<T>);
572 impl<T: Coordinator> tonic::server::UnaryService<super::Outcomes>
573 for DecodeSvc<T> {
574 type Response = super::Readouts;
575 type Future = BoxFuture<
576 tonic::Response<Self::Response>,
577 tonic::Status,
578 >;
579 fn call(
580 &mut self,
581 request: tonic::Request<super::Outcomes>,
582 ) -> Self::Future {
583 let inner = Arc::clone(&self.0);
584 let fut = async move {
585 <T as Coordinator>::decode(&inner, request).await
586 };
587 Box::pin(fut)
588 }
589 }
590 let accept_compression_encodings = self.accept_compression_encodings;
591 let send_compression_encodings = self.send_compression_encodings;
592 let max_decoding_message_size = self.max_decoding_message_size;
593 let max_encoding_message_size = self.max_encoding_message_size;
594 let inner = self.inner.clone();
595 let fut = async move {
596 let method = DecodeSvc(inner);
597 let codec = tonic_prost::ProstCodec::default();
598 let mut grpc = tonic::server::Grpc::new(codec)
599 .apply_compression_config(
600 accept_compression_encodings,
601 send_compression_encodings,
602 )
603 .apply_max_message_size_config(
604 max_decoding_message_size,
605 max_encoding_message_size,
606 );
607 let res = grpc.unary(method, req).await;
608 Ok(res)
609 };
610 Box::pin(fut)
611 }
612 "/deq.coordinator.Coordinator/Reset" => {
613 #[allow(non_camel_case_types)]
614 struct ResetSvc<T: Coordinator>(pub Arc<T>);
615 impl<T: Coordinator> tonic::server::UnaryService<super::ResetRequest>
616 for ResetSvc<T> {
617 type Response = ();
618 type Future = BoxFuture<
619 tonic::Response<Self::Response>,
620 tonic::Status,
621 >;
622 fn call(
623 &mut self,
624 request: tonic::Request<super::ResetRequest>,
625 ) -> Self::Future {
626 let inner = Arc::clone(&self.0);
627 let fut = async move {
628 <T as Coordinator>::reset(&inner, request).await
629 };
630 Box::pin(fut)
631 }
632 }
633 let accept_compression_encodings = self.accept_compression_encodings;
634 let send_compression_encodings = self.send_compression_encodings;
635 let max_decoding_message_size = self.max_decoding_message_size;
636 let max_encoding_message_size = self.max_encoding_message_size;
637 let inner = self.inner.clone();
638 let fut = async move {
639 let method = ResetSvc(inner);
640 let codec = tonic_prost::ProstCodec::default();
641 let mut grpc = tonic::server::Grpc::new(codec)
642 .apply_compression_config(
643 accept_compression_encodings,
644 send_compression_encodings,
645 )
646 .apply_max_message_size_config(
647 max_decoding_message_size,
648 max_encoding_message_size,
649 );
650 let res = grpc.unary(method, req).await;
651 Ok(res)
652 };
653 Box::pin(fut)
654 }
655 _ => {
656 Box::pin(async move {
657 let mut response = http::Response::new(
658 tonic::body::Body::default(),
659 );
660 let headers = response.headers_mut();
661 headers
662 .insert(
663 tonic::Status::GRPC_STATUS,
664 (tonic::Code::Unimplemented as i32).into(),
665 );
666 headers
667 .insert(
668 http::header::CONTENT_TYPE,
669 tonic::metadata::GRPC_CONTENT_TYPE,
670 );
671 Ok(response)
672 })
673 }
674 }
675 }
676 }
677 impl<T> Clone for CoordinatorServer<T> {
678 fn clone(&self) -> Self {
679 let inner = self.inner.clone();
680 Self {
681 inner,
682 accept_compression_encodings: self.accept_compression_encodings,
683 send_compression_encodings: self.send_compression_encodings,
684 max_decoding_message_size: self.max_decoding_message_size,
685 max_encoding_message_size: self.max_encoding_message_size,
686 }
687 }
688 }
689 pub const SERVICE_NAME: &str = "deq.coordinator.Coordinator";
691 impl<T> tonic::server::NamedService for CoordinatorServer<T> {
692 const NAME: &'static str = SERVICE_NAME;
693 }
694}