fidl_fuchsia_rebind_test/
fidl_fuchsia_rebind_test.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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_rebind_test_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct RebindChildMarker;
16
17impl fidl::endpoints::ProtocolMarker for RebindChildMarker {
18    type Proxy = RebindChildProxy;
19    type RequestStream = RebindChildRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = RebindChildSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "(anonymous) RebindChild";
24}
25
26pub trait RebindChildProxyInterface: Send + Sync {}
27#[derive(Debug)]
28#[cfg(target_os = "fuchsia")]
29pub struct RebindChildSynchronousProxy {
30    client: fidl::client::sync::Client,
31}
32
33#[cfg(target_os = "fuchsia")]
34impl fidl::endpoints::SynchronousProxy for RebindChildSynchronousProxy {
35    type Proxy = RebindChildProxy;
36    type Protocol = RebindChildMarker;
37
38    fn from_channel(inner: fidl::Channel) -> Self {
39        Self::new(inner)
40    }
41
42    fn into_channel(self) -> fidl::Channel {
43        self.client.into_channel()
44    }
45
46    fn as_channel(&self) -> &fidl::Channel {
47        self.client.as_channel()
48    }
49}
50
51#[cfg(target_os = "fuchsia")]
52impl RebindChildSynchronousProxy {
53    pub fn new(channel: fidl::Channel) -> Self {
54        let protocol_name = <RebindChildMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
55        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
56    }
57
58    pub fn into_channel(self) -> fidl::Channel {
59        self.client.into_channel()
60    }
61
62    /// Waits until an event arrives and returns it. It is safe for other
63    /// threads to make concurrent requests while waiting for an event.
64    pub fn wait_for_event(
65        &self,
66        deadline: zx::MonotonicInstant,
67    ) -> Result<RebindChildEvent, fidl::Error> {
68        RebindChildEvent::decode(self.client.wait_for_event(deadline)?)
69    }
70}
71
72#[derive(Debug, Clone)]
73pub struct RebindChildProxy {
74    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
75}
76
77impl fidl::endpoints::Proxy for RebindChildProxy {
78    type Protocol = RebindChildMarker;
79
80    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
81        Self::new(inner)
82    }
83
84    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
85        self.client.into_channel().map_err(|client| Self { client })
86    }
87
88    fn as_channel(&self) -> &::fidl::AsyncChannel {
89        self.client.as_channel()
90    }
91}
92
93impl RebindChildProxy {
94    /// Create a new Proxy for fuchsia.rebind.test/RebindChild.
95    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
96        let protocol_name = <RebindChildMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
97        Self { client: fidl::client::Client::new(channel, protocol_name) }
98    }
99
100    /// Get a Stream of events from the remote end of the protocol.
101    ///
102    /// # Panics
103    ///
104    /// Panics if the event stream was already taken.
105    pub fn take_event_stream(&self) -> RebindChildEventStream {
106        RebindChildEventStream { event_receiver: self.client.take_event_receiver() }
107    }
108}
109
110impl RebindChildProxyInterface for RebindChildProxy {}
111
112pub struct RebindChildEventStream {
113    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
114}
115
116impl std::marker::Unpin for RebindChildEventStream {}
117
118impl futures::stream::FusedStream for RebindChildEventStream {
119    fn is_terminated(&self) -> bool {
120        self.event_receiver.is_terminated()
121    }
122}
123
124impl futures::Stream for RebindChildEventStream {
125    type Item = Result<RebindChildEvent, fidl::Error>;
126
127    fn poll_next(
128        mut self: std::pin::Pin<&mut Self>,
129        cx: &mut std::task::Context<'_>,
130    ) -> std::task::Poll<Option<Self::Item>> {
131        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
132            &mut self.event_receiver,
133            cx
134        )?) {
135            Some(buf) => std::task::Poll::Ready(Some(RebindChildEvent::decode(buf))),
136            None => std::task::Poll::Ready(None),
137        }
138    }
139}
140
141#[derive(Debug)]
142pub enum RebindChildEvent {}
143
144impl RebindChildEvent {
145    /// Decodes a message buffer as a [`RebindChildEvent`].
146    fn decode(
147        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
148    ) -> Result<RebindChildEvent, fidl::Error> {
149        let (bytes, _handles) = buf.split_mut();
150        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
151        debug_assert_eq!(tx_header.tx_id, 0);
152        match tx_header.ordinal {
153            _ => Err(fidl::Error::UnknownOrdinal {
154                ordinal: tx_header.ordinal,
155                protocol_name: <RebindChildMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
156            }),
157        }
158    }
159}
160
161/// A Stream of incoming requests for fuchsia.rebind.test/RebindChild.
162pub struct RebindChildRequestStream {
163    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
164    is_terminated: bool,
165}
166
167impl std::marker::Unpin for RebindChildRequestStream {}
168
169impl futures::stream::FusedStream for RebindChildRequestStream {
170    fn is_terminated(&self) -> bool {
171        self.is_terminated
172    }
173}
174
175impl fidl::endpoints::RequestStream for RebindChildRequestStream {
176    type Protocol = RebindChildMarker;
177    type ControlHandle = RebindChildControlHandle;
178
179    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
180        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
181    }
182
183    fn control_handle(&self) -> Self::ControlHandle {
184        RebindChildControlHandle { inner: self.inner.clone() }
185    }
186
187    fn into_inner(
188        self,
189    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
190    {
191        (self.inner, self.is_terminated)
192    }
193
194    fn from_inner(
195        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
196        is_terminated: bool,
197    ) -> Self {
198        Self { inner, is_terminated }
199    }
200}
201
202impl futures::Stream for RebindChildRequestStream {
203    type Item = Result<RebindChildRequest, fidl::Error>;
204
205    fn poll_next(
206        mut self: std::pin::Pin<&mut Self>,
207        cx: &mut std::task::Context<'_>,
208    ) -> std::task::Poll<Option<Self::Item>> {
209        let this = &mut *self;
210        if this.inner.check_shutdown(cx) {
211            this.is_terminated = true;
212            return std::task::Poll::Ready(None);
213        }
214        if this.is_terminated {
215            panic!("polled RebindChildRequestStream after completion");
216        }
217        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
218            |bytes, handles| {
219                match this.inner.channel().read_etc(cx, bytes, handles) {
220                    std::task::Poll::Ready(Ok(())) => {}
221                    std::task::Poll::Pending => return std::task::Poll::Pending,
222                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
223                        this.is_terminated = true;
224                        return std::task::Poll::Ready(None);
225                    }
226                    std::task::Poll::Ready(Err(e)) => {
227                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
228                            e.into(),
229                        ))))
230                    }
231                }
232
233                // A message has been received from the channel
234                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
235
236                std::task::Poll::Ready(Some(match header.ordinal {
237                    _ => Err(fidl::Error::UnknownOrdinal {
238                        ordinal: header.ordinal,
239                        protocol_name:
240                            <RebindChildMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
241                    }),
242                }))
243            },
244        )
245    }
246}
247
248#[derive(Debug)]
249pub enum RebindChildRequest {}
250
251impl RebindChildRequest {
252    /// Name of the method defined in FIDL
253    pub fn method_name(&self) -> &'static str {
254        match *self {}
255    }
256}
257
258#[derive(Debug, Clone)]
259pub struct RebindChildControlHandle {
260    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
261}
262
263impl fidl::endpoints::ControlHandle for RebindChildControlHandle {
264    fn shutdown(&self) {
265        self.inner.shutdown()
266    }
267    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
268        self.inner.shutdown_with_epitaph(status)
269    }
270
271    fn is_closed(&self) -> bool {
272        self.inner.channel().is_closed()
273    }
274    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
275        self.inner.channel().on_closed()
276    }
277
278    #[cfg(target_os = "fuchsia")]
279    fn signal_peer(
280        &self,
281        clear_mask: zx::Signals,
282        set_mask: zx::Signals,
283    ) -> Result<(), zx_status::Status> {
284        use fidl::Peered;
285        self.inner.channel().signal_peer(clear_mask, set_mask)
286    }
287}
288
289impl RebindChildControlHandle {}
290
291#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
292pub struct RebindParentMarker;
293
294impl fidl::endpoints::ProtocolMarker for RebindParentMarker {
295    type Proxy = RebindParentProxy;
296    type RequestStream = RebindParentRequestStream;
297    #[cfg(target_os = "fuchsia")]
298    type SynchronousProxy = RebindParentSynchronousProxy;
299
300    const DEBUG_NAME: &'static str = "(anonymous) RebindParent";
301}
302pub type RebindParentAddChildResult = Result<(), i32>;
303pub type RebindParentRemoveChildResult = Result<(), i32>;
304
305pub trait RebindParentProxyInterface: Send + Sync {
306    type AddChildResponseFut: std::future::Future<Output = Result<RebindParentAddChildResult, fidl::Error>>
307        + Send;
308    fn r#add_child(&self) -> Self::AddChildResponseFut;
309    type RemoveChildResponseFut: std::future::Future<Output = Result<RebindParentRemoveChildResult, fidl::Error>>
310        + Send;
311    fn r#remove_child(&self) -> Self::RemoveChildResponseFut;
312}
313#[derive(Debug)]
314#[cfg(target_os = "fuchsia")]
315pub struct RebindParentSynchronousProxy {
316    client: fidl::client::sync::Client,
317}
318
319#[cfg(target_os = "fuchsia")]
320impl fidl::endpoints::SynchronousProxy for RebindParentSynchronousProxy {
321    type Proxy = RebindParentProxy;
322    type Protocol = RebindParentMarker;
323
324    fn from_channel(inner: fidl::Channel) -> Self {
325        Self::new(inner)
326    }
327
328    fn into_channel(self) -> fidl::Channel {
329        self.client.into_channel()
330    }
331
332    fn as_channel(&self) -> &fidl::Channel {
333        self.client.as_channel()
334    }
335}
336
337#[cfg(target_os = "fuchsia")]
338impl RebindParentSynchronousProxy {
339    pub fn new(channel: fidl::Channel) -> Self {
340        let protocol_name = <RebindParentMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
341        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
342    }
343
344    pub fn into_channel(self) -> fidl::Channel {
345        self.client.into_channel()
346    }
347
348    /// Waits until an event arrives and returns it. It is safe for other
349    /// threads to make concurrent requests while waiting for an event.
350    pub fn wait_for_event(
351        &self,
352        deadline: zx::MonotonicInstant,
353    ) -> Result<RebindParentEvent, fidl::Error> {
354        RebindParentEvent::decode(self.client.wait_for_event(deadline)?)
355    }
356
357    pub fn r#add_child(
358        &self,
359        ___deadline: zx::MonotonicInstant,
360    ) -> Result<RebindParentAddChildResult, fidl::Error> {
361        let _response = self.client.send_query::<
362            fidl::encoding::EmptyPayload,
363            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
364        >(
365            (),
366            0x74095dc7e942dea5,
367            fidl::encoding::DynamicFlags::empty(),
368            ___deadline,
369        )?;
370        Ok(_response.map(|x| x))
371    }
372
373    pub fn r#remove_child(
374        &self,
375        ___deadline: zx::MonotonicInstant,
376    ) -> Result<RebindParentRemoveChildResult, fidl::Error> {
377        let _response = self.client.send_query::<
378            fidl::encoding::EmptyPayload,
379            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
380        >(
381            (),
382            0x68d3023bfd04c269,
383            fidl::encoding::DynamicFlags::empty(),
384            ___deadline,
385        )?;
386        Ok(_response.map(|x| x))
387    }
388}
389
390#[derive(Debug, Clone)]
391pub struct RebindParentProxy {
392    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
393}
394
395impl fidl::endpoints::Proxy for RebindParentProxy {
396    type Protocol = RebindParentMarker;
397
398    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
399        Self::new(inner)
400    }
401
402    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
403        self.client.into_channel().map_err(|client| Self { client })
404    }
405
406    fn as_channel(&self) -> &::fidl::AsyncChannel {
407        self.client.as_channel()
408    }
409}
410
411impl RebindParentProxy {
412    /// Create a new Proxy for fuchsia.rebind.test/RebindParent.
413    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
414        let protocol_name = <RebindParentMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
415        Self { client: fidl::client::Client::new(channel, protocol_name) }
416    }
417
418    /// Get a Stream of events from the remote end of the protocol.
419    ///
420    /// # Panics
421    ///
422    /// Panics if the event stream was already taken.
423    pub fn take_event_stream(&self) -> RebindParentEventStream {
424        RebindParentEventStream { event_receiver: self.client.take_event_receiver() }
425    }
426
427    pub fn r#add_child(
428        &self,
429    ) -> fidl::client::QueryResponseFut<
430        RebindParentAddChildResult,
431        fidl::encoding::DefaultFuchsiaResourceDialect,
432    > {
433        RebindParentProxyInterface::r#add_child(self)
434    }
435
436    pub fn r#remove_child(
437        &self,
438    ) -> fidl::client::QueryResponseFut<
439        RebindParentRemoveChildResult,
440        fidl::encoding::DefaultFuchsiaResourceDialect,
441    > {
442        RebindParentProxyInterface::r#remove_child(self)
443    }
444}
445
446impl RebindParentProxyInterface for RebindParentProxy {
447    type AddChildResponseFut = fidl::client::QueryResponseFut<
448        RebindParentAddChildResult,
449        fidl::encoding::DefaultFuchsiaResourceDialect,
450    >;
451    fn r#add_child(&self) -> Self::AddChildResponseFut {
452        fn _decode(
453            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
454        ) -> Result<RebindParentAddChildResult, fidl::Error> {
455            let _response = fidl::client::decode_transaction_body::<
456                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
457                fidl::encoding::DefaultFuchsiaResourceDialect,
458                0x74095dc7e942dea5,
459            >(_buf?)?;
460            Ok(_response.map(|x| x))
461        }
462        self.client
463            .send_query_and_decode::<fidl::encoding::EmptyPayload, RebindParentAddChildResult>(
464                (),
465                0x74095dc7e942dea5,
466                fidl::encoding::DynamicFlags::empty(),
467                _decode,
468            )
469    }
470
471    type RemoveChildResponseFut = fidl::client::QueryResponseFut<
472        RebindParentRemoveChildResult,
473        fidl::encoding::DefaultFuchsiaResourceDialect,
474    >;
475    fn r#remove_child(&self) -> Self::RemoveChildResponseFut {
476        fn _decode(
477            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
478        ) -> Result<RebindParentRemoveChildResult, fidl::Error> {
479            let _response = fidl::client::decode_transaction_body::<
480                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
481                fidl::encoding::DefaultFuchsiaResourceDialect,
482                0x68d3023bfd04c269,
483            >(_buf?)?;
484            Ok(_response.map(|x| x))
485        }
486        self.client
487            .send_query_and_decode::<fidl::encoding::EmptyPayload, RebindParentRemoveChildResult>(
488                (),
489                0x68d3023bfd04c269,
490                fidl::encoding::DynamicFlags::empty(),
491                _decode,
492            )
493    }
494}
495
496pub struct RebindParentEventStream {
497    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
498}
499
500impl std::marker::Unpin for RebindParentEventStream {}
501
502impl futures::stream::FusedStream for RebindParentEventStream {
503    fn is_terminated(&self) -> bool {
504        self.event_receiver.is_terminated()
505    }
506}
507
508impl futures::Stream for RebindParentEventStream {
509    type Item = Result<RebindParentEvent, fidl::Error>;
510
511    fn poll_next(
512        mut self: std::pin::Pin<&mut Self>,
513        cx: &mut std::task::Context<'_>,
514    ) -> std::task::Poll<Option<Self::Item>> {
515        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
516            &mut self.event_receiver,
517            cx
518        )?) {
519            Some(buf) => std::task::Poll::Ready(Some(RebindParentEvent::decode(buf))),
520            None => std::task::Poll::Ready(None),
521        }
522    }
523}
524
525#[derive(Debug)]
526pub enum RebindParentEvent {}
527
528impl RebindParentEvent {
529    /// Decodes a message buffer as a [`RebindParentEvent`].
530    fn decode(
531        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
532    ) -> Result<RebindParentEvent, fidl::Error> {
533        let (bytes, _handles) = buf.split_mut();
534        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
535        debug_assert_eq!(tx_header.tx_id, 0);
536        match tx_header.ordinal {
537            _ => Err(fidl::Error::UnknownOrdinal {
538                ordinal: tx_header.ordinal,
539                protocol_name: <RebindParentMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
540            }),
541        }
542    }
543}
544
545/// A Stream of incoming requests for fuchsia.rebind.test/RebindParent.
546pub struct RebindParentRequestStream {
547    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
548    is_terminated: bool,
549}
550
551impl std::marker::Unpin for RebindParentRequestStream {}
552
553impl futures::stream::FusedStream for RebindParentRequestStream {
554    fn is_terminated(&self) -> bool {
555        self.is_terminated
556    }
557}
558
559impl fidl::endpoints::RequestStream for RebindParentRequestStream {
560    type Protocol = RebindParentMarker;
561    type ControlHandle = RebindParentControlHandle;
562
563    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
564        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
565    }
566
567    fn control_handle(&self) -> Self::ControlHandle {
568        RebindParentControlHandle { inner: self.inner.clone() }
569    }
570
571    fn into_inner(
572        self,
573    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
574    {
575        (self.inner, self.is_terminated)
576    }
577
578    fn from_inner(
579        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
580        is_terminated: bool,
581    ) -> Self {
582        Self { inner, is_terminated }
583    }
584}
585
586impl futures::Stream for RebindParentRequestStream {
587    type Item = Result<RebindParentRequest, fidl::Error>;
588
589    fn poll_next(
590        mut self: std::pin::Pin<&mut Self>,
591        cx: &mut std::task::Context<'_>,
592    ) -> std::task::Poll<Option<Self::Item>> {
593        let this = &mut *self;
594        if this.inner.check_shutdown(cx) {
595            this.is_terminated = true;
596            return std::task::Poll::Ready(None);
597        }
598        if this.is_terminated {
599            panic!("polled RebindParentRequestStream after completion");
600        }
601        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
602            |bytes, handles| {
603                match this.inner.channel().read_etc(cx, bytes, handles) {
604                    std::task::Poll::Ready(Ok(())) => {}
605                    std::task::Poll::Pending => return std::task::Poll::Pending,
606                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
607                        this.is_terminated = true;
608                        return std::task::Poll::Ready(None);
609                    }
610                    std::task::Poll::Ready(Err(e)) => {
611                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
612                            e.into(),
613                        ))))
614                    }
615                }
616
617                // A message has been received from the channel
618                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
619
620                std::task::Poll::Ready(Some(match header.ordinal {
621                    0x74095dc7e942dea5 => {
622                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
623                        let mut req = fidl::new_empty!(
624                            fidl::encoding::EmptyPayload,
625                            fidl::encoding::DefaultFuchsiaResourceDialect
626                        );
627                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
628                        let control_handle =
629                            RebindParentControlHandle { inner: this.inner.clone() };
630                        Ok(RebindParentRequest::AddChild {
631                            responder: RebindParentAddChildResponder {
632                                control_handle: std::mem::ManuallyDrop::new(control_handle),
633                                tx_id: header.tx_id,
634                            },
635                        })
636                    }
637                    0x68d3023bfd04c269 => {
638                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
639                        let mut req = fidl::new_empty!(
640                            fidl::encoding::EmptyPayload,
641                            fidl::encoding::DefaultFuchsiaResourceDialect
642                        );
643                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
644                        let control_handle =
645                            RebindParentControlHandle { inner: this.inner.clone() };
646                        Ok(RebindParentRequest::RemoveChild {
647                            responder: RebindParentRemoveChildResponder {
648                                control_handle: std::mem::ManuallyDrop::new(control_handle),
649                                tx_id: header.tx_id,
650                            },
651                        })
652                    }
653                    _ => Err(fidl::Error::UnknownOrdinal {
654                        ordinal: header.ordinal,
655                        protocol_name:
656                            <RebindParentMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
657                    }),
658                }))
659            },
660        )
661    }
662}
663
664#[derive(Debug)]
665pub enum RebindParentRequest {
666    AddChild { responder: RebindParentAddChildResponder },
667    RemoveChild { responder: RebindParentRemoveChildResponder },
668}
669
670impl RebindParentRequest {
671    #[allow(irrefutable_let_patterns)]
672    pub fn into_add_child(self) -> Option<(RebindParentAddChildResponder)> {
673        if let RebindParentRequest::AddChild { responder } = self {
674            Some((responder))
675        } else {
676            None
677        }
678    }
679
680    #[allow(irrefutable_let_patterns)]
681    pub fn into_remove_child(self) -> Option<(RebindParentRemoveChildResponder)> {
682        if let RebindParentRequest::RemoveChild { responder } = self {
683            Some((responder))
684        } else {
685            None
686        }
687    }
688
689    /// Name of the method defined in FIDL
690    pub fn method_name(&self) -> &'static str {
691        match *self {
692            RebindParentRequest::AddChild { .. } => "add_child",
693            RebindParentRequest::RemoveChild { .. } => "remove_child",
694        }
695    }
696}
697
698#[derive(Debug, Clone)]
699pub struct RebindParentControlHandle {
700    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
701}
702
703impl fidl::endpoints::ControlHandle for RebindParentControlHandle {
704    fn shutdown(&self) {
705        self.inner.shutdown()
706    }
707    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
708        self.inner.shutdown_with_epitaph(status)
709    }
710
711    fn is_closed(&self) -> bool {
712        self.inner.channel().is_closed()
713    }
714    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
715        self.inner.channel().on_closed()
716    }
717
718    #[cfg(target_os = "fuchsia")]
719    fn signal_peer(
720        &self,
721        clear_mask: zx::Signals,
722        set_mask: zx::Signals,
723    ) -> Result<(), zx_status::Status> {
724        use fidl::Peered;
725        self.inner.channel().signal_peer(clear_mask, set_mask)
726    }
727}
728
729impl RebindParentControlHandle {}
730
731#[must_use = "FIDL methods require a response to be sent"]
732#[derive(Debug)]
733pub struct RebindParentAddChildResponder {
734    control_handle: std::mem::ManuallyDrop<RebindParentControlHandle>,
735    tx_id: u32,
736}
737
738/// Set the the channel to be shutdown (see [`RebindParentControlHandle::shutdown`])
739/// if the responder is dropped without sending a response, so that the client
740/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
741impl std::ops::Drop for RebindParentAddChildResponder {
742    fn drop(&mut self) {
743        self.control_handle.shutdown();
744        // Safety: drops once, never accessed again
745        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
746    }
747}
748
749impl fidl::endpoints::Responder for RebindParentAddChildResponder {
750    type ControlHandle = RebindParentControlHandle;
751
752    fn control_handle(&self) -> &RebindParentControlHandle {
753        &self.control_handle
754    }
755
756    fn drop_without_shutdown(mut self) {
757        // Safety: drops once, never accessed again due to mem::forget
758        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
759        // Prevent Drop from running (which would shut down the channel)
760        std::mem::forget(self);
761    }
762}
763
764impl RebindParentAddChildResponder {
765    /// Sends a response to the FIDL transaction.
766    ///
767    /// Sets the channel to shutdown if an error occurs.
768    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
769        let _result = self.send_raw(result);
770        if _result.is_err() {
771            self.control_handle.shutdown();
772        }
773        self.drop_without_shutdown();
774        _result
775    }
776
777    /// Similar to "send" but does not shutdown the channel if an error occurs.
778    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
779        let _result = self.send_raw(result);
780        self.drop_without_shutdown();
781        _result
782    }
783
784    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
785        self.control_handle
786            .inner
787            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
788                result,
789                self.tx_id,
790                0x74095dc7e942dea5,
791                fidl::encoding::DynamicFlags::empty(),
792            )
793    }
794}
795
796#[must_use = "FIDL methods require a response to be sent"]
797#[derive(Debug)]
798pub struct RebindParentRemoveChildResponder {
799    control_handle: std::mem::ManuallyDrop<RebindParentControlHandle>,
800    tx_id: u32,
801}
802
803/// Set the the channel to be shutdown (see [`RebindParentControlHandle::shutdown`])
804/// if the responder is dropped without sending a response, so that the client
805/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
806impl std::ops::Drop for RebindParentRemoveChildResponder {
807    fn drop(&mut self) {
808        self.control_handle.shutdown();
809        // Safety: drops once, never accessed again
810        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
811    }
812}
813
814impl fidl::endpoints::Responder for RebindParentRemoveChildResponder {
815    type ControlHandle = RebindParentControlHandle;
816
817    fn control_handle(&self) -> &RebindParentControlHandle {
818        &self.control_handle
819    }
820
821    fn drop_without_shutdown(mut self) {
822        // Safety: drops once, never accessed again due to mem::forget
823        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
824        // Prevent Drop from running (which would shut down the channel)
825        std::mem::forget(self);
826    }
827}
828
829impl RebindParentRemoveChildResponder {
830    /// Sends a response to the FIDL transaction.
831    ///
832    /// Sets the channel to shutdown if an error occurs.
833    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
834        let _result = self.send_raw(result);
835        if _result.is_err() {
836            self.control_handle.shutdown();
837        }
838        self.drop_without_shutdown();
839        _result
840    }
841
842    /// Similar to "send" but does not shutdown the channel if an error occurs.
843    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
844        let _result = self.send_raw(result);
845        self.drop_without_shutdown();
846        _result
847    }
848
849    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
850        self.control_handle
851            .inner
852            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
853                result,
854                self.tx_id,
855                0x68d3023bfd04c269,
856                fidl::encoding::DynamicFlags::empty(),
857            )
858    }
859}
860
861mod internal {
862    use super::*;
863}