1#[derive(serde::Serialize, serde::Deserialize)]
3#[allow(clippy::derive_partial_eq_without_eq)]
4#[derive(Clone, PartialEq, ::prost::Message)]
5pub struct WriteExternalStateMessage {
6 #[prost(message, optional, tag = "1")]
7 pub view_payload: ::core::option::Option<super::super::common::state::ViewPayload>,
8 #[prost(message, optional, tag = "2")]
9 pub ctx: ::core::option::Option<super::super::common::events::ContractTransaction>,
10}
11pub mod driver_communication_client {
13 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
14 use tonic::codegen::*;
15 use tonic::codegen::http::Uri;
16 #[derive(Debug, Clone)]
17 pub struct DriverCommunicationClient<T> {
18 inner: tonic::client::Grpc<T>,
19 }
20 impl DriverCommunicationClient<tonic::transport::Channel> {
21 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
23 where
24 D: std::convert::TryInto<tonic::transport::Endpoint>,
25 D::Error: Into<StdError>,
26 {
27 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
28 Ok(Self::new(conn))
29 }
30 }
31 impl<T> DriverCommunicationClient<T>
32 where
33 T: tonic::client::GrpcService<tonic::body::BoxBody>,
34 T::Error: Into<StdError>,
35 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
36 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
37 {
38 pub fn new(inner: T) -> Self {
39 let inner = tonic::client::Grpc::new(inner);
40 Self { inner }
41 }
42 pub fn with_origin(inner: T, origin: Uri) -> Self {
43 let inner = tonic::client::Grpc::with_origin(inner, origin);
44 Self { inner }
45 }
46 pub fn with_interceptor<F>(
47 inner: T,
48 interceptor: F,
49 ) -> DriverCommunicationClient<InterceptedService<T, F>>
50 where
51 F: tonic::service::Interceptor,
52 T::ResponseBody: Default,
53 T: tonic::codegen::Service<
54 http::Request<tonic::body::BoxBody>,
55 Response = http::Response<
56 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
57 >,
58 >,
59 <T as tonic::codegen::Service<
60 http::Request<tonic::body::BoxBody>,
61 >>::Error: Into<StdError> + Send + Sync,
62 {
63 DriverCommunicationClient::new(InterceptedService::new(inner, interceptor))
64 }
65 #[must_use]
70 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
71 self.inner = self.inner.send_compressed(encoding);
72 self
73 }
74 #[must_use]
76 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
77 self.inner = self.inner.accept_compressed(encoding);
78 self
79 }
80 pub async fn request_driver_state(
84 &mut self,
85 request: impl tonic::IntoRequest<super::super::super::common::query::Query>,
86 ) -> Result<
87 tonic::Response<super::super::super::common::ack::Ack>,
88 tonic::Status,
89 > {
90 self.inner
91 .ready()
92 .await
93 .map_err(|e| {
94 tonic::Status::new(
95 tonic::Code::Unknown,
96 format!("Service was not ready: {}", e.into()),
97 )
98 })?;
99 let codec = tonic::codec::ProstCodec::default();
100 let path = http::uri::PathAndQuery::from_static(
101 "/driver.driver.DriverCommunication/RequestDriverState",
102 );
103 self.inner.unary(request.into_request(), path, codec).await
104 }
105 pub async fn subscribe_event(
108 &mut self,
109 request: impl tonic::IntoRequest<
110 super::super::super::common::events::EventSubscription,
111 >,
112 ) -> Result<
113 tonic::Response<super::super::super::common::ack::Ack>,
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 "/driver.driver.DriverCommunication/SubscribeEvent",
128 );
129 self.inner.unary(request.into_request(), path, codec).await
130 }
131 pub async fn request_signed_event_subscription_query(
135 &mut self,
136 request: impl tonic::IntoRequest<
137 super::super::super::common::events::EventSubscription,
138 >,
139 ) -> Result<
140 tonic::Response<super::super::super::common::query::Query>,
141 tonic::Status,
142 > {
143 self.inner
144 .ready()
145 .await
146 .map_err(|e| {
147 tonic::Status::new(
148 tonic::Code::Unknown,
149 format!("Service was not ready: {}", e.into()),
150 )
151 })?;
152 let codec = tonic::codec::ProstCodec::default();
153 let path = http::uri::PathAndQuery::from_static(
154 "/driver.driver.DriverCommunication/RequestSignedEventSubscriptionQuery",
155 );
156 self.inner.unary(request.into_request(), path, codec).await
157 }
158 pub async fn write_external_state(
161 &mut self,
162 request: impl tonic::IntoRequest<super::WriteExternalStateMessage>,
163 ) -> Result<
164 tonic::Response<super::super::super::common::ack::Ack>,
165 tonic::Status,
166 > {
167 self.inner
168 .ready()
169 .await
170 .map_err(|e| {
171 tonic::Status::new(
172 tonic::Code::Unknown,
173 format!("Service was not ready: {}", e.into()),
174 )
175 })?;
176 let codec = tonic::codec::ProstCodec::default();
177 let path = http::uri::PathAndQuery::from_static(
178 "/driver.driver.DriverCommunication/WriteExternalState",
179 );
180 self.inner.unary(request.into_request(), path, codec).await
181 }
182 }
183}
184pub mod driver_communication_server {
186 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
187 use tonic::codegen::*;
188 #[async_trait]
190 pub trait DriverCommunication: Send + Sync + 'static {
191 async fn request_driver_state(
195 &self,
196 request: tonic::Request<super::super::super::common::query::Query>,
197 ) -> Result<
198 tonic::Response<super::super::super::common::ack::Ack>,
199 tonic::Status,
200 >;
201 async fn subscribe_event(
204 &self,
205 request: tonic::Request<
206 super::super::super::common::events::EventSubscription,
207 >,
208 ) -> Result<
209 tonic::Response<super::super::super::common::ack::Ack>,
210 tonic::Status,
211 >;
212 async fn request_signed_event_subscription_query(
216 &self,
217 request: tonic::Request<
218 super::super::super::common::events::EventSubscription,
219 >,
220 ) -> Result<
221 tonic::Response<super::super::super::common::query::Query>,
222 tonic::Status,
223 >;
224 async fn write_external_state(
227 &self,
228 request: tonic::Request<super::WriteExternalStateMessage>,
229 ) -> Result<
230 tonic::Response<super::super::super::common::ack::Ack>,
231 tonic::Status,
232 >;
233 }
234 #[derive(Debug)]
235 pub struct DriverCommunicationServer<T: DriverCommunication> {
236 inner: _Inner<T>,
237 accept_compression_encodings: EnabledCompressionEncodings,
238 send_compression_encodings: EnabledCompressionEncodings,
239 }
240 struct _Inner<T>(Arc<T>);
241 impl<T: DriverCommunication> DriverCommunicationServer<T> {
242 pub fn new(inner: T) -> Self {
243 Self::from_arc(Arc::new(inner))
244 }
245 pub fn from_arc(inner: Arc<T>) -> Self {
246 let inner = _Inner(inner);
247 Self {
248 inner,
249 accept_compression_encodings: Default::default(),
250 send_compression_encodings: Default::default(),
251 }
252 }
253 pub fn with_interceptor<F>(
254 inner: T,
255 interceptor: F,
256 ) -> InterceptedService<Self, F>
257 where
258 F: tonic::service::Interceptor,
259 {
260 InterceptedService::new(Self::new(inner), interceptor)
261 }
262 #[must_use]
264 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
265 self.accept_compression_encodings.enable(encoding);
266 self
267 }
268 #[must_use]
270 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
271 self.send_compression_encodings.enable(encoding);
272 self
273 }
274 }
275 impl<T, B> tonic::codegen::Service<http::Request<B>> for DriverCommunicationServer<T>
276 where
277 T: DriverCommunication,
278 B: Body + Send + 'static,
279 B::Error: Into<StdError> + Send + 'static,
280 {
281 type Response = http::Response<tonic::body::BoxBody>;
282 type Error = std::convert::Infallible;
283 type Future = BoxFuture<Self::Response, Self::Error>;
284 fn poll_ready(
285 &mut self,
286 _cx: &mut Context<'_>,
287 ) -> Poll<Result<(), Self::Error>> {
288 Poll::Ready(Ok(()))
289 }
290 fn call(&mut self, req: http::Request<B>) -> Self::Future {
291 let inner = self.inner.clone();
292 match req.uri().path() {
293 "/driver.driver.DriverCommunication/RequestDriverState" => {
294 #[allow(non_camel_case_types)]
295 struct RequestDriverStateSvc<T: DriverCommunication>(pub Arc<T>);
296 impl<
297 T: DriverCommunication,
298 > tonic::server::UnaryService<
299 super::super::super::common::query::Query,
300 > for RequestDriverStateSvc<T> {
301 type Response = super::super::super::common::ack::Ack;
302 type Future = BoxFuture<
303 tonic::Response<Self::Response>,
304 tonic::Status,
305 >;
306 fn call(
307 &mut self,
308 request: tonic::Request<
309 super::super::super::common::query::Query,
310 >,
311 ) -> Self::Future {
312 let inner = self.0.clone();
313 let fut = async move {
314 (*inner).request_driver_state(request).await
315 };
316 Box::pin(fut)
317 }
318 }
319 let accept_compression_encodings = self.accept_compression_encodings;
320 let send_compression_encodings = self.send_compression_encodings;
321 let inner = self.inner.clone();
322 let fut = async move {
323 let inner = inner.0;
324 let method = RequestDriverStateSvc(inner);
325 let codec = tonic::codec::ProstCodec::default();
326 let mut grpc = tonic::server::Grpc::new(codec)
327 .apply_compression_config(
328 accept_compression_encodings,
329 send_compression_encodings,
330 );
331 let res = grpc.unary(method, req).await;
332 Ok(res)
333 };
334 Box::pin(fut)
335 }
336 "/driver.driver.DriverCommunication/SubscribeEvent" => {
337 #[allow(non_camel_case_types)]
338 struct SubscribeEventSvc<T: DriverCommunication>(pub Arc<T>);
339 impl<
340 T: DriverCommunication,
341 > tonic::server::UnaryService<
342 super::super::super::common::events::EventSubscription,
343 > for SubscribeEventSvc<T> {
344 type Response = super::super::super::common::ack::Ack;
345 type Future = BoxFuture<
346 tonic::Response<Self::Response>,
347 tonic::Status,
348 >;
349 fn call(
350 &mut self,
351 request: tonic::Request<
352 super::super::super::common::events::EventSubscription,
353 >,
354 ) -> Self::Future {
355 let inner = self.0.clone();
356 let fut = async move {
357 (*inner).subscribe_event(request).await
358 };
359 Box::pin(fut)
360 }
361 }
362 let accept_compression_encodings = self.accept_compression_encodings;
363 let send_compression_encodings = self.send_compression_encodings;
364 let inner = self.inner.clone();
365 let fut = async move {
366 let inner = inner.0;
367 let method = SubscribeEventSvc(inner);
368 let codec = tonic::codec::ProstCodec::default();
369 let mut grpc = tonic::server::Grpc::new(codec)
370 .apply_compression_config(
371 accept_compression_encodings,
372 send_compression_encodings,
373 );
374 let res = grpc.unary(method, req).await;
375 Ok(res)
376 };
377 Box::pin(fut)
378 }
379 "/driver.driver.DriverCommunication/RequestSignedEventSubscriptionQuery" => {
380 #[allow(non_camel_case_types)]
381 struct RequestSignedEventSubscriptionQuerySvc<
382 T: DriverCommunication,
383 >(
384 pub Arc<T>,
385 );
386 impl<
387 T: DriverCommunication,
388 > tonic::server::UnaryService<
389 super::super::super::common::events::EventSubscription,
390 > for RequestSignedEventSubscriptionQuerySvc<T> {
391 type Response = super::super::super::common::query::Query;
392 type Future = BoxFuture<
393 tonic::Response<Self::Response>,
394 tonic::Status,
395 >;
396 fn call(
397 &mut self,
398 request: tonic::Request<
399 super::super::super::common::events::EventSubscription,
400 >,
401 ) -> Self::Future {
402 let inner = self.0.clone();
403 let fut = async move {
404 (*inner)
405 .request_signed_event_subscription_query(request)
406 .await
407 };
408 Box::pin(fut)
409 }
410 }
411 let accept_compression_encodings = self.accept_compression_encodings;
412 let send_compression_encodings = self.send_compression_encodings;
413 let inner = self.inner.clone();
414 let fut = async move {
415 let inner = inner.0;
416 let method = RequestSignedEventSubscriptionQuerySvc(inner);
417 let codec = tonic::codec::ProstCodec::default();
418 let mut grpc = tonic::server::Grpc::new(codec)
419 .apply_compression_config(
420 accept_compression_encodings,
421 send_compression_encodings,
422 );
423 let res = grpc.unary(method, req).await;
424 Ok(res)
425 };
426 Box::pin(fut)
427 }
428 "/driver.driver.DriverCommunication/WriteExternalState" => {
429 #[allow(non_camel_case_types)]
430 struct WriteExternalStateSvc<T: DriverCommunication>(pub Arc<T>);
431 impl<
432 T: DriverCommunication,
433 > tonic::server::UnaryService<super::WriteExternalStateMessage>
434 for WriteExternalStateSvc<T> {
435 type Response = super::super::super::common::ack::Ack;
436 type Future = BoxFuture<
437 tonic::Response<Self::Response>,
438 tonic::Status,
439 >;
440 fn call(
441 &mut self,
442 request: tonic::Request<super::WriteExternalStateMessage>,
443 ) -> Self::Future {
444 let inner = self.0.clone();
445 let fut = async move {
446 (*inner).write_external_state(request).await
447 };
448 Box::pin(fut)
449 }
450 }
451 let accept_compression_encodings = self.accept_compression_encodings;
452 let send_compression_encodings = self.send_compression_encodings;
453 let inner = self.inner.clone();
454 let fut = async move {
455 let inner = inner.0;
456 let method = WriteExternalStateSvc(inner);
457 let codec = tonic::codec::ProstCodec::default();
458 let mut grpc = tonic::server::Grpc::new(codec)
459 .apply_compression_config(
460 accept_compression_encodings,
461 send_compression_encodings,
462 );
463 let res = grpc.unary(method, req).await;
464 Ok(res)
465 };
466 Box::pin(fut)
467 }
468 _ => {
469 Box::pin(async move {
470 Ok(
471 http::Response::builder()
472 .status(200)
473 .header("grpc-status", "12")
474 .header("content-type", "application/grpc")
475 .body(empty_body())
476 .unwrap(),
477 )
478 })
479 }
480 }
481 }
482 }
483 impl<T: DriverCommunication> Clone for DriverCommunicationServer<T> {
484 fn clone(&self) -> Self {
485 let inner = self.inner.clone();
486 Self {
487 inner,
488 accept_compression_encodings: self.accept_compression_encodings,
489 send_compression_encodings: self.send_compression_encodings,
490 }
491 }
492 }
493 impl<T: DriverCommunication> Clone for _Inner<T> {
494 fn clone(&self) -> Self {
495 Self(self.0.clone())
496 }
497 }
498 impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
499 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
500 write!(f, "{:?}", self.0)
501 }
502 }
503 impl<T: DriverCommunication> tonic::server::NamedService
504 for DriverCommunicationServer<T> {
505 const NAME: &'static str = "driver.driver.DriverCommunication";
506 }
507}