1#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct BatchReadouts {
4 #[prost(message, repeated, tag = "1")]
5 pub readouts: ::prost::alloc::vec::Vec<super::super::coordinator::Readouts>,
6}
7#[cfg(feature = "cli")]
9pub mod static_controller_client {
10 #![allow(
11 unused_variables,
12 dead_code,
13 missing_docs,
14 clippy::wildcard_imports,
15 clippy::let_unit_value,
16 )]
17 use tonic::codegen::*;
18 use tonic::codegen::http::Uri;
19 #[derive(Debug, Clone)]
20 pub struct StaticControllerClient<T> {
21 inner: tonic::client::Grpc<T>,
22 }
23 impl StaticControllerClient<tonic::transport::Channel> {
24 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
26 where
27 D: TryInto<tonic::transport::Endpoint>,
28 D::Error: Into<StdError>,
29 {
30 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
31 Ok(Self::new(conn))
32 }
33 }
34 impl<T> StaticControllerClient<T>
35 where
36 T: tonic::client::GrpcService<tonic::body::Body>,
37 T::Error: Into<StdError>,
38 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
39 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
40 {
41 pub fn new(inner: T) -> Self {
42 let inner = tonic::client::Grpc::new(inner);
43 Self { inner }
44 }
45 pub fn with_origin(inner: T, origin: Uri) -> Self {
46 let inner = tonic::client::Grpc::with_origin(inner, origin);
47 Self { inner }
48 }
49 pub fn with_interceptor<F>(
50 inner: T,
51 interceptor: F,
52 ) -> StaticControllerClient<InterceptedService<T, F>>
53 where
54 F: tonic::service::Interceptor,
55 T::ResponseBody: Default,
56 T: tonic::codegen::Service<
57 http::Request<tonic::body::Body>,
58 Response = http::Response<
59 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
60 >,
61 >,
62 <T as tonic::codegen::Service<
63 http::Request<tonic::body::Body>,
64 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
65 {
66 StaticControllerClient::new(InterceptedService::new(inner, interceptor))
67 }
68 #[must_use]
73 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
74 self.inner = self.inner.send_compressed(encoding);
75 self
76 }
77 #[must_use]
79 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
80 self.inner = self.inner.accept_compressed(encoding);
81 self
82 }
83 #[must_use]
87 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
88 self.inner = self.inner.max_decoding_message_size(limit);
89 self
90 }
91 #[must_use]
95 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
96 self.inner = self.inner.max_encoding_message_size(limit);
97 self
98 }
99 pub async fn decode(
115 &mut self,
116 request: impl tonic::IntoRequest<super::super::super::coordinator::Outcomes>,
117 ) -> std::result::Result<
118 tonic::Response<super::super::super::coordinator::Readouts>,
119 tonic::Status,
120 > {
121 self.inner
122 .ready()
123 .await
124 .map_err(|e| {
125 tonic::Status::unknown(
126 format!("Service was not ready: {}", e.into()),
127 )
128 })?;
129 let codec = tonic_prost::ProstCodec::default();
130 let path = http::uri::PathAndQuery::from_static(
131 "/deq.controller.static_controller.StaticController/Decode",
132 );
133 let mut req = request.into_request();
134 req.extensions_mut()
135 .insert(
136 GrpcMethod::new(
137 "deq.controller.static_controller.StaticController",
138 "Decode",
139 ),
140 );
141 self.inner.unary(req, path, codec).await
142 }
143 pub async fn decode_gadgets(
147 &mut self,
148 request: impl tonic::IntoRequest<super::super::super::coordinator::Outcomes>,
149 ) -> std::result::Result<tonic::Response<super::BatchReadouts>, tonic::Status> {
150 self.inner
151 .ready()
152 .await
153 .map_err(|e| {
154 tonic::Status::unknown(
155 format!("Service was not ready: {}", e.into()),
156 )
157 })?;
158 let codec = tonic_prost::ProstCodec::default();
159 let path = http::uri::PathAndQuery::from_static(
160 "/deq.controller.static_controller.StaticController/DecodeGadgets",
161 );
162 let mut req = request.into_request();
163 req.extensions_mut()
164 .insert(
165 GrpcMethod::new(
166 "deq.controller.static_controller.StaticController",
167 "DecodeGadgets",
168 ),
169 );
170 self.inner.unary(req, path, codec).await
171 }
172 pub async fn reset(
174 &mut self,
175 request: impl tonic::IntoRequest<()>,
176 ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
177 self.inner
178 .ready()
179 .await
180 .map_err(|e| {
181 tonic::Status::unknown(
182 format!("Service was not ready: {}", e.into()),
183 )
184 })?;
185 let codec = tonic_prost::ProstCodec::default();
186 let path = http::uri::PathAndQuery::from_static(
187 "/deq.controller.static_controller.StaticController/Reset",
188 );
189 let mut req = request.into_request();
190 req.extensions_mut()
191 .insert(
192 GrpcMethod::new(
193 "deq.controller.static_controller.StaticController",
194 "Reset",
195 ),
196 );
197 self.inner.unary(req, path, codec).await
198 }
199 }
200}
201pub mod static_controller_server {
203 #![allow(
204 unused_variables,
205 dead_code,
206 missing_docs,
207 clippy::wildcard_imports,
208 clippy::let_unit_value,
209 )]
210 use tonic::codegen::*;
211 #[async_trait]
213 pub trait StaticController: std::marker::Send + std::marker::Sync + 'static {
214 async fn decode(
230 &self,
231 request: tonic::Request<super::super::super::coordinator::Outcomes>,
232 ) -> std::result::Result<
233 tonic::Response<super::super::super::coordinator::Readouts>,
234 tonic::Status,
235 >;
236 async fn decode_gadgets(
240 &self,
241 request: tonic::Request<super::super::super::coordinator::Outcomes>,
242 ) -> std::result::Result<tonic::Response<super::BatchReadouts>, tonic::Status>;
243 async fn reset(
245 &self,
246 request: tonic::Request<()>,
247 ) -> std::result::Result<tonic::Response<()>, tonic::Status>;
248 }
249 #[derive(Debug)]
250 pub struct StaticControllerServer<T> {
251 inner: Arc<T>,
252 accept_compression_encodings: EnabledCompressionEncodings,
253 send_compression_encodings: EnabledCompressionEncodings,
254 max_decoding_message_size: Option<usize>,
255 max_encoding_message_size: Option<usize>,
256 }
257 impl<T> StaticControllerServer<T> {
258 pub fn new(inner: T) -> Self {
259 Self::from_arc(Arc::new(inner))
260 }
261 pub fn from_arc(inner: Arc<T>) -> Self {
262 Self {
263 inner,
264 accept_compression_encodings: Default::default(),
265 send_compression_encodings: Default::default(),
266 max_decoding_message_size: None,
267 max_encoding_message_size: None,
268 }
269 }
270 pub fn with_interceptor<F>(
271 inner: T,
272 interceptor: F,
273 ) -> InterceptedService<Self, F>
274 where
275 F: tonic::service::Interceptor,
276 {
277 InterceptedService::new(Self::new(inner), interceptor)
278 }
279 #[must_use]
281 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
282 self.accept_compression_encodings.enable(encoding);
283 self
284 }
285 #[must_use]
287 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
288 self.send_compression_encodings.enable(encoding);
289 self
290 }
291 #[must_use]
295 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
296 self.max_decoding_message_size = Some(limit);
297 self
298 }
299 #[must_use]
303 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
304 self.max_encoding_message_size = Some(limit);
305 self
306 }
307 }
308 impl<T, B> tonic::codegen::Service<http::Request<B>> for StaticControllerServer<T>
309 where
310 T: StaticController,
311 B: Body + std::marker::Send + 'static,
312 B::Error: Into<StdError> + std::marker::Send + 'static,
313 {
314 type Response = http::Response<tonic::body::Body>;
315 type Error = std::convert::Infallible;
316 type Future = BoxFuture<Self::Response, Self::Error>;
317 fn poll_ready(
318 &mut self,
319 _cx: &mut Context<'_>,
320 ) -> Poll<std::result::Result<(), Self::Error>> {
321 Poll::Ready(Ok(()))
322 }
323 fn call(&mut self, req: http::Request<B>) -> Self::Future {
324 match req.uri().path() {
325 "/deq.controller.static_controller.StaticController/Decode" => {
326 #[allow(non_camel_case_types)]
327 struct DecodeSvc<T: StaticController>(pub Arc<T>);
328 impl<
329 T: StaticController,
330 > tonic::server::UnaryService<
331 super::super::super::coordinator::Outcomes,
332 > for DecodeSvc<T> {
333 type Response = super::super::super::coordinator::Readouts;
334 type Future = BoxFuture<
335 tonic::Response<Self::Response>,
336 tonic::Status,
337 >;
338 fn call(
339 &mut self,
340 request: tonic::Request<
341 super::super::super::coordinator::Outcomes,
342 >,
343 ) -> Self::Future {
344 let inner = Arc::clone(&self.0);
345 let fut = async move {
346 <T as StaticController>::decode(&inner, request).await
347 };
348 Box::pin(fut)
349 }
350 }
351 let accept_compression_encodings = self.accept_compression_encodings;
352 let send_compression_encodings = self.send_compression_encodings;
353 let max_decoding_message_size = self.max_decoding_message_size;
354 let max_encoding_message_size = self.max_encoding_message_size;
355 let inner = self.inner.clone();
356 let fut = async move {
357 let method = DecodeSvc(inner);
358 let codec = tonic_prost::ProstCodec::default();
359 let mut grpc = tonic::server::Grpc::new(codec)
360 .apply_compression_config(
361 accept_compression_encodings,
362 send_compression_encodings,
363 )
364 .apply_max_message_size_config(
365 max_decoding_message_size,
366 max_encoding_message_size,
367 );
368 let res = grpc.unary(method, req).await;
369 Ok(res)
370 };
371 Box::pin(fut)
372 }
373 "/deq.controller.static_controller.StaticController/DecodeGadgets" => {
374 #[allow(non_camel_case_types)]
375 struct DecodeGadgetsSvc<T: StaticController>(pub Arc<T>);
376 impl<
377 T: StaticController,
378 > tonic::server::UnaryService<
379 super::super::super::coordinator::Outcomes,
380 > for DecodeGadgetsSvc<T> {
381 type Response = super::BatchReadouts;
382 type Future = BoxFuture<
383 tonic::Response<Self::Response>,
384 tonic::Status,
385 >;
386 fn call(
387 &mut self,
388 request: tonic::Request<
389 super::super::super::coordinator::Outcomes,
390 >,
391 ) -> Self::Future {
392 let inner = Arc::clone(&self.0);
393 let fut = async move {
394 <T as StaticController>::decode_gadgets(&inner, request)
395 .await
396 };
397 Box::pin(fut)
398 }
399 }
400 let accept_compression_encodings = self.accept_compression_encodings;
401 let send_compression_encodings = self.send_compression_encodings;
402 let max_decoding_message_size = self.max_decoding_message_size;
403 let max_encoding_message_size = self.max_encoding_message_size;
404 let inner = self.inner.clone();
405 let fut = async move {
406 let method = DecodeGadgetsSvc(inner);
407 let codec = tonic_prost::ProstCodec::default();
408 let mut grpc = tonic::server::Grpc::new(codec)
409 .apply_compression_config(
410 accept_compression_encodings,
411 send_compression_encodings,
412 )
413 .apply_max_message_size_config(
414 max_decoding_message_size,
415 max_encoding_message_size,
416 );
417 let res = grpc.unary(method, req).await;
418 Ok(res)
419 };
420 Box::pin(fut)
421 }
422 "/deq.controller.static_controller.StaticController/Reset" => {
423 #[allow(non_camel_case_types)]
424 struct ResetSvc<T: StaticController>(pub Arc<T>);
425 impl<T: StaticController> tonic::server::UnaryService<()>
426 for ResetSvc<T> {
427 type Response = ();
428 type Future = BoxFuture<
429 tonic::Response<Self::Response>,
430 tonic::Status,
431 >;
432 fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
433 let inner = Arc::clone(&self.0);
434 let fut = async move {
435 <T as StaticController>::reset(&inner, request).await
436 };
437 Box::pin(fut)
438 }
439 }
440 let accept_compression_encodings = self.accept_compression_encodings;
441 let send_compression_encodings = self.send_compression_encodings;
442 let max_decoding_message_size = self.max_decoding_message_size;
443 let max_encoding_message_size = self.max_encoding_message_size;
444 let inner = self.inner.clone();
445 let fut = async move {
446 let method = ResetSvc(inner);
447 let codec = tonic_prost::ProstCodec::default();
448 let mut grpc = tonic::server::Grpc::new(codec)
449 .apply_compression_config(
450 accept_compression_encodings,
451 send_compression_encodings,
452 )
453 .apply_max_message_size_config(
454 max_decoding_message_size,
455 max_encoding_message_size,
456 );
457 let res = grpc.unary(method, req).await;
458 Ok(res)
459 };
460 Box::pin(fut)
461 }
462 _ => {
463 Box::pin(async move {
464 let mut response = http::Response::new(
465 tonic::body::Body::default(),
466 );
467 let headers = response.headers_mut();
468 headers
469 .insert(
470 tonic::Status::GRPC_STATUS,
471 (tonic::Code::Unimplemented as i32).into(),
472 );
473 headers
474 .insert(
475 http::header::CONTENT_TYPE,
476 tonic::metadata::GRPC_CONTENT_TYPE,
477 );
478 Ok(response)
479 })
480 }
481 }
482 }
483 }
484 impl<T> Clone for StaticControllerServer<T> {
485 fn clone(&self) -> Self {
486 let inner = self.inner.clone();
487 Self {
488 inner,
489 accept_compression_encodings: self.accept_compression_encodings,
490 send_compression_encodings: self.send_compression_encodings,
491 max_decoding_message_size: self.max_decoding_message_size,
492 max_encoding_message_size: self.max_encoding_message_size,
493 }
494 }
495 }
496 pub const SERVICE_NAME: &str = "deq.controller.static_controller.StaticController";
498 impl<T> tonic::server::NamedService for StaticControllerServer<T> {
499 const NAME: &'static str = SERVICE_NAME;
500 }
501}