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