Skip to main content

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