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