1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_services_test__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ControlPlaneMarker;
16
17impl fidl::endpoints::ProtocolMarker for ControlPlaneMarker {
18 type Proxy = ControlPlaneProxy;
19 type RequestStream = ControlPlaneRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = ControlPlaneSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "(anonymous) ControlPlane";
24}
25
26pub trait ControlPlaneProxyInterface: Send + Sync {
27 type ControlDoResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
28 fn r#control_do(&self) -> Self::ControlDoResponseFut;
29}
30#[derive(Debug)]
31#[cfg(target_os = "fuchsia")]
32pub struct ControlPlaneSynchronousProxy {
33 client: fidl::client::sync::Client,
34}
35
36#[cfg(target_os = "fuchsia")]
37impl fidl::endpoints::SynchronousProxy for ControlPlaneSynchronousProxy {
38 type Proxy = ControlPlaneProxy;
39 type Protocol = ControlPlaneMarker;
40
41 fn from_channel(inner: fidl::Channel) -> Self {
42 Self::new(inner)
43 }
44
45 fn into_channel(self) -> fidl::Channel {
46 self.client.into_channel()
47 }
48
49 fn as_channel(&self) -> &fidl::Channel {
50 self.client.as_channel()
51 }
52}
53
54#[cfg(target_os = "fuchsia")]
55impl ControlPlaneSynchronousProxy {
56 pub fn new(channel: fidl::Channel) -> Self {
57 let protocol_name = <ControlPlaneMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
58 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
59 }
60
61 pub fn into_channel(self) -> fidl::Channel {
62 self.client.into_channel()
63 }
64
65 pub fn wait_for_event(
68 &self,
69 deadline: zx::MonotonicInstant,
70 ) -> Result<ControlPlaneEvent, fidl::Error> {
71 ControlPlaneEvent::decode(self.client.wait_for_event(deadline)?)
72 }
73
74 pub fn r#control_do(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
75 let _response =
76 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
77 (),
78 0x668f0515ba2e1ebc,
79 fidl::encoding::DynamicFlags::empty(),
80 ___deadline,
81 )?;
82 Ok(_response)
83 }
84}
85
86#[cfg(target_os = "fuchsia")]
87impl From<ControlPlaneSynchronousProxy> for zx::NullableHandle {
88 fn from(value: ControlPlaneSynchronousProxy) -> Self {
89 value.into_channel().into()
90 }
91}
92
93#[cfg(target_os = "fuchsia")]
94impl From<fidl::Channel> for ControlPlaneSynchronousProxy {
95 fn from(value: fidl::Channel) -> Self {
96 Self::new(value)
97 }
98}
99
100#[cfg(target_os = "fuchsia")]
101impl fidl::endpoints::FromClient for ControlPlaneSynchronousProxy {
102 type Protocol = ControlPlaneMarker;
103
104 fn from_client(value: fidl::endpoints::ClientEnd<ControlPlaneMarker>) -> Self {
105 Self::new(value.into_channel())
106 }
107}
108
109#[derive(Debug, Clone)]
110pub struct ControlPlaneProxy {
111 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
112}
113
114impl fidl::endpoints::Proxy for ControlPlaneProxy {
115 type Protocol = ControlPlaneMarker;
116
117 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
118 Self::new(inner)
119 }
120
121 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
122 self.client.into_channel().map_err(|client| Self { client })
123 }
124
125 fn as_channel(&self) -> &::fidl::AsyncChannel {
126 self.client.as_channel()
127 }
128}
129
130impl ControlPlaneProxy {
131 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
133 let protocol_name = <ControlPlaneMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
134 Self { client: fidl::client::Client::new(channel, protocol_name) }
135 }
136
137 pub fn take_event_stream(&self) -> ControlPlaneEventStream {
143 ControlPlaneEventStream { event_receiver: self.client.take_event_receiver() }
144 }
145
146 pub fn r#control_do(
147 &self,
148 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
149 ControlPlaneProxyInterface::r#control_do(self)
150 }
151}
152
153impl ControlPlaneProxyInterface for ControlPlaneProxy {
154 type ControlDoResponseFut =
155 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
156 fn r#control_do(&self) -> Self::ControlDoResponseFut {
157 fn _decode(
158 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
159 ) -> Result<(), fidl::Error> {
160 let _response = fidl::client::decode_transaction_body::<
161 fidl::encoding::EmptyPayload,
162 fidl::encoding::DefaultFuchsiaResourceDialect,
163 0x668f0515ba2e1ebc,
164 >(_buf?)?;
165 Ok(_response)
166 }
167 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
168 (),
169 0x668f0515ba2e1ebc,
170 fidl::encoding::DynamicFlags::empty(),
171 _decode,
172 )
173 }
174}
175
176pub struct ControlPlaneEventStream {
177 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
178}
179
180impl std::marker::Unpin for ControlPlaneEventStream {}
181
182impl futures::stream::FusedStream for ControlPlaneEventStream {
183 fn is_terminated(&self) -> bool {
184 self.event_receiver.is_terminated()
185 }
186}
187
188impl futures::Stream for ControlPlaneEventStream {
189 type Item = Result<ControlPlaneEvent, fidl::Error>;
190
191 fn poll_next(
192 mut self: std::pin::Pin<&mut Self>,
193 cx: &mut std::task::Context<'_>,
194 ) -> std::task::Poll<Option<Self::Item>> {
195 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
196 &mut self.event_receiver,
197 cx
198 )?) {
199 Some(buf) => std::task::Poll::Ready(Some(ControlPlaneEvent::decode(buf))),
200 None => std::task::Poll::Ready(None),
201 }
202 }
203}
204
205#[derive(Debug)]
206pub enum ControlPlaneEvent {}
207
208impl ControlPlaneEvent {
209 fn decode(
211 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
212 ) -> Result<ControlPlaneEvent, fidl::Error> {
213 let (bytes, _handles) = buf.split_mut();
214 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
215 debug_assert_eq!(tx_header.tx_id, 0);
216 match tx_header.ordinal {
217 _ => Err(fidl::Error::UnknownOrdinal {
218 ordinal: tx_header.ordinal,
219 protocol_name: <ControlPlaneMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
220 }),
221 }
222 }
223}
224
225pub struct ControlPlaneRequestStream {
227 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
228 is_terminated: bool,
229}
230
231impl std::marker::Unpin for ControlPlaneRequestStream {}
232
233impl futures::stream::FusedStream for ControlPlaneRequestStream {
234 fn is_terminated(&self) -> bool {
235 self.is_terminated
236 }
237}
238
239impl fidl::endpoints::RequestStream for ControlPlaneRequestStream {
240 type Protocol = ControlPlaneMarker;
241 type ControlHandle = ControlPlaneControlHandle;
242
243 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
244 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
245 }
246
247 fn control_handle(&self) -> Self::ControlHandle {
248 ControlPlaneControlHandle { inner: self.inner.clone() }
249 }
250
251 fn into_inner(
252 self,
253 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
254 {
255 (self.inner, self.is_terminated)
256 }
257
258 fn from_inner(
259 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
260 is_terminated: bool,
261 ) -> Self {
262 Self { inner, is_terminated }
263 }
264}
265
266impl futures::Stream for ControlPlaneRequestStream {
267 type Item = Result<ControlPlaneRequest, fidl::Error>;
268
269 fn poll_next(
270 mut self: std::pin::Pin<&mut Self>,
271 cx: &mut std::task::Context<'_>,
272 ) -> std::task::Poll<Option<Self::Item>> {
273 let this = &mut *self;
274 if this.inner.check_shutdown(cx) {
275 this.is_terminated = true;
276 return std::task::Poll::Ready(None);
277 }
278 if this.is_terminated {
279 panic!("polled ControlPlaneRequestStream after completion");
280 }
281 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
282 |bytes, handles| {
283 match this.inner.channel().read_etc(cx, bytes, handles) {
284 std::task::Poll::Ready(Ok(())) => {}
285 std::task::Poll::Pending => return std::task::Poll::Pending,
286 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
287 this.is_terminated = true;
288 return std::task::Poll::Ready(None);
289 }
290 std::task::Poll::Ready(Err(e)) => {
291 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
292 e.into(),
293 ))));
294 }
295 }
296
297 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
299
300 std::task::Poll::Ready(Some(match header.ordinal {
301 0x668f0515ba2e1ebc => {
302 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
303 let mut req = fidl::new_empty!(
304 fidl::encoding::EmptyPayload,
305 fidl::encoding::DefaultFuchsiaResourceDialect
306 );
307 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
308 let control_handle =
309 ControlPlaneControlHandle { inner: this.inner.clone() };
310 Ok(ControlPlaneRequest::ControlDo {
311 responder: ControlPlaneControlDoResponder {
312 control_handle: std::mem::ManuallyDrop::new(control_handle),
313 tx_id: header.tx_id,
314 },
315 })
316 }
317 _ => Err(fidl::Error::UnknownOrdinal {
318 ordinal: header.ordinal,
319 protocol_name:
320 <ControlPlaneMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
321 }),
322 }))
323 },
324 )
325 }
326}
327
328#[derive(Debug)]
329pub enum ControlPlaneRequest {
330 ControlDo { responder: ControlPlaneControlDoResponder },
331}
332
333impl ControlPlaneRequest {
334 #[allow(irrefutable_let_patterns)]
335 pub fn into_control_do(self) -> Option<(ControlPlaneControlDoResponder)> {
336 if let ControlPlaneRequest::ControlDo { responder } = self {
337 Some((responder))
338 } else {
339 None
340 }
341 }
342
343 pub fn method_name(&self) -> &'static str {
345 match *self {
346 ControlPlaneRequest::ControlDo { .. } => "control_do",
347 }
348 }
349}
350
351#[derive(Debug, Clone)]
352pub struct ControlPlaneControlHandle {
353 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
354}
355
356impl fidl::endpoints::ControlHandle for ControlPlaneControlHandle {
357 fn shutdown(&self) {
358 self.inner.shutdown()
359 }
360
361 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
362 self.inner.shutdown_with_epitaph(status)
363 }
364
365 fn is_closed(&self) -> bool {
366 self.inner.channel().is_closed()
367 }
368 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
369 self.inner.channel().on_closed()
370 }
371
372 #[cfg(target_os = "fuchsia")]
373 fn signal_peer(
374 &self,
375 clear_mask: zx::Signals,
376 set_mask: zx::Signals,
377 ) -> Result<(), zx_status::Status> {
378 use fidl::Peered;
379 self.inner.channel().signal_peer(clear_mask, set_mask)
380 }
381}
382
383impl ControlPlaneControlHandle {}
384
385#[must_use = "FIDL methods require a response to be sent"]
386#[derive(Debug)]
387pub struct ControlPlaneControlDoResponder {
388 control_handle: std::mem::ManuallyDrop<ControlPlaneControlHandle>,
389 tx_id: u32,
390}
391
392impl std::ops::Drop for ControlPlaneControlDoResponder {
396 fn drop(&mut self) {
397 self.control_handle.shutdown();
398 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
400 }
401}
402
403impl fidl::endpoints::Responder for ControlPlaneControlDoResponder {
404 type ControlHandle = ControlPlaneControlHandle;
405
406 fn control_handle(&self) -> &ControlPlaneControlHandle {
407 &self.control_handle
408 }
409
410 fn drop_without_shutdown(mut self) {
411 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
413 std::mem::forget(self);
415 }
416}
417
418impl ControlPlaneControlDoResponder {
419 pub fn send(self) -> Result<(), fidl::Error> {
423 let _result = self.send_raw();
424 if _result.is_err() {
425 self.control_handle.shutdown();
426 }
427 self.drop_without_shutdown();
428 _result
429 }
430
431 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
433 let _result = self.send_raw();
434 self.drop_without_shutdown();
435 _result
436 }
437
438 fn send_raw(&self) -> Result<(), fidl::Error> {
439 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
440 (),
441 self.tx_id,
442 0x668f0515ba2e1ebc,
443 fidl::encoding::DynamicFlags::empty(),
444 )
445 }
446}
447
448#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
449pub struct DataPlaneMarker;
450
451impl fidl::endpoints::ProtocolMarker for DataPlaneMarker {
452 type Proxy = DataPlaneProxy;
453 type RequestStream = DataPlaneRequestStream;
454 #[cfg(target_os = "fuchsia")]
455 type SynchronousProxy = DataPlaneSynchronousProxy;
456
457 const DEBUG_NAME: &'static str = "(anonymous) DataPlane";
458}
459
460pub trait DataPlaneProxyInterface: Send + Sync {
461 type DataDoResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
462 fn r#data_do(&self) -> Self::DataDoResponseFut;
463}
464#[derive(Debug)]
465#[cfg(target_os = "fuchsia")]
466pub struct DataPlaneSynchronousProxy {
467 client: fidl::client::sync::Client,
468}
469
470#[cfg(target_os = "fuchsia")]
471impl fidl::endpoints::SynchronousProxy for DataPlaneSynchronousProxy {
472 type Proxy = DataPlaneProxy;
473 type Protocol = DataPlaneMarker;
474
475 fn from_channel(inner: fidl::Channel) -> Self {
476 Self::new(inner)
477 }
478
479 fn into_channel(self) -> fidl::Channel {
480 self.client.into_channel()
481 }
482
483 fn as_channel(&self) -> &fidl::Channel {
484 self.client.as_channel()
485 }
486}
487
488#[cfg(target_os = "fuchsia")]
489impl DataPlaneSynchronousProxy {
490 pub fn new(channel: fidl::Channel) -> Self {
491 let protocol_name = <DataPlaneMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
492 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
493 }
494
495 pub fn into_channel(self) -> fidl::Channel {
496 self.client.into_channel()
497 }
498
499 pub fn wait_for_event(
502 &self,
503 deadline: zx::MonotonicInstant,
504 ) -> Result<DataPlaneEvent, fidl::Error> {
505 DataPlaneEvent::decode(self.client.wait_for_event(deadline)?)
506 }
507
508 pub fn r#data_do(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
509 let _response =
510 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
511 (),
512 0x1c8c82496b32e147,
513 fidl::encoding::DynamicFlags::empty(),
514 ___deadline,
515 )?;
516 Ok(_response)
517 }
518}
519
520#[cfg(target_os = "fuchsia")]
521impl From<DataPlaneSynchronousProxy> for zx::NullableHandle {
522 fn from(value: DataPlaneSynchronousProxy) -> Self {
523 value.into_channel().into()
524 }
525}
526
527#[cfg(target_os = "fuchsia")]
528impl From<fidl::Channel> for DataPlaneSynchronousProxy {
529 fn from(value: fidl::Channel) -> Self {
530 Self::new(value)
531 }
532}
533
534#[cfg(target_os = "fuchsia")]
535impl fidl::endpoints::FromClient for DataPlaneSynchronousProxy {
536 type Protocol = DataPlaneMarker;
537
538 fn from_client(value: fidl::endpoints::ClientEnd<DataPlaneMarker>) -> Self {
539 Self::new(value.into_channel())
540 }
541}
542
543#[derive(Debug, Clone)]
544pub struct DataPlaneProxy {
545 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
546}
547
548impl fidl::endpoints::Proxy for DataPlaneProxy {
549 type Protocol = DataPlaneMarker;
550
551 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
552 Self::new(inner)
553 }
554
555 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
556 self.client.into_channel().map_err(|client| Self { client })
557 }
558
559 fn as_channel(&self) -> &::fidl::AsyncChannel {
560 self.client.as_channel()
561 }
562}
563
564impl DataPlaneProxy {
565 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
567 let protocol_name = <DataPlaneMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
568 Self { client: fidl::client::Client::new(channel, protocol_name) }
569 }
570
571 pub fn take_event_stream(&self) -> DataPlaneEventStream {
577 DataPlaneEventStream { event_receiver: self.client.take_event_receiver() }
578 }
579
580 pub fn r#data_do(
581 &self,
582 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
583 DataPlaneProxyInterface::r#data_do(self)
584 }
585}
586
587impl DataPlaneProxyInterface for DataPlaneProxy {
588 type DataDoResponseFut =
589 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
590 fn r#data_do(&self) -> Self::DataDoResponseFut {
591 fn _decode(
592 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
593 ) -> Result<(), fidl::Error> {
594 let _response = fidl::client::decode_transaction_body::<
595 fidl::encoding::EmptyPayload,
596 fidl::encoding::DefaultFuchsiaResourceDialect,
597 0x1c8c82496b32e147,
598 >(_buf?)?;
599 Ok(_response)
600 }
601 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
602 (),
603 0x1c8c82496b32e147,
604 fidl::encoding::DynamicFlags::empty(),
605 _decode,
606 )
607 }
608}
609
610pub struct DataPlaneEventStream {
611 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
612}
613
614impl std::marker::Unpin for DataPlaneEventStream {}
615
616impl futures::stream::FusedStream for DataPlaneEventStream {
617 fn is_terminated(&self) -> bool {
618 self.event_receiver.is_terminated()
619 }
620}
621
622impl futures::Stream for DataPlaneEventStream {
623 type Item = Result<DataPlaneEvent, fidl::Error>;
624
625 fn poll_next(
626 mut self: std::pin::Pin<&mut Self>,
627 cx: &mut std::task::Context<'_>,
628 ) -> std::task::Poll<Option<Self::Item>> {
629 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
630 &mut self.event_receiver,
631 cx
632 )?) {
633 Some(buf) => std::task::Poll::Ready(Some(DataPlaneEvent::decode(buf))),
634 None => std::task::Poll::Ready(None),
635 }
636 }
637}
638
639#[derive(Debug)]
640pub enum DataPlaneEvent {}
641
642impl DataPlaneEvent {
643 fn decode(
645 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
646 ) -> Result<DataPlaneEvent, fidl::Error> {
647 let (bytes, _handles) = buf.split_mut();
648 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
649 debug_assert_eq!(tx_header.tx_id, 0);
650 match tx_header.ordinal {
651 _ => Err(fidl::Error::UnknownOrdinal {
652 ordinal: tx_header.ordinal,
653 protocol_name: <DataPlaneMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
654 }),
655 }
656 }
657}
658
659pub struct DataPlaneRequestStream {
661 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
662 is_terminated: bool,
663}
664
665impl std::marker::Unpin for DataPlaneRequestStream {}
666
667impl futures::stream::FusedStream for DataPlaneRequestStream {
668 fn is_terminated(&self) -> bool {
669 self.is_terminated
670 }
671}
672
673impl fidl::endpoints::RequestStream for DataPlaneRequestStream {
674 type Protocol = DataPlaneMarker;
675 type ControlHandle = DataPlaneControlHandle;
676
677 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
678 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
679 }
680
681 fn control_handle(&self) -> Self::ControlHandle {
682 DataPlaneControlHandle { inner: self.inner.clone() }
683 }
684
685 fn into_inner(
686 self,
687 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
688 {
689 (self.inner, self.is_terminated)
690 }
691
692 fn from_inner(
693 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
694 is_terminated: bool,
695 ) -> Self {
696 Self { inner, is_terminated }
697 }
698}
699
700impl futures::Stream for DataPlaneRequestStream {
701 type Item = Result<DataPlaneRequest, fidl::Error>;
702
703 fn poll_next(
704 mut self: std::pin::Pin<&mut Self>,
705 cx: &mut std::task::Context<'_>,
706 ) -> std::task::Poll<Option<Self::Item>> {
707 let this = &mut *self;
708 if this.inner.check_shutdown(cx) {
709 this.is_terminated = true;
710 return std::task::Poll::Ready(None);
711 }
712 if this.is_terminated {
713 panic!("polled DataPlaneRequestStream after completion");
714 }
715 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
716 |bytes, handles| {
717 match this.inner.channel().read_etc(cx, bytes, handles) {
718 std::task::Poll::Ready(Ok(())) => {}
719 std::task::Poll::Pending => return std::task::Poll::Pending,
720 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
721 this.is_terminated = true;
722 return std::task::Poll::Ready(None);
723 }
724 std::task::Poll::Ready(Err(e)) => {
725 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
726 e.into(),
727 ))));
728 }
729 }
730
731 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
733
734 std::task::Poll::Ready(Some(match header.ordinal {
735 0x1c8c82496b32e147 => {
736 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
737 let mut req = fidl::new_empty!(
738 fidl::encoding::EmptyPayload,
739 fidl::encoding::DefaultFuchsiaResourceDialect
740 );
741 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
742 let control_handle = DataPlaneControlHandle { inner: this.inner.clone() };
743 Ok(DataPlaneRequest::DataDo {
744 responder: DataPlaneDataDoResponder {
745 control_handle: std::mem::ManuallyDrop::new(control_handle),
746 tx_id: header.tx_id,
747 },
748 })
749 }
750 _ => Err(fidl::Error::UnknownOrdinal {
751 ordinal: header.ordinal,
752 protocol_name:
753 <DataPlaneMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
754 }),
755 }))
756 },
757 )
758 }
759}
760
761#[derive(Debug)]
762pub enum DataPlaneRequest {
763 DataDo { responder: DataPlaneDataDoResponder },
764}
765
766impl DataPlaneRequest {
767 #[allow(irrefutable_let_patterns)]
768 pub fn into_data_do(self) -> Option<(DataPlaneDataDoResponder)> {
769 if let DataPlaneRequest::DataDo { responder } = self { Some((responder)) } else { None }
770 }
771
772 pub fn method_name(&self) -> &'static str {
774 match *self {
775 DataPlaneRequest::DataDo { .. } => "data_do",
776 }
777 }
778}
779
780#[derive(Debug, Clone)]
781pub struct DataPlaneControlHandle {
782 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
783}
784
785impl fidl::endpoints::ControlHandle for DataPlaneControlHandle {
786 fn shutdown(&self) {
787 self.inner.shutdown()
788 }
789
790 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
791 self.inner.shutdown_with_epitaph(status)
792 }
793
794 fn is_closed(&self) -> bool {
795 self.inner.channel().is_closed()
796 }
797 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
798 self.inner.channel().on_closed()
799 }
800
801 #[cfg(target_os = "fuchsia")]
802 fn signal_peer(
803 &self,
804 clear_mask: zx::Signals,
805 set_mask: zx::Signals,
806 ) -> Result<(), zx_status::Status> {
807 use fidl::Peered;
808 self.inner.channel().signal_peer(clear_mask, set_mask)
809 }
810}
811
812impl DataPlaneControlHandle {}
813
814#[must_use = "FIDL methods require a response to be sent"]
815#[derive(Debug)]
816pub struct DataPlaneDataDoResponder {
817 control_handle: std::mem::ManuallyDrop<DataPlaneControlHandle>,
818 tx_id: u32,
819}
820
821impl std::ops::Drop for DataPlaneDataDoResponder {
825 fn drop(&mut self) {
826 self.control_handle.shutdown();
827 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
829 }
830}
831
832impl fidl::endpoints::Responder for DataPlaneDataDoResponder {
833 type ControlHandle = DataPlaneControlHandle;
834
835 fn control_handle(&self) -> &DataPlaneControlHandle {
836 &self.control_handle
837 }
838
839 fn drop_without_shutdown(mut self) {
840 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
842 std::mem::forget(self);
844 }
845}
846
847impl DataPlaneDataDoResponder {
848 pub fn send(self) -> Result<(), fidl::Error> {
852 let _result = self.send_raw();
853 if _result.is_err() {
854 self.control_handle.shutdown();
855 }
856 self.drop_without_shutdown();
857 _result
858 }
859
860 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
862 let _result = self.send_raw();
863 self.drop_without_shutdown();
864 _result
865 }
866
867 fn send_raw(&self) -> Result<(), fidl::Error> {
868 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
869 (),
870 self.tx_id,
871 0x1c8c82496b32e147,
872 fidl::encoding::DynamicFlags::empty(),
873 )
874 }
875}
876
877#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
878pub struct DeviceMarker;
879
880#[cfg(target_os = "fuchsia")]
881impl fidl::endpoints::ServiceMarker for DeviceMarker {
882 type Proxy = DeviceProxy;
883 type Request = DeviceRequest;
884 const SERVICE_NAME: &'static str = "fuchsia.services.test.Device";
885}
886
887#[cfg(target_os = "fuchsia")]
890pub enum DeviceRequest {
891 Control(ControlPlaneRequestStream),
892 Data(DataPlaneRequestStream),
893}
894
895#[cfg(target_os = "fuchsia")]
896impl fidl::endpoints::ServiceRequest for DeviceRequest {
897 type Service = DeviceMarker;
898
899 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
900 match name {
901 "control" => Self::Control(
902 <ControlPlaneRequestStream as fidl::endpoints::RequestStream>::from_channel(
903 _channel,
904 ),
905 ),
906 "data" => Self::Data(
907 <DataPlaneRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
908 ),
909 _ => panic!("no such member protocol name for service Device"),
910 }
911 }
912
913 fn member_names() -> &'static [&'static str] {
914 &["control", "data"]
915 }
916}
917#[cfg(target_os = "fuchsia")]
918pub struct DeviceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
919
920#[cfg(target_os = "fuchsia")]
921impl fidl::endpoints::ServiceProxy for DeviceProxy {
922 type Service = DeviceMarker;
923
924 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
925 Self(opener)
926 }
927}
928
929#[cfg(target_os = "fuchsia")]
930impl DeviceProxy {
931 pub fn connect_to_control(&self) -> Result<ControlPlaneProxy, fidl::Error> {
932 let (proxy, server_end) = fidl::endpoints::create_proxy::<ControlPlaneMarker>();
933 self.connect_channel_to_control(server_end)?;
934 Ok(proxy)
935 }
936
937 pub fn connect_to_control_sync(&self) -> Result<ControlPlaneSynchronousProxy, fidl::Error> {
940 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ControlPlaneMarker>();
941 self.connect_channel_to_control(server_end)?;
942 Ok(proxy)
943 }
944
945 pub fn connect_channel_to_control(
948 &self,
949 server_end: fidl::endpoints::ServerEnd<ControlPlaneMarker>,
950 ) -> Result<(), fidl::Error> {
951 self.0.open_member("control", server_end.into_channel())
952 }
953 pub fn connect_to_data(&self) -> Result<DataPlaneProxy, fidl::Error> {
954 let (proxy, server_end) = fidl::endpoints::create_proxy::<DataPlaneMarker>();
955 self.connect_channel_to_data(server_end)?;
956 Ok(proxy)
957 }
958
959 pub fn connect_to_data_sync(&self) -> Result<DataPlaneSynchronousProxy, fidl::Error> {
962 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DataPlaneMarker>();
963 self.connect_channel_to_data(server_end)?;
964 Ok(proxy)
965 }
966
967 pub fn connect_channel_to_data(
970 &self,
971 server_end: fidl::endpoints::ServerEnd<DataPlaneMarker>,
972 ) -> Result<(), fidl::Error> {
973 self.0.open_member("data", server_end.into_channel())
974 }
975
976 pub fn instance_name(&self) -> &str {
977 self.0.instance_name()
978 }
979}
980
981mod internal {
982 use super::*;
983}