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