fidl_fuchsia_nodegroup_test/
fidl_fuchsia_nodegroup_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 _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
14#[repr(C)]
15pub struct DeviceGetNumberResponse {
16    pub number: u32,
17}
18
19impl fidl::Persistable for DeviceGetNumberResponse {}
20
21#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
22#[repr(C)]
23pub struct WaiterAckRequest {
24    pub status: i32,
25}
26
27impl fidl::Persistable for WaiterAckRequest {}
28
29#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
30pub struct DeviceMarker;
31
32impl fidl::endpoints::ProtocolMarker for DeviceMarker {
33    type Proxy = DeviceProxy;
34    type RequestStream = DeviceRequestStream;
35    #[cfg(target_os = "fuchsia")]
36    type SynchronousProxy = DeviceSynchronousProxy;
37
38    const DEBUG_NAME: &'static str = "(anonymous) Device";
39}
40
41pub trait DeviceProxyInterface: Send + Sync {
42    type GetNumberResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
43    fn r#get_number(&self) -> Self::GetNumberResponseFut;
44}
45#[derive(Debug)]
46#[cfg(target_os = "fuchsia")]
47pub struct DeviceSynchronousProxy {
48    client: fidl::client::sync::Client,
49}
50
51#[cfg(target_os = "fuchsia")]
52impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
53    type Proxy = DeviceProxy;
54    type Protocol = DeviceMarker;
55
56    fn from_channel(inner: fidl::Channel) -> Self {
57        Self::new(inner)
58    }
59
60    fn into_channel(self) -> fidl::Channel {
61        self.client.into_channel()
62    }
63
64    fn as_channel(&self) -> &fidl::Channel {
65        self.client.as_channel()
66    }
67}
68
69#[cfg(target_os = "fuchsia")]
70impl DeviceSynchronousProxy {
71    pub fn new(channel: fidl::Channel) -> Self {
72        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
73        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
74    }
75
76    pub fn into_channel(self) -> fidl::Channel {
77        self.client.into_channel()
78    }
79
80    /// Waits until an event arrives and returns it. It is safe for other
81    /// threads to make concurrent requests while waiting for an event.
82    pub fn wait_for_event(
83        &self,
84        deadline: zx::MonotonicInstant,
85    ) -> Result<DeviceEvent, fidl::Error> {
86        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
87    }
88
89    pub fn r#get_number(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
90        let _response =
91            self.client.send_query::<fidl::encoding::EmptyPayload, DeviceGetNumberResponse>(
92                (),
93                0x6af95f9d3bd37367,
94                fidl::encoding::DynamicFlags::empty(),
95                ___deadline,
96            )?;
97        Ok(_response.number)
98    }
99}
100
101#[derive(Debug, Clone)]
102pub struct DeviceProxy {
103    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
104}
105
106impl fidl::endpoints::Proxy for DeviceProxy {
107    type Protocol = DeviceMarker;
108
109    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
110        Self::new(inner)
111    }
112
113    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
114        self.client.into_channel().map_err(|client| Self { client })
115    }
116
117    fn as_channel(&self) -> &::fidl::AsyncChannel {
118        self.client.as_channel()
119    }
120}
121
122impl DeviceProxy {
123    /// Create a new Proxy for fuchsia.nodegroup.test/Device.
124    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
125        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
126        Self { client: fidl::client::Client::new(channel, protocol_name) }
127    }
128
129    /// Get a Stream of events from the remote end of the protocol.
130    ///
131    /// # Panics
132    ///
133    /// Panics if the event stream was already taken.
134    pub fn take_event_stream(&self) -> DeviceEventStream {
135        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
136    }
137
138    pub fn r#get_number(
139        &self,
140    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
141        DeviceProxyInterface::r#get_number(self)
142    }
143}
144
145impl DeviceProxyInterface for DeviceProxy {
146    type GetNumberResponseFut =
147        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
148    fn r#get_number(&self) -> Self::GetNumberResponseFut {
149        fn _decode(
150            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
151        ) -> Result<u32, fidl::Error> {
152            let _response = fidl::client::decode_transaction_body::<
153                DeviceGetNumberResponse,
154                fidl::encoding::DefaultFuchsiaResourceDialect,
155                0x6af95f9d3bd37367,
156            >(_buf?)?;
157            Ok(_response.number)
158        }
159        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
160            (),
161            0x6af95f9d3bd37367,
162            fidl::encoding::DynamicFlags::empty(),
163            _decode,
164        )
165    }
166}
167
168pub struct DeviceEventStream {
169    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
170}
171
172impl std::marker::Unpin for DeviceEventStream {}
173
174impl futures::stream::FusedStream for DeviceEventStream {
175    fn is_terminated(&self) -> bool {
176        self.event_receiver.is_terminated()
177    }
178}
179
180impl futures::Stream for DeviceEventStream {
181    type Item = Result<DeviceEvent, fidl::Error>;
182
183    fn poll_next(
184        mut self: std::pin::Pin<&mut Self>,
185        cx: &mut std::task::Context<'_>,
186    ) -> std::task::Poll<Option<Self::Item>> {
187        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
188            &mut self.event_receiver,
189            cx
190        )?) {
191            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
192            None => std::task::Poll::Ready(None),
193        }
194    }
195}
196
197#[derive(Debug)]
198pub enum DeviceEvent {}
199
200impl DeviceEvent {
201    /// Decodes a message buffer as a [`DeviceEvent`].
202    fn decode(
203        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
204    ) -> Result<DeviceEvent, fidl::Error> {
205        let (bytes, _handles) = buf.split_mut();
206        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
207        debug_assert_eq!(tx_header.tx_id, 0);
208        match tx_header.ordinal {
209            _ => Err(fidl::Error::UnknownOrdinal {
210                ordinal: tx_header.ordinal,
211                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
212            }),
213        }
214    }
215}
216
217/// A Stream of incoming requests for fuchsia.nodegroup.test/Device.
218pub struct DeviceRequestStream {
219    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
220    is_terminated: bool,
221}
222
223impl std::marker::Unpin for DeviceRequestStream {}
224
225impl futures::stream::FusedStream for DeviceRequestStream {
226    fn is_terminated(&self) -> bool {
227        self.is_terminated
228    }
229}
230
231impl fidl::endpoints::RequestStream for DeviceRequestStream {
232    type Protocol = DeviceMarker;
233    type ControlHandle = DeviceControlHandle;
234
235    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
236        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
237    }
238
239    fn control_handle(&self) -> Self::ControlHandle {
240        DeviceControlHandle { inner: self.inner.clone() }
241    }
242
243    fn into_inner(
244        self,
245    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
246    {
247        (self.inner, self.is_terminated)
248    }
249
250    fn from_inner(
251        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
252        is_terminated: bool,
253    ) -> Self {
254        Self { inner, is_terminated }
255    }
256}
257
258impl futures::Stream for DeviceRequestStream {
259    type Item = Result<DeviceRequest, fidl::Error>;
260
261    fn poll_next(
262        mut self: std::pin::Pin<&mut Self>,
263        cx: &mut std::task::Context<'_>,
264    ) -> std::task::Poll<Option<Self::Item>> {
265        let this = &mut *self;
266        if this.inner.check_shutdown(cx) {
267            this.is_terminated = true;
268            return std::task::Poll::Ready(None);
269        }
270        if this.is_terminated {
271            panic!("polled DeviceRequestStream after completion");
272        }
273        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
274            |bytes, handles| {
275                match this.inner.channel().read_etc(cx, bytes, handles) {
276                    std::task::Poll::Ready(Ok(())) => {}
277                    std::task::Poll::Pending => return std::task::Poll::Pending,
278                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
279                        this.is_terminated = true;
280                        return std::task::Poll::Ready(None);
281                    }
282                    std::task::Poll::Ready(Err(e)) => {
283                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
284                            e.into(),
285                        ))))
286                    }
287                }
288
289                // A message has been received from the channel
290                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
291
292                std::task::Poll::Ready(Some(match header.ordinal {
293                    0x6af95f9d3bd37367 => {
294                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
295                        let mut req = fidl::new_empty!(
296                            fidl::encoding::EmptyPayload,
297                            fidl::encoding::DefaultFuchsiaResourceDialect
298                        );
299                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
300                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
301                        Ok(DeviceRequest::GetNumber {
302                            responder: DeviceGetNumberResponder {
303                                control_handle: std::mem::ManuallyDrop::new(control_handle),
304                                tx_id: header.tx_id,
305                            },
306                        })
307                    }
308                    _ => Err(fidl::Error::UnknownOrdinal {
309                        ordinal: header.ordinal,
310                        protocol_name:
311                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
312                    }),
313                }))
314            },
315        )
316    }
317}
318
319#[derive(Debug)]
320pub enum DeviceRequest {
321    GetNumber { responder: DeviceGetNumberResponder },
322}
323
324impl DeviceRequest {
325    #[allow(irrefutable_let_patterns)]
326    pub fn into_get_number(self) -> Option<(DeviceGetNumberResponder)> {
327        if let DeviceRequest::GetNumber { responder } = self {
328            Some((responder))
329        } else {
330            None
331        }
332    }
333
334    /// Name of the method defined in FIDL
335    pub fn method_name(&self) -> &'static str {
336        match *self {
337            DeviceRequest::GetNumber { .. } => "get_number",
338        }
339    }
340}
341
342#[derive(Debug, Clone)]
343pub struct DeviceControlHandle {
344    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
345}
346
347impl fidl::endpoints::ControlHandle for DeviceControlHandle {
348    fn shutdown(&self) {
349        self.inner.shutdown()
350    }
351    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
352        self.inner.shutdown_with_epitaph(status)
353    }
354
355    fn is_closed(&self) -> bool {
356        self.inner.channel().is_closed()
357    }
358    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
359        self.inner.channel().on_closed()
360    }
361
362    #[cfg(target_os = "fuchsia")]
363    fn signal_peer(
364        &self,
365        clear_mask: zx::Signals,
366        set_mask: zx::Signals,
367    ) -> Result<(), zx_status::Status> {
368        use fidl::Peered;
369        self.inner.channel().signal_peer(clear_mask, set_mask)
370    }
371}
372
373impl DeviceControlHandle {}
374
375#[must_use = "FIDL methods require a response to be sent"]
376#[derive(Debug)]
377pub struct DeviceGetNumberResponder {
378    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
379    tx_id: u32,
380}
381
382/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
383/// if the responder is dropped without sending a response, so that the client
384/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
385impl std::ops::Drop for DeviceGetNumberResponder {
386    fn drop(&mut self) {
387        self.control_handle.shutdown();
388        // Safety: drops once, never accessed again
389        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
390    }
391}
392
393impl fidl::endpoints::Responder for DeviceGetNumberResponder {
394    type ControlHandle = DeviceControlHandle;
395
396    fn control_handle(&self) -> &DeviceControlHandle {
397        &self.control_handle
398    }
399
400    fn drop_without_shutdown(mut self) {
401        // Safety: drops once, never accessed again due to mem::forget
402        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
403        // Prevent Drop from running (which would shut down the channel)
404        std::mem::forget(self);
405    }
406}
407
408impl DeviceGetNumberResponder {
409    /// Sends a response to the FIDL transaction.
410    ///
411    /// Sets the channel to shutdown if an error occurs.
412    pub fn send(self, mut number: u32) -> Result<(), fidl::Error> {
413        let _result = self.send_raw(number);
414        if _result.is_err() {
415            self.control_handle.shutdown();
416        }
417        self.drop_without_shutdown();
418        _result
419    }
420
421    /// Similar to "send" but does not shutdown the channel if an error occurs.
422    pub fn send_no_shutdown_on_err(self, mut number: u32) -> Result<(), fidl::Error> {
423        let _result = self.send_raw(number);
424        self.drop_without_shutdown();
425        _result
426    }
427
428    fn send_raw(&self, mut number: u32) -> Result<(), fidl::Error> {
429        self.control_handle.inner.send::<DeviceGetNumberResponse>(
430            (number,),
431            self.tx_id,
432            0x6af95f9d3bd37367,
433            fidl::encoding::DynamicFlags::empty(),
434        )
435    }
436}
437
438#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
439pub struct WaiterMarker;
440
441impl fidl::endpoints::ProtocolMarker for WaiterMarker {
442    type Proxy = WaiterProxy;
443    type RequestStream = WaiterRequestStream;
444    #[cfg(target_os = "fuchsia")]
445    type SynchronousProxy = WaiterSynchronousProxy;
446
447    const DEBUG_NAME: &'static str = "fuchsia.nodegroup.test.Waiter";
448}
449impl fidl::endpoints::DiscoverableProtocolMarker for WaiterMarker {}
450
451pub trait WaiterProxyInterface: Send + Sync {
452    fn r#ack(&self, status: i32) -> Result<(), fidl::Error>;
453}
454#[derive(Debug)]
455#[cfg(target_os = "fuchsia")]
456pub struct WaiterSynchronousProxy {
457    client: fidl::client::sync::Client,
458}
459
460#[cfg(target_os = "fuchsia")]
461impl fidl::endpoints::SynchronousProxy for WaiterSynchronousProxy {
462    type Proxy = WaiterProxy;
463    type Protocol = WaiterMarker;
464
465    fn from_channel(inner: fidl::Channel) -> Self {
466        Self::new(inner)
467    }
468
469    fn into_channel(self) -> fidl::Channel {
470        self.client.into_channel()
471    }
472
473    fn as_channel(&self) -> &fidl::Channel {
474        self.client.as_channel()
475    }
476}
477
478#[cfg(target_os = "fuchsia")]
479impl WaiterSynchronousProxy {
480    pub fn new(channel: fidl::Channel) -> Self {
481        let protocol_name = <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
482        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
483    }
484
485    pub fn into_channel(self) -> fidl::Channel {
486        self.client.into_channel()
487    }
488
489    /// Waits until an event arrives and returns it. It is safe for other
490    /// threads to make concurrent requests while waiting for an event.
491    pub fn wait_for_event(
492        &self,
493        deadline: zx::MonotonicInstant,
494    ) -> Result<WaiterEvent, fidl::Error> {
495        WaiterEvent::decode(self.client.wait_for_event(deadline)?)
496    }
497
498    pub fn r#ack(&self, mut status: i32) -> Result<(), fidl::Error> {
499        self.client.send::<WaiterAckRequest>(
500            (status,),
501            0x13b7e3e83c507878,
502            fidl::encoding::DynamicFlags::empty(),
503        )
504    }
505}
506
507#[derive(Debug, Clone)]
508pub struct WaiterProxy {
509    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
510}
511
512impl fidl::endpoints::Proxy for WaiterProxy {
513    type Protocol = WaiterMarker;
514
515    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
516        Self::new(inner)
517    }
518
519    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
520        self.client.into_channel().map_err(|client| Self { client })
521    }
522
523    fn as_channel(&self) -> &::fidl::AsyncChannel {
524        self.client.as_channel()
525    }
526}
527
528impl WaiterProxy {
529    /// Create a new Proxy for fuchsia.nodegroup.test/Waiter.
530    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
531        let protocol_name = <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
532        Self { client: fidl::client::Client::new(channel, protocol_name) }
533    }
534
535    /// Get a Stream of events from the remote end of the protocol.
536    ///
537    /// # Panics
538    ///
539    /// Panics if the event stream was already taken.
540    pub fn take_event_stream(&self) -> WaiterEventStream {
541        WaiterEventStream { event_receiver: self.client.take_event_receiver() }
542    }
543
544    pub fn r#ack(&self, mut status: i32) -> Result<(), fidl::Error> {
545        WaiterProxyInterface::r#ack(self, status)
546    }
547}
548
549impl WaiterProxyInterface for WaiterProxy {
550    fn r#ack(&self, mut status: i32) -> Result<(), fidl::Error> {
551        self.client.send::<WaiterAckRequest>(
552            (status,),
553            0x13b7e3e83c507878,
554            fidl::encoding::DynamicFlags::empty(),
555        )
556    }
557}
558
559pub struct WaiterEventStream {
560    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
561}
562
563impl std::marker::Unpin for WaiterEventStream {}
564
565impl futures::stream::FusedStream for WaiterEventStream {
566    fn is_terminated(&self) -> bool {
567        self.event_receiver.is_terminated()
568    }
569}
570
571impl futures::Stream for WaiterEventStream {
572    type Item = Result<WaiterEvent, fidl::Error>;
573
574    fn poll_next(
575        mut self: std::pin::Pin<&mut Self>,
576        cx: &mut std::task::Context<'_>,
577    ) -> std::task::Poll<Option<Self::Item>> {
578        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
579            &mut self.event_receiver,
580            cx
581        )?) {
582            Some(buf) => std::task::Poll::Ready(Some(WaiterEvent::decode(buf))),
583            None => std::task::Poll::Ready(None),
584        }
585    }
586}
587
588#[derive(Debug)]
589pub enum WaiterEvent {}
590
591impl WaiterEvent {
592    /// Decodes a message buffer as a [`WaiterEvent`].
593    fn decode(
594        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
595    ) -> Result<WaiterEvent, fidl::Error> {
596        let (bytes, _handles) = buf.split_mut();
597        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
598        debug_assert_eq!(tx_header.tx_id, 0);
599        match tx_header.ordinal {
600            _ => Err(fidl::Error::UnknownOrdinal {
601                ordinal: tx_header.ordinal,
602                protocol_name: <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
603            }),
604        }
605    }
606}
607
608/// A Stream of incoming requests for fuchsia.nodegroup.test/Waiter.
609pub struct WaiterRequestStream {
610    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
611    is_terminated: bool,
612}
613
614impl std::marker::Unpin for WaiterRequestStream {}
615
616impl futures::stream::FusedStream for WaiterRequestStream {
617    fn is_terminated(&self) -> bool {
618        self.is_terminated
619    }
620}
621
622impl fidl::endpoints::RequestStream for WaiterRequestStream {
623    type Protocol = WaiterMarker;
624    type ControlHandle = WaiterControlHandle;
625
626    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
627        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
628    }
629
630    fn control_handle(&self) -> Self::ControlHandle {
631        WaiterControlHandle { inner: self.inner.clone() }
632    }
633
634    fn into_inner(
635        self,
636    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
637    {
638        (self.inner, self.is_terminated)
639    }
640
641    fn from_inner(
642        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
643        is_terminated: bool,
644    ) -> Self {
645        Self { inner, is_terminated }
646    }
647}
648
649impl futures::Stream for WaiterRequestStream {
650    type Item = Result<WaiterRequest, fidl::Error>;
651
652    fn poll_next(
653        mut self: std::pin::Pin<&mut Self>,
654        cx: &mut std::task::Context<'_>,
655    ) -> std::task::Poll<Option<Self::Item>> {
656        let this = &mut *self;
657        if this.inner.check_shutdown(cx) {
658            this.is_terminated = true;
659            return std::task::Poll::Ready(None);
660        }
661        if this.is_terminated {
662            panic!("polled WaiterRequestStream after completion");
663        }
664        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
665            |bytes, handles| {
666                match this.inner.channel().read_etc(cx, bytes, handles) {
667                    std::task::Poll::Ready(Ok(())) => {}
668                    std::task::Poll::Pending => return std::task::Poll::Pending,
669                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
670                        this.is_terminated = true;
671                        return std::task::Poll::Ready(None);
672                    }
673                    std::task::Poll::Ready(Err(e)) => {
674                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
675                            e.into(),
676                        ))))
677                    }
678                }
679
680                // A message has been received from the channel
681                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
682
683                std::task::Poll::Ready(Some(match header.ordinal {
684                    0x13b7e3e83c507878 => {
685                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
686                        let mut req = fidl::new_empty!(
687                            WaiterAckRequest,
688                            fidl::encoding::DefaultFuchsiaResourceDialect
689                        );
690                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WaiterAckRequest>(&header, _body_bytes, handles, &mut req)?;
691                        let control_handle = WaiterControlHandle { inner: this.inner.clone() };
692                        Ok(WaiterRequest::Ack { status: req.status, control_handle })
693                    }
694                    _ => Err(fidl::Error::UnknownOrdinal {
695                        ordinal: header.ordinal,
696                        protocol_name:
697                            <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
698                    }),
699                }))
700            },
701        )
702    }
703}
704
705#[derive(Debug)]
706pub enum WaiterRequest {
707    Ack { status: i32, control_handle: WaiterControlHandle },
708}
709
710impl WaiterRequest {
711    #[allow(irrefutable_let_patterns)]
712    pub fn into_ack(self) -> Option<(i32, WaiterControlHandle)> {
713        if let WaiterRequest::Ack { status, control_handle } = self {
714            Some((status, control_handle))
715        } else {
716            None
717        }
718    }
719
720    /// Name of the method defined in FIDL
721    pub fn method_name(&self) -> &'static str {
722        match *self {
723            WaiterRequest::Ack { .. } => "ack",
724        }
725    }
726}
727
728#[derive(Debug, Clone)]
729pub struct WaiterControlHandle {
730    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
731}
732
733impl fidl::endpoints::ControlHandle for WaiterControlHandle {
734    fn shutdown(&self) {
735        self.inner.shutdown()
736    }
737    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
738        self.inner.shutdown_with_epitaph(status)
739    }
740
741    fn is_closed(&self) -> bool {
742        self.inner.channel().is_closed()
743    }
744    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
745        self.inner.channel().on_closed()
746    }
747
748    #[cfg(target_os = "fuchsia")]
749    fn signal_peer(
750        &self,
751        clear_mask: zx::Signals,
752        set_mask: zx::Signals,
753    ) -> Result<(), zx_status::Status> {
754        use fidl::Peered;
755        self.inner.channel().signal_peer(clear_mask, set_mask)
756    }
757}
758
759impl WaiterControlHandle {}
760
761#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
762pub struct ServiceMarker;
763
764#[cfg(target_os = "fuchsia")]
765impl fidl::endpoints::ServiceMarker for ServiceMarker {
766    type Proxy = ServiceProxy;
767    type Request = ServiceRequest;
768    const SERVICE_NAME: &'static str = "fuchsia.nodegroup.test.Service";
769}
770
771/// A request for one of the member protocols of Service.
772///
773#[cfg(target_os = "fuchsia")]
774pub enum ServiceRequest {
775    Device(DeviceRequestStream),
776}
777
778#[cfg(target_os = "fuchsia")]
779impl fidl::endpoints::ServiceRequest for ServiceRequest {
780    type Service = ServiceMarker;
781
782    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
783        match name {
784            "device" => Self::Device(
785                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
786            ),
787            _ => panic!("no such member protocol name for service Service"),
788        }
789    }
790
791    fn member_names() -> &'static [&'static str] {
792        &["device"]
793    }
794}
795#[cfg(target_os = "fuchsia")]
796pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
797
798#[cfg(target_os = "fuchsia")]
799impl fidl::endpoints::ServiceProxy for ServiceProxy {
800    type Service = ServiceMarker;
801
802    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
803        Self(opener)
804    }
805}
806
807#[cfg(target_os = "fuchsia")]
808impl ServiceProxy {
809    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
810        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
811        self.connect_channel_to_device(server_end)?;
812        Ok(proxy)
813    }
814
815    /// Like `connect_to_device`, but returns a sync proxy.
816    /// See [`Self::connect_to_device`] for more details.
817    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
818        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
819        self.connect_channel_to_device(server_end)?;
820        Ok(proxy)
821    }
822
823    /// Like `connect_to_device`, but accepts a server end.
824    /// See [`Self::connect_to_device`] for more details.
825    pub fn connect_channel_to_device(
826        &self,
827        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
828    ) -> Result<(), fidl::Error> {
829        self.0.open_member("device", server_end.into_channel())
830    }
831
832    pub fn instance_name(&self) -> &str {
833        self.0.instance_name()
834    }
835}
836
837mod internal {
838    use super::*;
839
840    impl fidl::encoding::ValueTypeMarker for DeviceGetNumberResponse {
841        type Borrowed<'a> = &'a Self;
842        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
843            value
844        }
845    }
846
847    unsafe impl fidl::encoding::TypeMarker for DeviceGetNumberResponse {
848        type Owned = Self;
849
850        #[inline(always)]
851        fn inline_align(_context: fidl::encoding::Context) -> usize {
852            4
853        }
854
855        #[inline(always)]
856        fn inline_size(_context: fidl::encoding::Context) -> usize {
857            4
858        }
859        #[inline(always)]
860        fn encode_is_copy() -> bool {
861            true
862        }
863
864        #[inline(always)]
865        fn decode_is_copy() -> bool {
866            true
867        }
868    }
869
870    unsafe impl<D: fidl::encoding::ResourceDialect>
871        fidl::encoding::Encode<DeviceGetNumberResponse, D> for &DeviceGetNumberResponse
872    {
873        #[inline]
874        unsafe fn encode(
875            self,
876            encoder: &mut fidl::encoding::Encoder<'_, D>,
877            offset: usize,
878            _depth: fidl::encoding::Depth,
879        ) -> fidl::Result<()> {
880            encoder.debug_check_bounds::<DeviceGetNumberResponse>(offset);
881            unsafe {
882                // Copy the object into the buffer.
883                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
884                (buf_ptr as *mut DeviceGetNumberResponse)
885                    .write_unaligned((self as *const DeviceGetNumberResponse).read());
886                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
887                // done second because the memcpy will write garbage to these bytes.
888            }
889            Ok(())
890        }
891    }
892    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
893        fidl::encoding::Encode<DeviceGetNumberResponse, D> for (T0,)
894    {
895        #[inline]
896        unsafe fn encode(
897            self,
898            encoder: &mut fidl::encoding::Encoder<'_, D>,
899            offset: usize,
900            depth: fidl::encoding::Depth,
901        ) -> fidl::Result<()> {
902            encoder.debug_check_bounds::<DeviceGetNumberResponse>(offset);
903            // Zero out padding regions. There's no need to apply masks
904            // because the unmasked parts will be overwritten by fields.
905            // Write the fields.
906            self.0.encode(encoder, offset + 0, depth)?;
907            Ok(())
908        }
909    }
910
911    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
912        for DeviceGetNumberResponse
913    {
914        #[inline(always)]
915        fn new_empty() -> Self {
916            Self { number: fidl::new_empty!(u32, D) }
917        }
918
919        #[inline]
920        unsafe fn decode(
921            &mut self,
922            decoder: &mut fidl::encoding::Decoder<'_, D>,
923            offset: usize,
924            _depth: fidl::encoding::Depth,
925        ) -> fidl::Result<()> {
926            decoder.debug_check_bounds::<Self>(offset);
927            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
928            // Verify that padding bytes are zero.
929            // Copy from the buffer into the object.
930            unsafe {
931                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
932            }
933            Ok(())
934        }
935    }
936
937    impl fidl::encoding::ValueTypeMarker for WaiterAckRequest {
938        type Borrowed<'a> = &'a Self;
939        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
940            value
941        }
942    }
943
944    unsafe impl fidl::encoding::TypeMarker for WaiterAckRequest {
945        type Owned = Self;
946
947        #[inline(always)]
948        fn inline_align(_context: fidl::encoding::Context) -> usize {
949            4
950        }
951
952        #[inline(always)]
953        fn inline_size(_context: fidl::encoding::Context) -> usize {
954            4
955        }
956        #[inline(always)]
957        fn encode_is_copy() -> bool {
958            true
959        }
960
961        #[inline(always)]
962        fn decode_is_copy() -> bool {
963            true
964        }
965    }
966
967    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<WaiterAckRequest, D>
968        for &WaiterAckRequest
969    {
970        #[inline]
971        unsafe fn encode(
972            self,
973            encoder: &mut fidl::encoding::Encoder<'_, D>,
974            offset: usize,
975            _depth: fidl::encoding::Depth,
976        ) -> fidl::Result<()> {
977            encoder.debug_check_bounds::<WaiterAckRequest>(offset);
978            unsafe {
979                // Copy the object into the buffer.
980                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
981                (buf_ptr as *mut WaiterAckRequest)
982                    .write_unaligned((self as *const WaiterAckRequest).read());
983                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
984                // done second because the memcpy will write garbage to these bytes.
985            }
986            Ok(())
987        }
988    }
989    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
990        fidl::encoding::Encode<WaiterAckRequest, D> for (T0,)
991    {
992        #[inline]
993        unsafe fn encode(
994            self,
995            encoder: &mut fidl::encoding::Encoder<'_, D>,
996            offset: usize,
997            depth: fidl::encoding::Depth,
998        ) -> fidl::Result<()> {
999            encoder.debug_check_bounds::<WaiterAckRequest>(offset);
1000            // Zero out padding regions. There's no need to apply masks
1001            // because the unmasked parts will be overwritten by fields.
1002            // Write the fields.
1003            self.0.encode(encoder, offset + 0, depth)?;
1004            Ok(())
1005        }
1006    }
1007
1008    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WaiterAckRequest {
1009        #[inline(always)]
1010        fn new_empty() -> Self {
1011            Self { status: fidl::new_empty!(i32, D) }
1012        }
1013
1014        #[inline]
1015        unsafe fn decode(
1016            &mut self,
1017            decoder: &mut fidl::encoding::Decoder<'_, D>,
1018            offset: usize,
1019            _depth: fidl::encoding::Depth,
1020        ) -> fidl::Result<()> {
1021            decoder.debug_check_bounds::<Self>(offset);
1022            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1023            // Verify that padding bytes are zero.
1024            // Copy from the buffer into the object.
1025            unsafe {
1026                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1027            }
1028            Ok(())
1029        }
1030    }
1031}