1#[derive(Clone, Copy, PartialEq, ::prost::Message)]
3pub struct Angle {
4 #[prost(float, tag = "1")]
5 pub rad: f32,
6}
7#[derive(Clone, Copy, PartialEq, ::prost::Message)]
8pub struct UnitVector3 {
9 #[prost(float, tag = "1")]
10 pub x: f32,
11 #[prost(float, tag = "2")]
12 pub y: f32,
13 #[prost(float, tag = "3")]
14 pub z: f32,
15}
16#[derive(Clone, Copy, PartialEq, ::prost::Message)]
17pub struct Point3 {
18 #[prost(float, tag = "1")]
19 pub x: f32,
20 #[prost(float, tag = "2")]
21 pub y: f32,
22 #[prost(float, tag = "3")]
23 pub z: f32,
24}
25#[derive(Clone, Copy, PartialEq, ::prost::Message)]
26pub struct Quaternion {
27 #[prost(float, tag = "1")]
28 pub w: f32,
29 #[prost(float, tag = "2")]
30 pub x: f32,
31 #[prost(float, tag = "3")]
32 pub y: f32,
33 #[prost(float, tag = "4")]
34 pub z: f32,
35}
36#[derive(Clone, PartialEq, ::prost::Message)]
37pub struct Geometry {
38 #[prost(message, repeated, tag = "1")]
39 pub devices: ::prost::alloc::vec::Vec<geometry::Autd3>,
40}
41pub mod geometry {
43 #[derive(Clone, Copy, PartialEq, ::prost::Message)]
44 pub struct Autd3 {
45 #[prost(message, optional, tag = "1")]
46 pub pos: ::core::option::Option<super::Point3>,
47 #[prost(message, optional, tag = "2")]
48 pub rot: ::core::option::Option<super::Quaternion>,
49 }
50}
51#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
52pub struct TxRawData {
53 #[prost(bytes = "vec", tag = "1")]
54 pub data: ::prost::alloc::vec::Vec<u8>,
55 #[prost(uint32, tag = "2")]
56 pub n: u32,
57}
58#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
59pub struct SendResponse {}
60#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
61pub struct RxMessage {
62 #[prost(bytes = "vec", tag = "1")]
63 pub data: ::prost::alloc::vec::Vec<u8>,
64}
65#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
66pub struct ReadRequest {}
67#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
68pub struct CloseRequest {}
69#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
70pub struct CloseResponse {}
71#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
72pub struct GeometryResponse {}
73pub mod simulator_client {
75 #![allow(
76 unused_variables,
77 dead_code,
78 missing_docs,
79 clippy::wildcard_imports,
80 clippy::let_unit_value
81 )]
82 use tonic::codegen::http::Uri;
83 use tonic::codegen::*;
84 #[derive(Debug, Clone)]
85 pub struct SimulatorClient<T> {
86 inner: tonic::client::Grpc<T>,
87 }
88 impl SimulatorClient<tonic::transport::Channel> {
89 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
91 where
92 D: TryInto<tonic::transport::Endpoint>,
93 D::Error: Into<StdError>,
94 {
95 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
96 Ok(Self::new(conn))
97 }
98 }
99 impl<T> SimulatorClient<T>
100 where
101 T: tonic::client::GrpcService<tonic::body::Body>,
102 T::Error: Into<StdError>,
103 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
104 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
105 {
106 pub fn new(inner: T) -> Self {
107 let inner = tonic::client::Grpc::new(inner);
108 Self { inner }
109 }
110 pub fn with_origin(inner: T, origin: Uri) -> Self {
111 let inner = tonic::client::Grpc::with_origin(inner, origin);
112 Self { inner }
113 }
114 pub fn with_interceptor<F>(
115 inner: T,
116 interceptor: F,
117 ) -> SimulatorClient<InterceptedService<T, F>>
118 where
119 F: tonic::service::Interceptor,
120 T::ResponseBody: Default,
121 T: tonic::codegen::Service<
122 http::Request<tonic::body::Body>,
123 Response = http::Response<
124 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
125 >,
126 >,
127 <T as tonic::codegen::Service<http::Request<tonic::body::Body>>>::Error:
128 Into<StdError> + std::marker::Send + std::marker::Sync,
129 {
130 SimulatorClient::new(InterceptedService::new(inner, interceptor))
131 }
132 #[must_use]
137 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
138 self.inner = self.inner.send_compressed(encoding);
139 self
140 }
141 #[must_use]
143 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
144 self.inner = self.inner.accept_compressed(encoding);
145 self
146 }
147 #[must_use]
151 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
152 self.inner = self.inner.max_decoding_message_size(limit);
153 self
154 }
155 #[must_use]
159 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
160 self.inner = self.inner.max_encoding_message_size(limit);
161 self
162 }
163 pub async fn config_geometry(
164 &mut self,
165 request: impl tonic::IntoRequest<super::Geometry>,
166 ) -> std::result::Result<tonic::Response<super::GeometryResponse>, tonic::Status> {
167 self.inner.ready().await.map_err(|e| {
168 tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
169 })?;
170 let codec = tonic_prost::ProstCodec::default();
171 let path = http::uri::PathAndQuery::from_static("/autd3.Simulator/ConfigGeometry");
172 let mut req = request.into_request();
173 req.extensions_mut()
174 .insert(GrpcMethod::new("autd3.Simulator", "ConfigGeometry"));
175 self.inner.unary(req, path, codec).await
176 }
177 pub async fn update_geometry(
178 &mut self,
179 request: impl tonic::IntoRequest<super::Geometry>,
180 ) -> std::result::Result<tonic::Response<super::GeometryResponse>, tonic::Status> {
181 self.inner.ready().await.map_err(|e| {
182 tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
183 })?;
184 let codec = tonic_prost::ProstCodec::default();
185 let path = http::uri::PathAndQuery::from_static("/autd3.Simulator/UpdateGeometry");
186 let mut req = request.into_request();
187 req.extensions_mut()
188 .insert(GrpcMethod::new("autd3.Simulator", "UpdateGeometry"));
189 self.inner.unary(req, path, codec).await
190 }
191 pub async fn send_data(
192 &mut self,
193 request: impl tonic::IntoRequest<super::TxRawData>,
194 ) -> std::result::Result<tonic::Response<super::SendResponse>, tonic::Status> {
195 self.inner.ready().await.map_err(|e| {
196 tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
197 })?;
198 let codec = tonic_prost::ProstCodec::default();
199 let path = http::uri::PathAndQuery::from_static("/autd3.Simulator/SendData");
200 let mut req = request.into_request();
201 req.extensions_mut()
202 .insert(GrpcMethod::new("autd3.Simulator", "SendData"));
203 self.inner.unary(req, path, codec).await
204 }
205 pub async fn read_data(
206 &mut self,
207 request: impl tonic::IntoRequest<super::ReadRequest>,
208 ) -> std::result::Result<tonic::Response<super::RxMessage>, tonic::Status> {
209 self.inner.ready().await.map_err(|e| {
210 tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
211 })?;
212 let codec = tonic_prost::ProstCodec::default();
213 let path = http::uri::PathAndQuery::from_static("/autd3.Simulator/ReadData");
214 let mut req = request.into_request();
215 req.extensions_mut()
216 .insert(GrpcMethod::new("autd3.Simulator", "ReadData"));
217 self.inner.unary(req, path, codec).await
218 }
219 pub async fn close(
220 &mut self,
221 request: impl tonic::IntoRequest<super::CloseRequest>,
222 ) -> std::result::Result<tonic::Response<super::CloseResponse>, tonic::Status> {
223 self.inner.ready().await.map_err(|e| {
224 tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
225 })?;
226 let codec = tonic_prost::ProstCodec::default();
227 let path = http::uri::PathAndQuery::from_static("/autd3.Simulator/Close");
228 let mut req = request.into_request();
229 req.extensions_mut()
230 .insert(GrpcMethod::new("autd3.Simulator", "Close"));
231 self.inner.unary(req, path, codec).await
232 }
233 }
234}
235pub mod simulator_server {
237 #![allow(
238 unused_variables,
239 dead_code,
240 missing_docs,
241 clippy::wildcard_imports,
242 clippy::let_unit_value
243 )]
244 use tonic::codegen::*;
245 #[async_trait]
247 pub trait Simulator: std::marker::Send + std::marker::Sync + 'static {
248 async fn config_geometry(
249 &self,
250 request: tonic::Request<super::Geometry>,
251 ) -> std::result::Result<tonic::Response<super::GeometryResponse>, tonic::Status>;
252 async fn update_geometry(
253 &self,
254 request: tonic::Request<super::Geometry>,
255 ) -> std::result::Result<tonic::Response<super::GeometryResponse>, tonic::Status>;
256 async fn send_data(
257 &self,
258 request: tonic::Request<super::TxRawData>,
259 ) -> std::result::Result<tonic::Response<super::SendResponse>, tonic::Status>;
260 async fn read_data(
261 &self,
262 request: tonic::Request<super::ReadRequest>,
263 ) -> std::result::Result<tonic::Response<super::RxMessage>, tonic::Status>;
264 async fn close(
265 &self,
266 request: tonic::Request<super::CloseRequest>,
267 ) -> std::result::Result<tonic::Response<super::CloseResponse>, tonic::Status>;
268 }
269 #[derive(Debug)]
270 pub struct SimulatorServer<T> {
271 inner: Arc<T>,
272 accept_compression_encodings: EnabledCompressionEncodings,
273 send_compression_encodings: EnabledCompressionEncodings,
274 max_decoding_message_size: Option<usize>,
275 max_encoding_message_size: Option<usize>,
276 }
277 impl<T> SimulatorServer<T> {
278 pub fn new(inner: T) -> Self {
279 Self::from_arc(Arc::new(inner))
280 }
281 pub fn from_arc(inner: Arc<T>) -> Self {
282 Self {
283 inner,
284 accept_compression_encodings: Default::default(),
285 send_compression_encodings: Default::default(),
286 max_decoding_message_size: None,
287 max_encoding_message_size: None,
288 }
289 }
290 pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
291 where
292 F: tonic::service::Interceptor,
293 {
294 InterceptedService::new(Self::new(inner), interceptor)
295 }
296 #[must_use]
298 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
299 self.accept_compression_encodings.enable(encoding);
300 self
301 }
302 #[must_use]
304 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
305 self.send_compression_encodings.enable(encoding);
306 self
307 }
308 #[must_use]
312 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
313 self.max_decoding_message_size = Some(limit);
314 self
315 }
316 #[must_use]
320 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
321 self.max_encoding_message_size = Some(limit);
322 self
323 }
324 }
325 impl<T, B> tonic::codegen::Service<http::Request<B>> for SimulatorServer<T>
326 where
327 T: Simulator,
328 B: Body + std::marker::Send + 'static,
329 B::Error: Into<StdError> + std::marker::Send + 'static,
330 {
331 type Response = http::Response<tonic::body::Body>;
332 type Error = std::convert::Infallible;
333 type Future = BoxFuture<Self::Response, Self::Error>;
334 fn poll_ready(
335 &mut self,
336 _cx: &mut Context<'_>,
337 ) -> Poll<std::result::Result<(), Self::Error>> {
338 Poll::Ready(Ok(()))
339 }
340 fn call(&mut self, req: http::Request<B>) -> Self::Future {
341 match req.uri().path() {
342 "/autd3.Simulator/ConfigGeometry" => {
343 #[allow(non_camel_case_types)]
344 struct ConfigGeometrySvc<T: Simulator>(pub Arc<T>);
345 impl<T: Simulator> tonic::server::UnaryService<super::Geometry> for ConfigGeometrySvc<T> {
346 type Response = super::GeometryResponse;
347 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
348 fn call(
349 &mut self,
350 request: tonic::Request<super::Geometry>,
351 ) -> Self::Future {
352 let inner = Arc::clone(&self.0);
353 let fut = async move {
354 <T as Simulator>::config_geometry(&inner, request).await
355 };
356 Box::pin(fut)
357 }
358 }
359 let accept_compression_encodings = self.accept_compression_encodings;
360 let send_compression_encodings = self.send_compression_encodings;
361 let max_decoding_message_size = self.max_decoding_message_size;
362 let max_encoding_message_size = self.max_encoding_message_size;
363 let inner = self.inner.clone();
364 let fut = async move {
365 let method = ConfigGeometrySvc(inner);
366 let codec = tonic_prost::ProstCodec::default();
367 let mut grpc = tonic::server::Grpc::new(codec)
368 .apply_compression_config(
369 accept_compression_encodings,
370 send_compression_encodings,
371 )
372 .apply_max_message_size_config(
373 max_decoding_message_size,
374 max_encoding_message_size,
375 );
376 let res = grpc.unary(method, req).await;
377 Ok(res)
378 };
379 Box::pin(fut)
380 }
381 "/autd3.Simulator/UpdateGeometry" => {
382 #[allow(non_camel_case_types)]
383 struct UpdateGeometrySvc<T: Simulator>(pub Arc<T>);
384 impl<T: Simulator> tonic::server::UnaryService<super::Geometry> for UpdateGeometrySvc<T> {
385 type Response = super::GeometryResponse;
386 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
387 fn call(
388 &mut self,
389 request: tonic::Request<super::Geometry>,
390 ) -> Self::Future {
391 let inner = Arc::clone(&self.0);
392 let fut = async move {
393 <T as Simulator>::update_geometry(&inner, request).await
394 };
395 Box::pin(fut)
396 }
397 }
398 let accept_compression_encodings = self.accept_compression_encodings;
399 let send_compression_encodings = self.send_compression_encodings;
400 let max_decoding_message_size = self.max_decoding_message_size;
401 let max_encoding_message_size = self.max_encoding_message_size;
402 let inner = self.inner.clone();
403 let fut = async move {
404 let method = UpdateGeometrySvc(inner);
405 let codec = tonic_prost::ProstCodec::default();
406 let mut grpc = tonic::server::Grpc::new(codec)
407 .apply_compression_config(
408 accept_compression_encodings,
409 send_compression_encodings,
410 )
411 .apply_max_message_size_config(
412 max_decoding_message_size,
413 max_encoding_message_size,
414 );
415 let res = grpc.unary(method, req).await;
416 Ok(res)
417 };
418 Box::pin(fut)
419 }
420 "/autd3.Simulator/SendData" => {
421 #[allow(non_camel_case_types)]
422 struct SendDataSvc<T: Simulator>(pub Arc<T>);
423 impl<T: Simulator> tonic::server::UnaryService<super::TxRawData> for SendDataSvc<T> {
424 type Response = super::SendResponse;
425 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
426 fn call(
427 &mut self,
428 request: tonic::Request<super::TxRawData>,
429 ) -> Self::Future {
430 let inner = Arc::clone(&self.0);
431 let fut =
432 async move { <T as Simulator>::send_data(&inner, request).await };
433 Box::pin(fut)
434 }
435 }
436 let accept_compression_encodings = self.accept_compression_encodings;
437 let send_compression_encodings = self.send_compression_encodings;
438 let max_decoding_message_size = self.max_decoding_message_size;
439 let max_encoding_message_size = self.max_encoding_message_size;
440 let inner = self.inner.clone();
441 let fut = async move {
442 let method = SendDataSvc(inner);
443 let codec = tonic_prost::ProstCodec::default();
444 let mut grpc = tonic::server::Grpc::new(codec)
445 .apply_compression_config(
446 accept_compression_encodings,
447 send_compression_encodings,
448 )
449 .apply_max_message_size_config(
450 max_decoding_message_size,
451 max_encoding_message_size,
452 );
453 let res = grpc.unary(method, req).await;
454 Ok(res)
455 };
456 Box::pin(fut)
457 }
458 "/autd3.Simulator/ReadData" => {
459 #[allow(non_camel_case_types)]
460 struct ReadDataSvc<T: Simulator>(pub Arc<T>);
461 impl<T: Simulator> tonic::server::UnaryService<super::ReadRequest> for ReadDataSvc<T> {
462 type Response = super::RxMessage;
463 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
464 fn call(
465 &mut self,
466 request: tonic::Request<super::ReadRequest>,
467 ) -> Self::Future {
468 let inner = Arc::clone(&self.0);
469 let fut =
470 async move { <T as Simulator>::read_data(&inner, request).await };
471 Box::pin(fut)
472 }
473 }
474 let accept_compression_encodings = self.accept_compression_encodings;
475 let send_compression_encodings = self.send_compression_encodings;
476 let max_decoding_message_size = self.max_decoding_message_size;
477 let max_encoding_message_size = self.max_encoding_message_size;
478 let inner = self.inner.clone();
479 let fut = async move {
480 let method = ReadDataSvc(inner);
481 let codec = tonic_prost::ProstCodec::default();
482 let mut grpc = tonic::server::Grpc::new(codec)
483 .apply_compression_config(
484 accept_compression_encodings,
485 send_compression_encodings,
486 )
487 .apply_max_message_size_config(
488 max_decoding_message_size,
489 max_encoding_message_size,
490 );
491 let res = grpc.unary(method, req).await;
492 Ok(res)
493 };
494 Box::pin(fut)
495 }
496 "/autd3.Simulator/Close" => {
497 #[allow(non_camel_case_types)]
498 struct CloseSvc<T: Simulator>(pub Arc<T>);
499 impl<T: Simulator> tonic::server::UnaryService<super::CloseRequest> for CloseSvc<T> {
500 type Response = super::CloseResponse;
501 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
502 fn call(
503 &mut self,
504 request: tonic::Request<super::CloseRequest>,
505 ) -> Self::Future {
506 let inner = Arc::clone(&self.0);
507 let fut = async move { <T as Simulator>::close(&inner, request).await };
508 Box::pin(fut)
509 }
510 }
511 let accept_compression_encodings = self.accept_compression_encodings;
512 let send_compression_encodings = self.send_compression_encodings;
513 let max_decoding_message_size = self.max_decoding_message_size;
514 let max_encoding_message_size = self.max_encoding_message_size;
515 let inner = self.inner.clone();
516 let fut = async move {
517 let method = CloseSvc(inner);
518 let codec = tonic_prost::ProstCodec::default();
519 let mut grpc = tonic::server::Grpc::new(codec)
520 .apply_compression_config(
521 accept_compression_encodings,
522 send_compression_encodings,
523 )
524 .apply_max_message_size_config(
525 max_decoding_message_size,
526 max_encoding_message_size,
527 );
528 let res = grpc.unary(method, req).await;
529 Ok(res)
530 };
531 Box::pin(fut)
532 }
533 _ => Box::pin(async move {
534 let mut response = http::Response::new(tonic::body::Body::default());
535 let headers = response.headers_mut();
536 headers.insert(
537 tonic::Status::GRPC_STATUS,
538 (tonic::Code::Unimplemented as i32).into(),
539 );
540 headers.insert(
541 http::header::CONTENT_TYPE,
542 tonic::metadata::GRPC_CONTENT_TYPE,
543 );
544 Ok(response)
545 }),
546 }
547 }
548 }
549 impl<T> Clone for SimulatorServer<T> {
550 fn clone(&self) -> Self {
551 let inner = self.inner.clone();
552 Self {
553 inner,
554 accept_compression_encodings: self.accept_compression_encodings,
555 send_compression_encodings: self.send_compression_encodings,
556 max_decoding_message_size: self.max_decoding_message_size,
557 max_encoding_message_size: self.max_encoding_message_size,
558 }
559 }
560 }
561 pub const SERVICE_NAME: &str = "autd3.Simulator";
563 impl<T> tonic::server::NamedService for SimulatorServer<T> {
564 const NAME: &'static str = SERVICE_NAME;
565 }
566}
567pub mod ecat_client {
569 #![allow(
570 unused_variables,
571 dead_code,
572 missing_docs,
573 clippy::wildcard_imports,
574 clippy::let_unit_value
575 )]
576 use tonic::codegen::http::Uri;
577 use tonic::codegen::*;
578 #[derive(Debug, Clone)]
579 pub struct EcatClient<T> {
580 inner: tonic::client::Grpc<T>,
581 }
582 impl EcatClient<tonic::transport::Channel> {
583 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
585 where
586 D: TryInto<tonic::transport::Endpoint>,
587 D::Error: Into<StdError>,
588 {
589 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
590 Ok(Self::new(conn))
591 }
592 }
593 impl<T> EcatClient<T>
594 where
595 T: tonic::client::GrpcService<tonic::body::Body>,
596 T::Error: Into<StdError>,
597 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
598 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
599 {
600 pub fn new(inner: T) -> Self {
601 let inner = tonic::client::Grpc::new(inner);
602 Self { inner }
603 }
604 pub fn with_origin(inner: T, origin: Uri) -> Self {
605 let inner = tonic::client::Grpc::with_origin(inner, origin);
606 Self { inner }
607 }
608 pub fn with_interceptor<F>(inner: T, interceptor: F) -> EcatClient<InterceptedService<T, F>>
609 where
610 F: tonic::service::Interceptor,
611 T::ResponseBody: Default,
612 T: tonic::codegen::Service<
613 http::Request<tonic::body::Body>,
614 Response = http::Response<
615 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
616 >,
617 >,
618 <T as tonic::codegen::Service<http::Request<tonic::body::Body>>>::Error:
619 Into<StdError> + std::marker::Send + std::marker::Sync,
620 {
621 EcatClient::new(InterceptedService::new(inner, interceptor))
622 }
623 #[must_use]
628 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
629 self.inner = self.inner.send_compressed(encoding);
630 self
631 }
632 #[must_use]
634 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
635 self.inner = self.inner.accept_compressed(encoding);
636 self
637 }
638 #[must_use]
642 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
643 self.inner = self.inner.max_decoding_message_size(limit);
644 self
645 }
646 #[must_use]
650 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
651 self.inner = self.inner.max_encoding_message_size(limit);
652 self
653 }
654 pub async fn send_data(
655 &mut self,
656 request: impl tonic::IntoRequest<super::TxRawData>,
657 ) -> std::result::Result<tonic::Response<super::SendResponse>, tonic::Status> {
658 self.inner.ready().await.map_err(|e| {
659 tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
660 })?;
661 let codec = tonic_prost::ProstCodec::default();
662 let path = http::uri::PathAndQuery::from_static("/autd3.ECAT/SendData");
663 let mut req = request.into_request();
664 req.extensions_mut()
665 .insert(GrpcMethod::new("autd3.ECAT", "SendData"));
666 self.inner.unary(req, path, codec).await
667 }
668 pub async fn read_data(
669 &mut self,
670 request: impl tonic::IntoRequest<super::ReadRequest>,
671 ) -> std::result::Result<tonic::Response<super::RxMessage>, tonic::Status> {
672 self.inner.ready().await.map_err(|e| {
673 tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
674 })?;
675 let codec = tonic_prost::ProstCodec::default();
676 let path = http::uri::PathAndQuery::from_static("/autd3.ECAT/ReadData");
677 let mut req = request.into_request();
678 req.extensions_mut()
679 .insert(GrpcMethod::new("autd3.ECAT", "ReadData"));
680 self.inner.unary(req, path, codec).await
681 }
682 pub async fn close(
683 &mut self,
684 request: impl tonic::IntoRequest<super::CloseRequest>,
685 ) -> std::result::Result<tonic::Response<super::CloseResponse>, tonic::Status> {
686 self.inner.ready().await.map_err(|e| {
687 tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
688 })?;
689 let codec = tonic_prost::ProstCodec::default();
690 let path = http::uri::PathAndQuery::from_static("/autd3.ECAT/Close");
691 let mut req = request.into_request();
692 req.extensions_mut()
693 .insert(GrpcMethod::new("autd3.ECAT", "Close"));
694 self.inner.unary(req, path, codec).await
695 }
696 }
697}
698pub mod ecat_server {
700 #![allow(
701 unused_variables,
702 dead_code,
703 missing_docs,
704 clippy::wildcard_imports,
705 clippy::let_unit_value
706 )]
707 use tonic::codegen::*;
708 #[async_trait]
710 pub trait Ecat: std::marker::Send + std::marker::Sync + 'static {
711 async fn send_data(
712 &self,
713 request: tonic::Request<super::TxRawData>,
714 ) -> std::result::Result<tonic::Response<super::SendResponse>, tonic::Status>;
715 async fn read_data(
716 &self,
717 request: tonic::Request<super::ReadRequest>,
718 ) -> std::result::Result<tonic::Response<super::RxMessage>, tonic::Status>;
719 async fn close(
720 &self,
721 request: tonic::Request<super::CloseRequest>,
722 ) -> std::result::Result<tonic::Response<super::CloseResponse>, tonic::Status>;
723 }
724 #[derive(Debug)]
725 pub struct EcatServer<T> {
726 inner: Arc<T>,
727 accept_compression_encodings: EnabledCompressionEncodings,
728 send_compression_encodings: EnabledCompressionEncodings,
729 max_decoding_message_size: Option<usize>,
730 max_encoding_message_size: Option<usize>,
731 }
732 impl<T> EcatServer<T> {
733 pub fn new(inner: T) -> Self {
734 Self::from_arc(Arc::new(inner))
735 }
736 pub fn from_arc(inner: Arc<T>) -> Self {
737 Self {
738 inner,
739 accept_compression_encodings: Default::default(),
740 send_compression_encodings: Default::default(),
741 max_decoding_message_size: None,
742 max_encoding_message_size: None,
743 }
744 }
745 pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
746 where
747 F: tonic::service::Interceptor,
748 {
749 InterceptedService::new(Self::new(inner), interceptor)
750 }
751 #[must_use]
753 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
754 self.accept_compression_encodings.enable(encoding);
755 self
756 }
757 #[must_use]
759 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
760 self.send_compression_encodings.enable(encoding);
761 self
762 }
763 #[must_use]
767 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
768 self.max_decoding_message_size = Some(limit);
769 self
770 }
771 #[must_use]
775 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
776 self.max_encoding_message_size = Some(limit);
777 self
778 }
779 }
780 impl<T, B> tonic::codegen::Service<http::Request<B>> for EcatServer<T>
781 where
782 T: Ecat,
783 B: Body + std::marker::Send + 'static,
784 B::Error: Into<StdError> + std::marker::Send + 'static,
785 {
786 type Response = http::Response<tonic::body::Body>;
787 type Error = std::convert::Infallible;
788 type Future = BoxFuture<Self::Response, Self::Error>;
789 fn poll_ready(
790 &mut self,
791 _cx: &mut Context<'_>,
792 ) -> Poll<std::result::Result<(), Self::Error>> {
793 Poll::Ready(Ok(()))
794 }
795 fn call(&mut self, req: http::Request<B>) -> Self::Future {
796 match req.uri().path() {
797 "/autd3.ECAT/SendData" => {
798 #[allow(non_camel_case_types)]
799 struct SendDataSvc<T: Ecat>(pub Arc<T>);
800 impl<T: Ecat> tonic::server::UnaryService<super::TxRawData> for SendDataSvc<T> {
801 type Response = super::SendResponse;
802 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
803 fn call(
804 &mut self,
805 request: tonic::Request<super::TxRawData>,
806 ) -> Self::Future {
807 let inner = Arc::clone(&self.0);
808 let fut = async move { <T as Ecat>::send_data(&inner, request).await };
809 Box::pin(fut)
810 }
811 }
812 let accept_compression_encodings = self.accept_compression_encodings;
813 let send_compression_encodings = self.send_compression_encodings;
814 let max_decoding_message_size = self.max_decoding_message_size;
815 let max_encoding_message_size = self.max_encoding_message_size;
816 let inner = self.inner.clone();
817 let fut = async move {
818 let method = SendDataSvc(inner);
819 let codec = tonic_prost::ProstCodec::default();
820 let mut grpc = tonic::server::Grpc::new(codec)
821 .apply_compression_config(
822 accept_compression_encodings,
823 send_compression_encodings,
824 )
825 .apply_max_message_size_config(
826 max_decoding_message_size,
827 max_encoding_message_size,
828 );
829 let res = grpc.unary(method, req).await;
830 Ok(res)
831 };
832 Box::pin(fut)
833 }
834 "/autd3.ECAT/ReadData" => {
835 #[allow(non_camel_case_types)]
836 struct ReadDataSvc<T: Ecat>(pub Arc<T>);
837 impl<T: Ecat> tonic::server::UnaryService<super::ReadRequest> for ReadDataSvc<T> {
838 type Response = super::RxMessage;
839 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
840 fn call(
841 &mut self,
842 request: tonic::Request<super::ReadRequest>,
843 ) -> Self::Future {
844 let inner = Arc::clone(&self.0);
845 let fut = async move { <T as Ecat>::read_data(&inner, request).await };
846 Box::pin(fut)
847 }
848 }
849 let accept_compression_encodings = self.accept_compression_encodings;
850 let send_compression_encodings = self.send_compression_encodings;
851 let max_decoding_message_size = self.max_decoding_message_size;
852 let max_encoding_message_size = self.max_encoding_message_size;
853 let inner = self.inner.clone();
854 let fut = async move {
855 let method = ReadDataSvc(inner);
856 let codec = tonic_prost::ProstCodec::default();
857 let mut grpc = tonic::server::Grpc::new(codec)
858 .apply_compression_config(
859 accept_compression_encodings,
860 send_compression_encodings,
861 )
862 .apply_max_message_size_config(
863 max_decoding_message_size,
864 max_encoding_message_size,
865 );
866 let res = grpc.unary(method, req).await;
867 Ok(res)
868 };
869 Box::pin(fut)
870 }
871 "/autd3.ECAT/Close" => {
872 #[allow(non_camel_case_types)]
873 struct CloseSvc<T: Ecat>(pub Arc<T>);
874 impl<T: Ecat> tonic::server::UnaryService<super::CloseRequest> for CloseSvc<T> {
875 type Response = super::CloseResponse;
876 type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
877 fn call(
878 &mut self,
879 request: tonic::Request<super::CloseRequest>,
880 ) -> Self::Future {
881 let inner = Arc::clone(&self.0);
882 let fut = async move { <T as Ecat>::close(&inner, request).await };
883 Box::pin(fut)
884 }
885 }
886 let accept_compression_encodings = self.accept_compression_encodings;
887 let send_compression_encodings = self.send_compression_encodings;
888 let max_decoding_message_size = self.max_decoding_message_size;
889 let max_encoding_message_size = self.max_encoding_message_size;
890 let inner = self.inner.clone();
891 let fut = async move {
892 let method = CloseSvc(inner);
893 let codec = tonic_prost::ProstCodec::default();
894 let mut grpc = tonic::server::Grpc::new(codec)
895 .apply_compression_config(
896 accept_compression_encodings,
897 send_compression_encodings,
898 )
899 .apply_max_message_size_config(
900 max_decoding_message_size,
901 max_encoding_message_size,
902 );
903 let res = grpc.unary(method, req).await;
904 Ok(res)
905 };
906 Box::pin(fut)
907 }
908 _ => Box::pin(async move {
909 let mut response = http::Response::new(tonic::body::Body::default());
910 let headers = response.headers_mut();
911 headers.insert(
912 tonic::Status::GRPC_STATUS,
913 (tonic::Code::Unimplemented as i32).into(),
914 );
915 headers.insert(
916 http::header::CONTENT_TYPE,
917 tonic::metadata::GRPC_CONTENT_TYPE,
918 );
919 Ok(response)
920 }),
921 }
922 }
923 }
924 impl<T> Clone for EcatServer<T> {
925 fn clone(&self) -> Self {
926 let inner = self.inner.clone();
927 Self {
928 inner,
929 accept_compression_encodings: self.accept_compression_encodings,
930 send_compression_encodings: self.send_compression_encodings,
931 max_decoding_message_size: self.max_decoding_message_size,
932 max_encoding_message_size: self.max_encoding_message_size,
933 }
934 }
935 }
936 pub const SERVICE_NAME: &str = "autd3.ECAT";
938 impl<T> tonic::server::NamedService for EcatServer<T> {
939 const NAME: &'static str = SERVICE_NAME;
940 }
941}