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