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        let protocol_name = <LeafMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
58        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
59    }
60
61    pub fn into_channel(self) -> fidl::Channel {
62        self.client.into_channel()
63    }
64
65    /// Waits until an event arrives and returns it. It is safe for other
66    /// threads to make concurrent requests while waiting for an event.
67    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<LeafEvent, fidl::Error> {
68        LeafEvent::decode(self.client.wait_for_event(deadline)?)
69    }
70
71    pub fn r#get_string(&self, ___deadline: zx::MonotonicInstant) -> Result<String, fidl::Error> {
72        let _response =
73            self.client.send_query::<fidl::encoding::EmptyPayload, LeafGetStringResponse>(
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::Handle {
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 {
332            Some((responder))
333        } else {
334            None
335        }
336    }
337
338    /// Name of the method defined in FIDL
339    pub fn method_name(&self) -> &'static str {
340        match *self {
341            LeafRequest::GetString { .. } => "get_string",
342        }
343    }
344}
345
346#[derive(Debug, Clone)]
347pub struct LeafControlHandle {
348    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
349}
350
351impl fidl::endpoints::ControlHandle for LeafControlHandle {
352    fn shutdown(&self) {
353        self.inner.shutdown()
354    }
355    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
356        self.inner.shutdown_with_epitaph(status)
357    }
358
359    fn is_closed(&self) -> bool {
360        self.inner.channel().is_closed()
361    }
362    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
363        self.inner.channel().on_closed()
364    }
365
366    #[cfg(target_os = "fuchsia")]
367    fn signal_peer(
368        &self,
369        clear_mask: zx::Signals,
370        set_mask: zx::Signals,
371    ) -> Result<(), zx_status::Status> {
372        use fidl::Peered;
373        self.inner.channel().signal_peer(clear_mask, set_mask)
374    }
375}
376
377impl LeafControlHandle {}
378
379#[must_use = "FIDL methods require a response to be sent"]
380#[derive(Debug)]
381pub struct LeafGetStringResponder {
382    control_handle: std::mem::ManuallyDrop<LeafControlHandle>,
383    tx_id: u32,
384}
385
386/// Set the the channel to be shutdown (see [`LeafControlHandle::shutdown`])
387/// if the responder is dropped without sending a response, so that the client
388/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
389impl std::ops::Drop for LeafGetStringResponder {
390    fn drop(&mut self) {
391        self.control_handle.shutdown();
392        // Safety: drops once, never accessed again
393        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
394    }
395}
396
397impl fidl::endpoints::Responder for LeafGetStringResponder {
398    type ControlHandle = LeafControlHandle;
399
400    fn control_handle(&self) -> &LeafControlHandle {
401        &self.control_handle
402    }
403
404    fn drop_without_shutdown(mut self) {
405        // Safety: drops once, never accessed again due to mem::forget
406        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
407        // Prevent Drop from running (which would shut down the channel)
408        std::mem::forget(self);
409    }
410}
411
412impl LeafGetStringResponder {
413    /// Sends a response to the FIDL transaction.
414    ///
415    /// Sets the channel to shutdown if an error occurs.
416    pub fn send(self, mut response: &str) -> Result<(), fidl::Error> {
417        let _result = self.send_raw(response);
418        if _result.is_err() {
419            self.control_handle.shutdown();
420        }
421        self.drop_without_shutdown();
422        _result
423    }
424
425    /// Similar to "send" but does not shutdown the channel if an error occurs.
426    pub fn send_no_shutdown_on_err(self, mut response: &str) -> Result<(), fidl::Error> {
427        let _result = self.send_raw(response);
428        self.drop_without_shutdown();
429        _result
430    }
431
432    fn send_raw(&self, mut response: &str) -> Result<(), fidl::Error> {
433        self.control_handle.inner.send::<LeafGetStringResponse>(
434            (response,),
435            self.tx_id,
436            0x765999b3a5e5cbcc,
437            fidl::encoding::DynamicFlags::empty(),
438        )
439    }
440}
441
442#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
443pub struct WaiterMarker;
444
445impl fidl::endpoints::ProtocolMarker for WaiterMarker {
446    type Proxy = WaiterProxy;
447    type RequestStream = WaiterRequestStream;
448    #[cfg(target_os = "fuchsia")]
449    type SynchronousProxy = WaiterSynchronousProxy;
450
451    const DEBUG_NAME: &'static str = "fuchsia.compat.runtime.test.Waiter";
452}
453impl fidl::endpoints::DiscoverableProtocolMarker for WaiterMarker {}
454
455pub trait WaiterProxyInterface: Send + Sync {
456    fn r#ack(&self) -> Result<(), fidl::Error>;
457}
458#[derive(Debug)]
459#[cfg(target_os = "fuchsia")]
460pub struct WaiterSynchronousProxy {
461    client: fidl::client::sync::Client,
462}
463
464#[cfg(target_os = "fuchsia")]
465impl fidl::endpoints::SynchronousProxy for WaiterSynchronousProxy {
466    type Proxy = WaiterProxy;
467    type Protocol = WaiterMarker;
468
469    fn from_channel(inner: fidl::Channel) -> Self {
470        Self::new(inner)
471    }
472
473    fn into_channel(self) -> fidl::Channel {
474        self.client.into_channel()
475    }
476
477    fn as_channel(&self) -> &fidl::Channel {
478        self.client.as_channel()
479    }
480}
481
482#[cfg(target_os = "fuchsia")]
483impl WaiterSynchronousProxy {
484    pub fn new(channel: fidl::Channel) -> Self {
485        let protocol_name = <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
486        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
487    }
488
489    pub fn into_channel(self) -> fidl::Channel {
490        self.client.into_channel()
491    }
492
493    /// Waits until an event arrives and returns it. It is safe for other
494    /// threads to make concurrent requests while waiting for an event.
495    pub fn wait_for_event(
496        &self,
497        deadline: zx::MonotonicInstant,
498    ) -> Result<WaiterEvent, fidl::Error> {
499        WaiterEvent::decode(self.client.wait_for_event(deadline)?)
500    }
501
502    pub fn r#ack(&self) -> Result<(), fidl::Error> {
503        self.client.send::<fidl::encoding::EmptyPayload>(
504            (),
505            0x37380907dd9472fa,
506            fidl::encoding::DynamicFlags::empty(),
507        )
508    }
509}
510
511#[cfg(target_os = "fuchsia")]
512impl From<WaiterSynchronousProxy> for zx::Handle {
513    fn from(value: WaiterSynchronousProxy) -> Self {
514        value.into_channel().into()
515    }
516}
517
518#[cfg(target_os = "fuchsia")]
519impl From<fidl::Channel> for WaiterSynchronousProxy {
520    fn from(value: fidl::Channel) -> Self {
521        Self::new(value)
522    }
523}
524
525#[cfg(target_os = "fuchsia")]
526impl fidl::endpoints::FromClient for WaiterSynchronousProxy {
527    type Protocol = WaiterMarker;
528
529    fn from_client(value: fidl::endpoints::ClientEnd<WaiterMarker>) -> Self {
530        Self::new(value.into_channel())
531    }
532}
533
534#[derive(Debug, Clone)]
535pub struct WaiterProxy {
536    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
537}
538
539impl fidl::endpoints::Proxy for WaiterProxy {
540    type Protocol = WaiterMarker;
541
542    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
543        Self::new(inner)
544    }
545
546    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
547        self.client.into_channel().map_err(|client| Self { client })
548    }
549
550    fn as_channel(&self) -> &::fidl::AsyncChannel {
551        self.client.as_channel()
552    }
553}
554
555impl WaiterProxy {
556    /// Create a new Proxy for fuchsia.compat.runtime.test/Waiter.
557    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
558        let protocol_name = <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
559        Self { client: fidl::client::Client::new(channel, protocol_name) }
560    }
561
562    /// Get a Stream of events from the remote end of the protocol.
563    ///
564    /// # Panics
565    ///
566    /// Panics if the event stream was already taken.
567    pub fn take_event_stream(&self) -> WaiterEventStream {
568        WaiterEventStream { event_receiver: self.client.take_event_receiver() }
569    }
570
571    pub fn r#ack(&self) -> Result<(), fidl::Error> {
572        WaiterProxyInterface::r#ack(self)
573    }
574}
575
576impl WaiterProxyInterface for WaiterProxy {
577    fn r#ack(&self) -> Result<(), fidl::Error> {
578        self.client.send::<fidl::encoding::EmptyPayload>(
579            (),
580            0x37380907dd9472fa,
581            fidl::encoding::DynamicFlags::empty(),
582        )
583    }
584}
585
586pub struct WaiterEventStream {
587    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
588}
589
590impl std::marker::Unpin for WaiterEventStream {}
591
592impl futures::stream::FusedStream for WaiterEventStream {
593    fn is_terminated(&self) -> bool {
594        self.event_receiver.is_terminated()
595    }
596}
597
598impl futures::Stream for WaiterEventStream {
599    type Item = Result<WaiterEvent, fidl::Error>;
600
601    fn poll_next(
602        mut self: std::pin::Pin<&mut Self>,
603        cx: &mut std::task::Context<'_>,
604    ) -> std::task::Poll<Option<Self::Item>> {
605        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
606            &mut self.event_receiver,
607            cx
608        )?) {
609            Some(buf) => std::task::Poll::Ready(Some(WaiterEvent::decode(buf))),
610            None => std::task::Poll::Ready(None),
611        }
612    }
613}
614
615#[derive(Debug)]
616pub enum WaiterEvent {}
617
618impl WaiterEvent {
619    /// Decodes a message buffer as a [`WaiterEvent`].
620    fn decode(
621        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
622    ) -> Result<WaiterEvent, fidl::Error> {
623        let (bytes, _handles) = buf.split_mut();
624        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
625        debug_assert_eq!(tx_header.tx_id, 0);
626        match tx_header.ordinal {
627            _ => Err(fidl::Error::UnknownOrdinal {
628                ordinal: tx_header.ordinal,
629                protocol_name: <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
630            }),
631        }
632    }
633}
634
635/// A Stream of incoming requests for fuchsia.compat.runtime.test/Waiter.
636pub struct WaiterRequestStream {
637    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
638    is_terminated: bool,
639}
640
641impl std::marker::Unpin for WaiterRequestStream {}
642
643impl futures::stream::FusedStream for WaiterRequestStream {
644    fn is_terminated(&self) -> bool {
645        self.is_terminated
646    }
647}
648
649impl fidl::endpoints::RequestStream for WaiterRequestStream {
650    type Protocol = WaiterMarker;
651    type ControlHandle = WaiterControlHandle;
652
653    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
654        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
655    }
656
657    fn control_handle(&self) -> Self::ControlHandle {
658        WaiterControlHandle { inner: self.inner.clone() }
659    }
660
661    fn into_inner(
662        self,
663    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
664    {
665        (self.inner, self.is_terminated)
666    }
667
668    fn from_inner(
669        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
670        is_terminated: bool,
671    ) -> Self {
672        Self { inner, is_terminated }
673    }
674}
675
676impl futures::Stream for WaiterRequestStream {
677    type Item = Result<WaiterRequest, fidl::Error>;
678
679    fn poll_next(
680        mut self: std::pin::Pin<&mut Self>,
681        cx: &mut std::task::Context<'_>,
682    ) -> std::task::Poll<Option<Self::Item>> {
683        let this = &mut *self;
684        if this.inner.check_shutdown(cx) {
685            this.is_terminated = true;
686            return std::task::Poll::Ready(None);
687        }
688        if this.is_terminated {
689            panic!("polled WaiterRequestStream after completion");
690        }
691        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
692            |bytes, handles| {
693                match this.inner.channel().read_etc(cx, bytes, handles) {
694                    std::task::Poll::Ready(Ok(())) => {}
695                    std::task::Poll::Pending => return std::task::Poll::Pending,
696                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
697                        this.is_terminated = true;
698                        return std::task::Poll::Ready(None);
699                    }
700                    std::task::Poll::Ready(Err(e)) => {
701                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
702                            e.into(),
703                        ))))
704                    }
705                }
706
707                // A message has been received from the channel
708                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
709
710                std::task::Poll::Ready(Some(match header.ordinal {
711                    0x37380907dd9472fa => {
712                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
713                        let mut req = fidl::new_empty!(
714                            fidl::encoding::EmptyPayload,
715                            fidl::encoding::DefaultFuchsiaResourceDialect
716                        );
717                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
718                        let control_handle = WaiterControlHandle { inner: this.inner.clone() };
719                        Ok(WaiterRequest::Ack { control_handle })
720                    }
721                    _ => Err(fidl::Error::UnknownOrdinal {
722                        ordinal: header.ordinal,
723                        protocol_name:
724                            <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
725                    }),
726                }))
727            },
728        )
729    }
730}
731
732#[derive(Debug)]
733pub enum WaiterRequest {
734    Ack { control_handle: WaiterControlHandle },
735}
736
737impl WaiterRequest {
738    #[allow(irrefutable_let_patterns)]
739    pub fn into_ack(self) -> Option<(WaiterControlHandle)> {
740        if let WaiterRequest::Ack { control_handle } = self {
741            Some((control_handle))
742        } else {
743            None
744        }
745    }
746
747    /// Name of the method defined in FIDL
748    pub fn method_name(&self) -> &'static str {
749        match *self {
750            WaiterRequest::Ack { .. } => "ack",
751        }
752    }
753}
754
755#[derive(Debug, Clone)]
756pub struct WaiterControlHandle {
757    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
758}
759
760impl fidl::endpoints::ControlHandle for WaiterControlHandle {
761    fn shutdown(&self) {
762        self.inner.shutdown()
763    }
764    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
765        self.inner.shutdown_with_epitaph(status)
766    }
767
768    fn is_closed(&self) -> bool {
769        self.inner.channel().is_closed()
770    }
771    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
772        self.inner.channel().on_closed()
773    }
774
775    #[cfg(target_os = "fuchsia")]
776    fn signal_peer(
777        &self,
778        clear_mask: zx::Signals,
779        set_mask: zx::Signals,
780    ) -> Result<(), zx_status::Status> {
781        use fidl::Peered;
782        self.inner.channel().signal_peer(clear_mask, set_mask)
783    }
784}
785
786impl WaiterControlHandle {}
787
788mod internal {
789    use super::*;
790}