Skip to main content

fidl_fuchsia_hardware_google_nanohub/
fidl_fuchsia_hardware_google_nanohub.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_hardware_google_nanohub_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DataChannelRegisterRequest {
16    pub event: fidl::Event,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for DataChannelRegisterRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct DeviceDownloadFirmwareRequest {
26    pub firmware: fidl::Vmo,
27    pub offset: u64,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for DeviceDownloadFirmwareRequest
32{
33}
34
35#[derive(Debug, Default, PartialEq)]
36pub struct DataChannelReadResponse {
37    pub data: Option<Vec<u8>>,
38    pub wake_lease: Option<fidl::EventPair>,
39    #[doc(hidden)]
40    pub __source_breaking: fidl::marker::SourceBreaking,
41}
42
43impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DataChannelReadResponse {}
44
45#[derive(Debug, Default, PartialEq)]
46pub struct HangingDataChannelReadResponse {
47    pub data: Option<Vec<u8>>,
48    pub wake_lease: Option<fidl::EventPair>,
49    #[doc(hidden)]
50    pub __source_breaking: fidl::marker::SourceBreaking,
51}
52
53impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
54    for HangingDataChannelReadResponse
55{
56}
57
58#[derive(Debug, Default, PartialEq)]
59pub struct UnboundHangingDataChannelBindRequest {
60    pub server: Option<fidl::endpoints::ServerEnd<HangingDataChannelMarker>>,
61    #[doc(hidden)]
62    pub __source_breaking: fidl::marker::SourceBreaking,
63}
64
65impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
66    for UnboundHangingDataChannelBindRequest
67{
68}
69
70#[derive(Debug, Default, PartialEq)]
71pub struct UnboundWaitableDataChannelBindRequest {
72    pub event: Option<fidl::Event>,
73    pub server: Option<fidl::endpoints::ServerEnd<WaitableDataChannelMarker>>,
74    #[doc(hidden)]
75    pub __source_breaking: fidl::marker::SourceBreaking,
76}
77
78impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
79    for UnboundWaitableDataChannelBindRequest
80{
81}
82
83#[derive(Debug, Default, PartialEq)]
84pub struct WaitableDataChannelReadResponse {
85    pub data: Option<Vec<u8>>,
86    #[doc(hidden)]
87    pub __source_breaking: fidl::marker::SourceBreaking,
88}
89
90impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
91    for WaitableDataChannelReadResponse
92{
93}
94
95#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
96pub struct DataChannelMarker;
97
98impl fidl::endpoints::ProtocolMarker for DataChannelMarker {
99    type Proxy = DataChannelProxy;
100    type RequestStream = DataChannelRequestStream;
101    #[cfg(target_os = "fuchsia")]
102    type SynchronousProxy = DataChannelSynchronousProxy;
103
104    const DEBUG_NAME: &'static str = "(anonymous) DataChannel";
105}
106pub type DataChannelRegisterResult = Result<(), i32>;
107pub type DataChannelReadResult = Result<DataChannelReadResponse, i32>;
108pub type DataChannelWriteResult = Result<(), i32>;
109
110pub trait DataChannelProxyInterface: Send + Sync {
111    type RegisterResponseFut: std::future::Future<Output = Result<DataChannelRegisterResult, fidl::Error>>
112        + Send;
113    fn r#register(&self, event: fidl::Event) -> Self::RegisterResponseFut;
114    type GetIdentifierResponseFut: std::future::Future<Output = Result<DataChannelGetIdentifierResponse, fidl::Error>>
115        + Send;
116    fn r#get_identifier(&self) -> Self::GetIdentifierResponseFut;
117    type ReadResponseFut: std::future::Future<Output = Result<DataChannelReadResult, fidl::Error>>
118        + Send;
119    fn r#read(&self, payload: &DataChannelReadRequest) -> Self::ReadResponseFut;
120    type WriteResponseFut: std::future::Future<Output = Result<DataChannelWriteResult, fidl::Error>>
121        + Send;
122    fn r#write(&self, payload: &DataChannelWriteRequest) -> Self::WriteResponseFut;
123}
124#[derive(Debug)]
125#[cfg(target_os = "fuchsia")]
126pub struct DataChannelSynchronousProxy {
127    client: fidl::client::sync::Client,
128}
129
130#[cfg(target_os = "fuchsia")]
131impl fidl::endpoints::SynchronousProxy for DataChannelSynchronousProxy {
132    type Proxy = DataChannelProxy;
133    type Protocol = DataChannelMarker;
134
135    fn from_channel(inner: fidl::Channel) -> Self {
136        Self::new(inner)
137    }
138
139    fn into_channel(self) -> fidl::Channel {
140        self.client.into_channel()
141    }
142
143    fn as_channel(&self) -> &fidl::Channel {
144        self.client.as_channel()
145    }
146}
147
148#[cfg(target_os = "fuchsia")]
149impl DataChannelSynchronousProxy {
150    pub fn new(channel: fidl::Channel) -> Self {
151        Self { client: fidl::client::sync::Client::new(channel) }
152    }
153
154    pub fn into_channel(self) -> fidl::Channel {
155        self.client.into_channel()
156    }
157
158    /// Waits until an event arrives and returns it. It is safe for other
159    /// threads to make concurrent requests while waiting for an event.
160    pub fn wait_for_event(
161        &self,
162        deadline: zx::MonotonicInstant,
163    ) -> Result<DataChannelEvent, fidl::Error> {
164        DataChannelEvent::decode(self.client.wait_for_event::<DataChannelMarker>(deadline)?)
165    }
166
167    /// Set event used to signal device state. Discards existing event
168    /// after having transferred device state to the new event.
169    /// This must be called before invoking Read or Write, and can fail with
170    /// ZX_ERR_NO_RESOURCES if the underlying channel is busy.
171    pub fn r#register(
172        &self,
173        mut event: fidl::Event,
174        ___deadline: zx::MonotonicInstant,
175    ) -> Result<DataChannelRegisterResult, fidl::Error> {
176        let _response = self.client.send_query::<
177            DataChannelRegisterRequest,
178            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
179            DataChannelMarker,
180        >(
181            (event,),
182            0x1778251ad75157b6,
183            fidl::encoding::DynamicFlags::FLEXIBLE,
184            ___deadline,
185        )?
186        .into_result::<DataChannelMarker>("register")?;
187        Ok(_response.map(|x| x))
188    }
189
190    /// Returns the identifier associated with this connection.
191    pub fn r#get_identifier(
192        &self,
193        ___deadline: zx::MonotonicInstant,
194    ) -> Result<DataChannelGetIdentifierResponse, fidl::Error> {
195        let _response = self.client.send_query::<
196            fidl::encoding::EmptyPayload,
197            fidl::encoding::FlexibleType<DataChannelGetIdentifierResponse>,
198            DataChannelMarker,
199        >(
200            (),
201            0x4bf148d0ddbd4f69,
202            fidl::encoding::DynamicFlags::FLEXIBLE,
203            ___deadline,
204        )?
205        .into_result::<DataChannelMarker>("get_identifier")?;
206        Ok(_response)
207    }
208
209    /// The call will return the next datagram to be read from the channel.
210    /// If there is more data to be read, SIGNAL_READABLE will remain asserted
211    /// after this call returns.
212    pub fn r#read(
213        &self,
214        mut payload: &DataChannelReadRequest,
215        ___deadline: zx::MonotonicInstant,
216    ) -> Result<DataChannelReadResult, fidl::Error> {
217        let _response = self.client.send_query::<
218            DataChannelReadRequest,
219            fidl::encoding::FlexibleResultType<DataChannelReadResponse, i32>,
220            DataChannelMarker,
221        >(
222            payload,
223            0x12ab08cf21533d26,
224            fidl::encoding::DynamicFlags::FLEXIBLE,
225            ___deadline,
226        )?
227        .into_result::<DataChannelMarker>("read")?;
228        Ok(_response.map(|x| x))
229    }
230
231    /// The call will return once the data is fully committed.
232    ///
233    /// If the driver is not ready for a write, it will return
234    /// ZX_ERR_NO_RESOURCES and the caller should await SIGNAL_WRITABLE to be
235    /// asserted.
236    pub fn r#write(
237        &self,
238        mut payload: &DataChannelWriteRequest,
239        ___deadline: zx::MonotonicInstant,
240    ) -> Result<DataChannelWriteResult, fidl::Error> {
241        let _response = self.client.send_query::<
242            DataChannelWriteRequest,
243            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
244            DataChannelMarker,
245        >(
246            payload,
247            0xf2e12121698789b,
248            fidl::encoding::DynamicFlags::FLEXIBLE,
249            ___deadline,
250        )?
251        .into_result::<DataChannelMarker>("write")?;
252        Ok(_response.map(|x| x))
253    }
254}
255
256#[cfg(target_os = "fuchsia")]
257impl From<DataChannelSynchronousProxy> for zx::NullableHandle {
258    fn from(value: DataChannelSynchronousProxy) -> Self {
259        value.into_channel().into()
260    }
261}
262
263#[cfg(target_os = "fuchsia")]
264impl From<fidl::Channel> for DataChannelSynchronousProxy {
265    fn from(value: fidl::Channel) -> Self {
266        Self::new(value)
267    }
268}
269
270#[cfg(target_os = "fuchsia")]
271impl fidl::endpoints::FromClient for DataChannelSynchronousProxy {
272    type Protocol = DataChannelMarker;
273
274    fn from_client(value: fidl::endpoints::ClientEnd<DataChannelMarker>) -> Self {
275        Self::new(value.into_channel())
276    }
277}
278
279#[derive(Debug, Clone)]
280pub struct DataChannelProxy {
281    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
282}
283
284impl fidl::endpoints::Proxy for DataChannelProxy {
285    type Protocol = DataChannelMarker;
286
287    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
288        Self::new(inner)
289    }
290
291    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
292        self.client.into_channel().map_err(|client| Self { client })
293    }
294
295    fn as_channel(&self) -> &::fidl::AsyncChannel {
296        self.client.as_channel()
297    }
298}
299
300impl DataChannelProxy {
301    /// Create a new Proxy for fuchsia.hardware.google.nanohub/DataChannel.
302    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
303        let protocol_name = <DataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
304        Self { client: fidl::client::Client::new(channel, protocol_name) }
305    }
306
307    /// Get a Stream of events from the remote end of the protocol.
308    ///
309    /// # Panics
310    ///
311    /// Panics if the event stream was already taken.
312    pub fn take_event_stream(&self) -> DataChannelEventStream {
313        DataChannelEventStream { event_receiver: self.client.take_event_receiver() }
314    }
315
316    /// Set event used to signal device state. Discards existing event
317    /// after having transferred device state to the new event.
318    /// This must be called before invoking Read or Write, and can fail with
319    /// ZX_ERR_NO_RESOURCES if the underlying channel is busy.
320    pub fn r#register(
321        &self,
322        mut event: fidl::Event,
323    ) -> fidl::client::QueryResponseFut<
324        DataChannelRegisterResult,
325        fidl::encoding::DefaultFuchsiaResourceDialect,
326    > {
327        DataChannelProxyInterface::r#register(self, event)
328    }
329
330    /// Returns the identifier associated with this connection.
331    pub fn r#get_identifier(
332        &self,
333    ) -> fidl::client::QueryResponseFut<
334        DataChannelGetIdentifierResponse,
335        fidl::encoding::DefaultFuchsiaResourceDialect,
336    > {
337        DataChannelProxyInterface::r#get_identifier(self)
338    }
339
340    /// The call will return the next datagram to be read from the channel.
341    /// If there is more data to be read, SIGNAL_READABLE will remain asserted
342    /// after this call returns.
343    pub fn r#read(
344        &self,
345        mut payload: &DataChannelReadRequest,
346    ) -> fidl::client::QueryResponseFut<
347        DataChannelReadResult,
348        fidl::encoding::DefaultFuchsiaResourceDialect,
349    > {
350        DataChannelProxyInterface::r#read(self, payload)
351    }
352
353    /// The call will return once the data is fully committed.
354    ///
355    /// If the driver is not ready for a write, it will return
356    /// ZX_ERR_NO_RESOURCES and the caller should await SIGNAL_WRITABLE to be
357    /// asserted.
358    pub fn r#write(
359        &self,
360        mut payload: &DataChannelWriteRequest,
361    ) -> fidl::client::QueryResponseFut<
362        DataChannelWriteResult,
363        fidl::encoding::DefaultFuchsiaResourceDialect,
364    > {
365        DataChannelProxyInterface::r#write(self, payload)
366    }
367}
368
369impl DataChannelProxyInterface for DataChannelProxy {
370    type RegisterResponseFut = fidl::client::QueryResponseFut<
371        DataChannelRegisterResult,
372        fidl::encoding::DefaultFuchsiaResourceDialect,
373    >;
374    fn r#register(&self, mut event: fidl::Event) -> Self::RegisterResponseFut {
375        fn _decode(
376            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
377        ) -> Result<DataChannelRegisterResult, fidl::Error> {
378            let _response = fidl::client::decode_transaction_body::<
379                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
380                fidl::encoding::DefaultFuchsiaResourceDialect,
381                0x1778251ad75157b6,
382            >(_buf?)?
383            .into_result::<DataChannelMarker>("register")?;
384            Ok(_response.map(|x| x))
385        }
386        self.client.send_query_and_decode::<DataChannelRegisterRequest, DataChannelRegisterResult>(
387            (event,),
388            0x1778251ad75157b6,
389            fidl::encoding::DynamicFlags::FLEXIBLE,
390            _decode,
391        )
392    }
393
394    type GetIdentifierResponseFut = fidl::client::QueryResponseFut<
395        DataChannelGetIdentifierResponse,
396        fidl::encoding::DefaultFuchsiaResourceDialect,
397    >;
398    fn r#get_identifier(&self) -> Self::GetIdentifierResponseFut {
399        fn _decode(
400            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
401        ) -> Result<DataChannelGetIdentifierResponse, fidl::Error> {
402            let _response = fidl::client::decode_transaction_body::<
403                fidl::encoding::FlexibleType<DataChannelGetIdentifierResponse>,
404                fidl::encoding::DefaultFuchsiaResourceDialect,
405                0x4bf148d0ddbd4f69,
406            >(_buf?)?
407            .into_result::<DataChannelMarker>("get_identifier")?;
408            Ok(_response)
409        }
410        self.client.send_query_and_decode::<
411            fidl::encoding::EmptyPayload,
412            DataChannelGetIdentifierResponse,
413        >(
414            (),
415            0x4bf148d0ddbd4f69,
416            fidl::encoding::DynamicFlags::FLEXIBLE,
417            _decode,
418        )
419    }
420
421    type ReadResponseFut = fidl::client::QueryResponseFut<
422        DataChannelReadResult,
423        fidl::encoding::DefaultFuchsiaResourceDialect,
424    >;
425    fn r#read(&self, mut payload: &DataChannelReadRequest) -> Self::ReadResponseFut {
426        fn _decode(
427            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
428        ) -> Result<DataChannelReadResult, fidl::Error> {
429            let _response = fidl::client::decode_transaction_body::<
430                fidl::encoding::FlexibleResultType<DataChannelReadResponse, i32>,
431                fidl::encoding::DefaultFuchsiaResourceDialect,
432                0x12ab08cf21533d26,
433            >(_buf?)?
434            .into_result::<DataChannelMarker>("read")?;
435            Ok(_response.map(|x| x))
436        }
437        self.client.send_query_and_decode::<DataChannelReadRequest, DataChannelReadResult>(
438            payload,
439            0x12ab08cf21533d26,
440            fidl::encoding::DynamicFlags::FLEXIBLE,
441            _decode,
442        )
443    }
444
445    type WriteResponseFut = fidl::client::QueryResponseFut<
446        DataChannelWriteResult,
447        fidl::encoding::DefaultFuchsiaResourceDialect,
448    >;
449    fn r#write(&self, mut payload: &DataChannelWriteRequest) -> Self::WriteResponseFut {
450        fn _decode(
451            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
452        ) -> Result<DataChannelWriteResult, fidl::Error> {
453            let _response = fidl::client::decode_transaction_body::<
454                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
455                fidl::encoding::DefaultFuchsiaResourceDialect,
456                0xf2e12121698789b,
457            >(_buf?)?
458            .into_result::<DataChannelMarker>("write")?;
459            Ok(_response.map(|x| x))
460        }
461        self.client.send_query_and_decode::<DataChannelWriteRequest, DataChannelWriteResult>(
462            payload,
463            0xf2e12121698789b,
464            fidl::encoding::DynamicFlags::FLEXIBLE,
465            _decode,
466        )
467    }
468}
469
470pub struct DataChannelEventStream {
471    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
472}
473
474impl std::marker::Unpin for DataChannelEventStream {}
475
476impl futures::stream::FusedStream for DataChannelEventStream {
477    fn is_terminated(&self) -> bool {
478        self.event_receiver.is_terminated()
479    }
480}
481
482impl futures::Stream for DataChannelEventStream {
483    type Item = Result<DataChannelEvent, fidl::Error>;
484
485    fn poll_next(
486        mut self: std::pin::Pin<&mut Self>,
487        cx: &mut std::task::Context<'_>,
488    ) -> std::task::Poll<Option<Self::Item>> {
489        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
490            &mut self.event_receiver,
491            cx
492        )?) {
493            Some(buf) => std::task::Poll::Ready(Some(DataChannelEvent::decode(buf))),
494            None => std::task::Poll::Ready(None),
495        }
496    }
497}
498
499#[derive(Debug)]
500pub enum DataChannelEvent {
501    #[non_exhaustive]
502    _UnknownEvent {
503        /// Ordinal of the event that was sent.
504        ordinal: u64,
505    },
506}
507
508impl DataChannelEvent {
509    /// Decodes a message buffer as a [`DataChannelEvent`].
510    fn decode(
511        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
512    ) -> Result<DataChannelEvent, fidl::Error> {
513        let (bytes, _handles) = buf.split_mut();
514        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
515        debug_assert_eq!(tx_header.tx_id, 0);
516        match tx_header.ordinal {
517            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
518                Ok(DataChannelEvent::_UnknownEvent { ordinal: tx_header.ordinal })
519            }
520            _ => Err(fidl::Error::UnknownOrdinal {
521                ordinal: tx_header.ordinal,
522                protocol_name: <DataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
523            }),
524        }
525    }
526}
527
528/// A Stream of incoming requests for fuchsia.hardware.google.nanohub/DataChannel.
529pub struct DataChannelRequestStream {
530    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
531    is_terminated: bool,
532}
533
534impl std::marker::Unpin for DataChannelRequestStream {}
535
536impl futures::stream::FusedStream for DataChannelRequestStream {
537    fn is_terminated(&self) -> bool {
538        self.is_terminated
539    }
540}
541
542impl fidl::endpoints::RequestStream for DataChannelRequestStream {
543    type Protocol = DataChannelMarker;
544    type ControlHandle = DataChannelControlHandle;
545
546    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
547        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
548    }
549
550    fn control_handle(&self) -> Self::ControlHandle {
551        DataChannelControlHandle { inner: self.inner.clone() }
552    }
553
554    fn into_inner(
555        self,
556    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
557    {
558        (self.inner, self.is_terminated)
559    }
560
561    fn from_inner(
562        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
563        is_terminated: bool,
564    ) -> Self {
565        Self { inner, is_terminated }
566    }
567}
568
569impl futures::Stream for DataChannelRequestStream {
570    type Item = Result<DataChannelRequest, fidl::Error>;
571
572    fn poll_next(
573        mut self: std::pin::Pin<&mut Self>,
574        cx: &mut std::task::Context<'_>,
575    ) -> std::task::Poll<Option<Self::Item>> {
576        let this = &mut *self;
577        if this.inner.check_shutdown(cx) {
578            this.is_terminated = true;
579            return std::task::Poll::Ready(None);
580        }
581        if this.is_terminated {
582            panic!("polled DataChannelRequestStream after completion");
583        }
584        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
585            |bytes, handles| {
586                match this.inner.channel().read_etc(cx, bytes, handles) {
587                    std::task::Poll::Ready(Ok(())) => {}
588                    std::task::Poll::Pending => return std::task::Poll::Pending,
589                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
590                        this.is_terminated = true;
591                        return std::task::Poll::Ready(None);
592                    }
593                    std::task::Poll::Ready(Err(e)) => {
594                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
595                            e.into(),
596                        ))));
597                    }
598                }
599
600                // A message has been received from the channel
601                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
602
603                std::task::Poll::Ready(Some(match header.ordinal {
604                    0x1778251ad75157b6 => {
605                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
606                        let mut req = fidl::new_empty!(
607                            DataChannelRegisterRequest,
608                            fidl::encoding::DefaultFuchsiaResourceDialect
609                        );
610                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DataChannelRegisterRequest>(&header, _body_bytes, handles, &mut req)?;
611                        let control_handle = DataChannelControlHandle { inner: this.inner.clone() };
612                        Ok(DataChannelRequest::Register {
613                            event: req.event,
614
615                            responder: DataChannelRegisterResponder {
616                                control_handle: std::mem::ManuallyDrop::new(control_handle),
617                                tx_id: header.tx_id,
618                            },
619                        })
620                    }
621                    0x4bf148d0ddbd4f69 => {
622                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
623                        let mut req = fidl::new_empty!(
624                            fidl::encoding::EmptyPayload,
625                            fidl::encoding::DefaultFuchsiaResourceDialect
626                        );
627                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
628                        let control_handle = DataChannelControlHandle { inner: this.inner.clone() };
629                        Ok(DataChannelRequest::GetIdentifier {
630                            responder: DataChannelGetIdentifierResponder {
631                                control_handle: std::mem::ManuallyDrop::new(control_handle),
632                                tx_id: header.tx_id,
633                            },
634                        })
635                    }
636                    0x12ab08cf21533d26 => {
637                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
638                        let mut req = fidl::new_empty!(
639                            DataChannelReadRequest,
640                            fidl::encoding::DefaultFuchsiaResourceDialect
641                        );
642                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DataChannelReadRequest>(&header, _body_bytes, handles, &mut req)?;
643                        let control_handle = DataChannelControlHandle { inner: this.inner.clone() };
644                        Ok(DataChannelRequest::Read {
645                            payload: req,
646                            responder: DataChannelReadResponder {
647                                control_handle: std::mem::ManuallyDrop::new(control_handle),
648                                tx_id: header.tx_id,
649                            },
650                        })
651                    }
652                    0xf2e12121698789b => {
653                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
654                        let mut req = fidl::new_empty!(
655                            DataChannelWriteRequest,
656                            fidl::encoding::DefaultFuchsiaResourceDialect
657                        );
658                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DataChannelWriteRequest>(&header, _body_bytes, handles, &mut req)?;
659                        let control_handle = DataChannelControlHandle { inner: this.inner.clone() };
660                        Ok(DataChannelRequest::Write {
661                            payload: req,
662                            responder: DataChannelWriteResponder {
663                                control_handle: std::mem::ManuallyDrop::new(control_handle),
664                                tx_id: header.tx_id,
665                            },
666                        })
667                    }
668                    _ if header.tx_id == 0
669                        && header
670                            .dynamic_flags()
671                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
672                    {
673                        Ok(DataChannelRequest::_UnknownMethod {
674                            ordinal: header.ordinal,
675                            control_handle: DataChannelControlHandle { inner: this.inner.clone() },
676                            method_type: fidl::MethodType::OneWay,
677                        })
678                    }
679                    _ if header
680                        .dynamic_flags()
681                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
682                    {
683                        this.inner.send_framework_err(
684                            fidl::encoding::FrameworkErr::UnknownMethod,
685                            header.tx_id,
686                            header.ordinal,
687                            header.dynamic_flags(),
688                            (bytes, handles),
689                        )?;
690                        Ok(DataChannelRequest::_UnknownMethod {
691                            ordinal: header.ordinal,
692                            control_handle: DataChannelControlHandle { inner: this.inner.clone() },
693                            method_type: fidl::MethodType::TwoWay,
694                        })
695                    }
696                    _ => Err(fidl::Error::UnknownOrdinal {
697                        ordinal: header.ordinal,
698                        protocol_name:
699                            <DataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
700                    }),
701                }))
702            },
703        )
704    }
705}
706
707/// DataChannel Implementation
708#[derive(Debug)]
709pub enum DataChannelRequest {
710    /// Set event used to signal device state. Discards existing event
711    /// after having transferred device state to the new event.
712    /// This must be called before invoking Read or Write, and can fail with
713    /// ZX_ERR_NO_RESOURCES if the underlying channel is busy.
714    Register { event: fidl::Event, responder: DataChannelRegisterResponder },
715    /// Returns the identifier associated with this connection.
716    GetIdentifier { responder: DataChannelGetIdentifierResponder },
717    /// The call will return the next datagram to be read from the channel.
718    /// If there is more data to be read, SIGNAL_READABLE will remain asserted
719    /// after this call returns.
720    Read { payload: DataChannelReadRequest, responder: DataChannelReadResponder },
721    /// The call will return once the data is fully committed.
722    ///
723    /// If the driver is not ready for a write, it will return
724    /// ZX_ERR_NO_RESOURCES and the caller should await SIGNAL_WRITABLE to be
725    /// asserted.
726    Write { payload: DataChannelWriteRequest, responder: DataChannelWriteResponder },
727    /// An interaction was received which does not match any known method.
728    #[non_exhaustive]
729    _UnknownMethod {
730        /// Ordinal of the method that was called.
731        ordinal: u64,
732        control_handle: DataChannelControlHandle,
733        method_type: fidl::MethodType,
734    },
735}
736
737impl DataChannelRequest {
738    #[allow(irrefutable_let_patterns)]
739    pub fn into_register(self) -> Option<(fidl::Event, DataChannelRegisterResponder)> {
740        if let DataChannelRequest::Register { event, responder } = self {
741            Some((event, responder))
742        } else {
743            None
744        }
745    }
746
747    #[allow(irrefutable_let_patterns)]
748    pub fn into_get_identifier(self) -> Option<(DataChannelGetIdentifierResponder)> {
749        if let DataChannelRequest::GetIdentifier { responder } = self {
750            Some((responder))
751        } else {
752            None
753        }
754    }
755
756    #[allow(irrefutable_let_patterns)]
757    pub fn into_read(self) -> Option<(DataChannelReadRequest, DataChannelReadResponder)> {
758        if let DataChannelRequest::Read { payload, responder } = self {
759            Some((payload, responder))
760        } else {
761            None
762        }
763    }
764
765    #[allow(irrefutable_let_patterns)]
766    pub fn into_write(self) -> Option<(DataChannelWriteRequest, DataChannelWriteResponder)> {
767        if let DataChannelRequest::Write { payload, responder } = self {
768            Some((payload, responder))
769        } else {
770            None
771        }
772    }
773
774    /// Name of the method defined in FIDL
775    pub fn method_name(&self) -> &'static str {
776        match *self {
777            DataChannelRequest::Register { .. } => "register",
778            DataChannelRequest::GetIdentifier { .. } => "get_identifier",
779            DataChannelRequest::Read { .. } => "read",
780            DataChannelRequest::Write { .. } => "write",
781            DataChannelRequest::_UnknownMethod {
782                method_type: fidl::MethodType::OneWay, ..
783            } => "unknown one-way method",
784            DataChannelRequest::_UnknownMethod {
785                method_type: fidl::MethodType::TwoWay, ..
786            } => "unknown two-way method",
787        }
788    }
789}
790
791#[derive(Debug, Clone)]
792pub struct DataChannelControlHandle {
793    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
794}
795
796impl DataChannelControlHandle {
797    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
798        self.inner.shutdown_with_epitaph(status.into())
799    }
800}
801
802impl fidl::endpoints::ControlHandle for DataChannelControlHandle {
803    fn shutdown(&self) {
804        self.inner.shutdown()
805    }
806
807    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
808        self.inner.shutdown_with_epitaph(status)
809    }
810
811    fn is_closed(&self) -> bool {
812        self.inner.channel().is_closed()
813    }
814    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
815        self.inner.channel().on_closed()
816    }
817
818    #[cfg(target_os = "fuchsia")]
819    fn signal_peer(
820        &self,
821        clear_mask: zx::Signals,
822        set_mask: zx::Signals,
823    ) -> Result<(), zx_status::Status> {
824        use fidl::Peered;
825        self.inner.channel().signal_peer(clear_mask, set_mask)
826    }
827}
828
829impl DataChannelControlHandle {}
830
831#[must_use = "FIDL methods require a response to be sent"]
832#[derive(Debug)]
833pub struct DataChannelRegisterResponder {
834    control_handle: std::mem::ManuallyDrop<DataChannelControlHandle>,
835    tx_id: u32,
836}
837
838/// Set the the channel to be shutdown (see [`DataChannelControlHandle::shutdown`])
839/// if the responder is dropped without sending a response, so that the client
840/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
841impl std::ops::Drop for DataChannelRegisterResponder {
842    fn drop(&mut self) {
843        self.control_handle.shutdown();
844        // Safety: drops once, never accessed again
845        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
846    }
847}
848
849impl fidl::endpoints::Responder for DataChannelRegisterResponder {
850    type ControlHandle = DataChannelControlHandle;
851
852    fn control_handle(&self) -> &DataChannelControlHandle {
853        &self.control_handle
854    }
855
856    fn drop_without_shutdown(mut self) {
857        // Safety: drops once, never accessed again due to mem::forget
858        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
859        // Prevent Drop from running (which would shut down the channel)
860        std::mem::forget(self);
861    }
862}
863
864impl DataChannelRegisterResponder {
865    /// Sends a response to the FIDL transaction.
866    ///
867    /// Sets the channel to shutdown if an error occurs.
868    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
869        let _result = self.send_raw(result);
870        if _result.is_err() {
871            self.control_handle.shutdown();
872        }
873        self.drop_without_shutdown();
874        _result
875    }
876
877    /// Similar to "send" but does not shutdown the channel if an error occurs.
878    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
879        let _result = self.send_raw(result);
880        self.drop_without_shutdown();
881        _result
882    }
883
884    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
885        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
886            fidl::encoding::EmptyStruct,
887            i32,
888        >>(
889            fidl::encoding::FlexibleResult::new(result),
890            self.tx_id,
891            0x1778251ad75157b6,
892            fidl::encoding::DynamicFlags::FLEXIBLE,
893        )
894    }
895}
896
897#[must_use = "FIDL methods require a response to be sent"]
898#[derive(Debug)]
899pub struct DataChannelGetIdentifierResponder {
900    control_handle: std::mem::ManuallyDrop<DataChannelControlHandle>,
901    tx_id: u32,
902}
903
904/// Set the the channel to be shutdown (see [`DataChannelControlHandle::shutdown`])
905/// if the responder is dropped without sending a response, so that the client
906/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
907impl std::ops::Drop for DataChannelGetIdentifierResponder {
908    fn drop(&mut self) {
909        self.control_handle.shutdown();
910        // Safety: drops once, never accessed again
911        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
912    }
913}
914
915impl fidl::endpoints::Responder for DataChannelGetIdentifierResponder {
916    type ControlHandle = DataChannelControlHandle;
917
918    fn control_handle(&self) -> &DataChannelControlHandle {
919        &self.control_handle
920    }
921
922    fn drop_without_shutdown(mut self) {
923        // Safety: drops once, never accessed again due to mem::forget
924        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
925        // Prevent Drop from running (which would shut down the channel)
926        std::mem::forget(self);
927    }
928}
929
930impl DataChannelGetIdentifierResponder {
931    /// Sends a response to the FIDL transaction.
932    ///
933    /// Sets the channel to shutdown if an error occurs.
934    pub fn send(self, mut payload: &DataChannelGetIdentifierResponse) -> Result<(), fidl::Error> {
935        let _result = self.send_raw(payload);
936        if _result.is_err() {
937            self.control_handle.shutdown();
938        }
939        self.drop_without_shutdown();
940        _result
941    }
942
943    /// Similar to "send" but does not shutdown the channel if an error occurs.
944    pub fn send_no_shutdown_on_err(
945        self,
946        mut payload: &DataChannelGetIdentifierResponse,
947    ) -> Result<(), fidl::Error> {
948        let _result = self.send_raw(payload);
949        self.drop_without_shutdown();
950        _result
951    }
952
953    fn send_raw(&self, mut payload: &DataChannelGetIdentifierResponse) -> Result<(), fidl::Error> {
954        self.control_handle
955            .inner
956            .send::<fidl::encoding::FlexibleType<DataChannelGetIdentifierResponse>>(
957                fidl::encoding::Flexible::new(payload),
958                self.tx_id,
959                0x4bf148d0ddbd4f69,
960                fidl::encoding::DynamicFlags::FLEXIBLE,
961            )
962    }
963}
964
965#[must_use = "FIDL methods require a response to be sent"]
966#[derive(Debug)]
967pub struct DataChannelReadResponder {
968    control_handle: std::mem::ManuallyDrop<DataChannelControlHandle>,
969    tx_id: u32,
970}
971
972/// Set the the channel to be shutdown (see [`DataChannelControlHandle::shutdown`])
973/// if the responder is dropped without sending a response, so that the client
974/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
975impl std::ops::Drop for DataChannelReadResponder {
976    fn drop(&mut self) {
977        self.control_handle.shutdown();
978        // Safety: drops once, never accessed again
979        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
980    }
981}
982
983impl fidl::endpoints::Responder for DataChannelReadResponder {
984    type ControlHandle = DataChannelControlHandle;
985
986    fn control_handle(&self) -> &DataChannelControlHandle {
987        &self.control_handle
988    }
989
990    fn drop_without_shutdown(mut self) {
991        // Safety: drops once, never accessed again due to mem::forget
992        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
993        // Prevent Drop from running (which would shut down the channel)
994        std::mem::forget(self);
995    }
996}
997
998impl DataChannelReadResponder {
999    /// Sends a response to the FIDL transaction.
1000    ///
1001    /// Sets the channel to shutdown if an error occurs.
1002    pub fn send(self, mut result: Result<DataChannelReadResponse, i32>) -> Result<(), fidl::Error> {
1003        let _result = self.send_raw(result);
1004        if _result.is_err() {
1005            self.control_handle.shutdown();
1006        }
1007        self.drop_without_shutdown();
1008        _result
1009    }
1010
1011    /// Similar to "send" but does not shutdown the channel if an error occurs.
1012    pub fn send_no_shutdown_on_err(
1013        self,
1014        mut result: Result<DataChannelReadResponse, i32>,
1015    ) -> Result<(), fidl::Error> {
1016        let _result = self.send_raw(result);
1017        self.drop_without_shutdown();
1018        _result
1019    }
1020
1021    fn send_raw(
1022        &self,
1023        mut result: Result<DataChannelReadResponse, i32>,
1024    ) -> Result<(), fidl::Error> {
1025        self.control_handle
1026            .inner
1027            .send::<fidl::encoding::FlexibleResultType<DataChannelReadResponse, i32>>(
1028                fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
1029                self.tx_id,
1030                0x12ab08cf21533d26,
1031                fidl::encoding::DynamicFlags::FLEXIBLE,
1032            )
1033    }
1034}
1035
1036#[must_use = "FIDL methods require a response to be sent"]
1037#[derive(Debug)]
1038pub struct DataChannelWriteResponder {
1039    control_handle: std::mem::ManuallyDrop<DataChannelControlHandle>,
1040    tx_id: u32,
1041}
1042
1043/// Set the the channel to be shutdown (see [`DataChannelControlHandle::shutdown`])
1044/// if the responder is dropped without sending a response, so that the client
1045/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1046impl std::ops::Drop for DataChannelWriteResponder {
1047    fn drop(&mut self) {
1048        self.control_handle.shutdown();
1049        // Safety: drops once, never accessed again
1050        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1051    }
1052}
1053
1054impl fidl::endpoints::Responder for DataChannelWriteResponder {
1055    type ControlHandle = DataChannelControlHandle;
1056
1057    fn control_handle(&self) -> &DataChannelControlHandle {
1058        &self.control_handle
1059    }
1060
1061    fn drop_without_shutdown(mut self) {
1062        // Safety: drops once, never accessed again due to mem::forget
1063        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1064        // Prevent Drop from running (which would shut down the channel)
1065        std::mem::forget(self);
1066    }
1067}
1068
1069impl DataChannelWriteResponder {
1070    /// Sends a response to the FIDL transaction.
1071    ///
1072    /// Sets the channel to shutdown if an error occurs.
1073    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1074        let _result = self.send_raw(result);
1075        if _result.is_err() {
1076            self.control_handle.shutdown();
1077        }
1078        self.drop_without_shutdown();
1079        _result
1080    }
1081
1082    /// Similar to "send" but does not shutdown the channel if an error occurs.
1083    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1084        let _result = self.send_raw(result);
1085        self.drop_without_shutdown();
1086        _result
1087    }
1088
1089    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1090        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1091            fidl::encoding::EmptyStruct,
1092            i32,
1093        >>(
1094            fidl::encoding::FlexibleResult::new(result),
1095            self.tx_id,
1096            0xf2e12121698789b,
1097            fidl::encoding::DynamicFlags::FLEXIBLE,
1098        )
1099    }
1100}
1101
1102#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1103pub struct DeviceMarker;
1104
1105impl fidl::endpoints::ProtocolMarker for DeviceMarker {
1106    type Proxy = DeviceProxy;
1107    type RequestStream = DeviceRequestStream;
1108    #[cfg(target_os = "fuchsia")]
1109    type SynchronousProxy = DeviceSynchronousProxy;
1110
1111    const DEBUG_NAME: &'static str = "fuchsia.hardware.google.nanohub.Device";
1112}
1113impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
1114pub type DeviceDownloadFirmwareResult = Result<(), i32>;
1115pub type DeviceGetTimeSyncResult = Result<McuTimeSyncInfo, i32>;
1116pub type DeviceSetWakeLockResult = Result<(), i32>;
1117pub type DeviceGetWakeUpEventDurationResult = Result<i64, i32>;
1118pub type DeviceSetWakeUpEventDurationResult = Result<(), i32>;
1119pub type DeviceHardwareResetResult = Result<(), i32>;
1120
1121pub trait DeviceProxyInterface: Send + Sync {
1122    type DownloadFirmwareResponseFut: std::future::Future<Output = Result<DeviceDownloadFirmwareResult, fidl::Error>>
1123        + Send;
1124    fn r#download_firmware(
1125        &self,
1126        firmware: fidl::Vmo,
1127        offset: u64,
1128    ) -> Self::DownloadFirmwareResponseFut;
1129    type GetFirmwareNameResponseFut: std::future::Future<Output = Result<String, fidl::Error>>
1130        + Send;
1131    fn r#get_firmware_name(&self) -> Self::GetFirmwareNameResponseFut;
1132    type GetFirmwareVersionResponseFut: std::future::Future<Output = Result<McuVersionInfo, fidl::Error>>
1133        + Send;
1134    fn r#get_firmware_version(&self) -> Self::GetFirmwareVersionResponseFut;
1135    type GetTimeSyncResponseFut: std::future::Future<Output = Result<DeviceGetTimeSyncResult, fidl::Error>>
1136        + Send;
1137    fn r#get_time_sync(&self) -> Self::GetTimeSyncResponseFut;
1138    type SetWakeLockResponseFut: std::future::Future<Output = Result<DeviceSetWakeLockResult, fidl::Error>>
1139        + Send;
1140    fn r#set_wake_lock(&self, value: McuWakeLockValue) -> Self::SetWakeLockResponseFut;
1141    type GetWakeUpEventDurationResponseFut: std::future::Future<Output = Result<DeviceGetWakeUpEventDurationResult, fidl::Error>>
1142        + Send;
1143    fn r#get_wake_up_event_duration(&self) -> Self::GetWakeUpEventDurationResponseFut;
1144    type SetWakeUpEventDurationResponseFut: std::future::Future<Output = Result<DeviceSetWakeUpEventDurationResult, fidl::Error>>
1145        + Send;
1146    fn r#set_wake_up_event_duration(
1147        &self,
1148        duration: i64,
1149    ) -> Self::SetWakeUpEventDurationResponseFut;
1150    type HardwareResetResponseFut: std::future::Future<Output = Result<DeviceHardwareResetResult, fidl::Error>>
1151        + Send;
1152    fn r#hardware_reset(
1153        &self,
1154        isp_pin_0: PinState,
1155        isp_pin_1: PinState,
1156        isp_pin_2: PinState,
1157    ) -> Self::HardwareResetResponseFut;
1158}
1159#[derive(Debug)]
1160#[cfg(target_os = "fuchsia")]
1161pub struct DeviceSynchronousProxy {
1162    client: fidl::client::sync::Client,
1163}
1164
1165#[cfg(target_os = "fuchsia")]
1166impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
1167    type Proxy = DeviceProxy;
1168    type Protocol = DeviceMarker;
1169
1170    fn from_channel(inner: fidl::Channel) -> Self {
1171        Self::new(inner)
1172    }
1173
1174    fn into_channel(self) -> fidl::Channel {
1175        self.client.into_channel()
1176    }
1177
1178    fn as_channel(&self) -> &fidl::Channel {
1179        self.client.as_channel()
1180    }
1181}
1182
1183#[cfg(target_os = "fuchsia")]
1184impl DeviceSynchronousProxy {
1185    pub fn new(channel: fidl::Channel) -> Self {
1186        Self { client: fidl::client::sync::Client::new(channel) }
1187    }
1188
1189    pub fn into_channel(self) -> fidl::Channel {
1190        self.client.into_channel()
1191    }
1192
1193    /// Waits until an event arrives and returns it. It is safe for other
1194    /// threads to make concurrent requests while waiting for an event.
1195    pub fn wait_for_event(
1196        &self,
1197        deadline: zx::MonotonicInstant,
1198    ) -> Result<DeviceEvent, fidl::Error> {
1199        DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
1200    }
1201
1202    /// Request to sent to nanohub to load the firmware.
1203    pub fn r#download_firmware(
1204        &self,
1205        mut firmware: fidl::Vmo,
1206        mut offset: u64,
1207        ___deadline: zx::MonotonicInstant,
1208    ) -> Result<DeviceDownloadFirmwareResult, fidl::Error> {
1209        let _response = self.client.send_query::<
1210            DeviceDownloadFirmwareRequest,
1211            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1212            DeviceMarker,
1213        >(
1214            (firmware, offset,),
1215            0x7bba8137e24661e5,
1216            fidl::encoding::DynamicFlags::empty(),
1217            ___deadline,
1218        )?;
1219        Ok(_response.map(|x| x))
1220    }
1221
1222    /// The name of the firmware binary running on the MCU.
1223    pub fn r#get_firmware_name(
1224        &self,
1225        ___deadline: zx::MonotonicInstant,
1226    ) -> Result<String, fidl::Error> {
1227        let _response = self.client.send_query::<
1228            fidl::encoding::EmptyPayload,
1229            DeviceGetFirmwareNameResponse,
1230            DeviceMarker,
1231        >(
1232            (),
1233            0x1649434b5e5bcb8d,
1234            fidl::encoding::DynamicFlags::empty(),
1235            ___deadline,
1236        )?;
1237        Ok(_response.firmware_name)
1238    }
1239
1240    /// The version of the firmware binary running on the MCU.
1241    pub fn r#get_firmware_version(
1242        &self,
1243        ___deadline: zx::MonotonicInstant,
1244    ) -> Result<McuVersionInfo, fidl::Error> {
1245        let _response = self.client.send_query::<
1246            fidl::encoding::EmptyPayload,
1247            DeviceGetFirmwareVersionResponse,
1248            DeviceMarker,
1249        >(
1250            (),
1251            0x4f0599abcc95736b,
1252            fidl::encoding::DynamicFlags::empty(),
1253            ___deadline,
1254        )?;
1255        Ok(_response.version_info)
1256    }
1257
1258    /// The time since boot recorded by the AP and the MCU.
1259    pub fn r#get_time_sync(
1260        &self,
1261        ___deadline: zx::MonotonicInstant,
1262    ) -> Result<DeviceGetTimeSyncResult, fidl::Error> {
1263        let _response = self.client.send_query::<
1264            fidl::encoding::EmptyPayload,
1265            fidl::encoding::ResultType<McuTimeSyncInfo, i32>,
1266            DeviceMarker,
1267        >(
1268            (),
1269            0x4406991222e3975d,
1270            fidl::encoding::DynamicFlags::empty(),
1271            ___deadline,
1272        )?;
1273        Ok(_response.map(|x| x))
1274    }
1275
1276    /// Set an MCU wake lock request to prevent the MCU from entering a low-power state.
1277    pub fn r#set_wake_lock(
1278        &self,
1279        mut value: McuWakeLockValue,
1280        ___deadline: zx::MonotonicInstant,
1281    ) -> Result<DeviceSetWakeLockResult, fidl::Error> {
1282        let _response = self.client.send_query::<
1283            DeviceSetWakeLockRequest,
1284            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1285            DeviceMarker,
1286        >(
1287            (value,),
1288            0x9f83f614affa1dc,
1289            fidl::encoding::DynamicFlags::empty(),
1290            ___deadline,
1291        )?;
1292        Ok(_response.map(|x| x))
1293    }
1294
1295    /// Get the current duration of time the MCU will remain awake.
1296    pub fn r#get_wake_up_event_duration(
1297        &self,
1298        ___deadline: zx::MonotonicInstant,
1299    ) -> Result<DeviceGetWakeUpEventDurationResult, fidl::Error> {
1300        let _response = self.client.send_query::<
1301            fidl::encoding::EmptyPayload,
1302            fidl::encoding::ResultType<DeviceGetWakeUpEventDurationResponse, i32>,
1303            DeviceMarker,
1304        >(
1305            (),
1306            0x45c79749f65e7176,
1307            fidl::encoding::DynamicFlags::empty(),
1308            ___deadline,
1309        )?;
1310        Ok(_response.map(|x| x.duration))
1311    }
1312
1313    /// Set a duration of time for the MCU to remain awake.
1314    pub fn r#set_wake_up_event_duration(
1315        &self,
1316        mut duration: i64,
1317        ___deadline: zx::MonotonicInstant,
1318    ) -> Result<DeviceSetWakeUpEventDurationResult, fidl::Error> {
1319        let _response = self.client.send_query::<
1320            DeviceSetWakeUpEventDurationRequest,
1321            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1322            DeviceMarker,
1323        >(
1324            (duration,),
1325            0x1fa1771ffa5f570,
1326            fidl::encoding::DynamicFlags::empty(),
1327            ___deadline,
1328        )?;
1329        Ok(_response.map(|x| x))
1330    }
1331
1332    /// Initiates a hardware reset.
1333    pub fn r#hardware_reset(
1334        &self,
1335        mut isp_pin_0: PinState,
1336        mut isp_pin_1: PinState,
1337        mut isp_pin_2: PinState,
1338        ___deadline: zx::MonotonicInstant,
1339    ) -> Result<DeviceHardwareResetResult, fidl::Error> {
1340        let _response = self.client.send_query::<
1341            HardwareResetPinStates,
1342            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1343            DeviceMarker,
1344        >(
1345            (isp_pin_0, isp_pin_1, isp_pin_2,),
1346            0x78e3d2ded2f929f,
1347            fidl::encoding::DynamicFlags::empty(),
1348            ___deadline,
1349        )?;
1350        Ok(_response.map(|x| x))
1351    }
1352}
1353
1354#[cfg(target_os = "fuchsia")]
1355impl From<DeviceSynchronousProxy> for zx::NullableHandle {
1356    fn from(value: DeviceSynchronousProxy) -> Self {
1357        value.into_channel().into()
1358    }
1359}
1360
1361#[cfg(target_os = "fuchsia")]
1362impl From<fidl::Channel> for DeviceSynchronousProxy {
1363    fn from(value: fidl::Channel) -> Self {
1364        Self::new(value)
1365    }
1366}
1367
1368#[cfg(target_os = "fuchsia")]
1369impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
1370    type Protocol = DeviceMarker;
1371
1372    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
1373        Self::new(value.into_channel())
1374    }
1375}
1376
1377#[derive(Debug, Clone)]
1378pub struct DeviceProxy {
1379    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1380}
1381
1382impl fidl::endpoints::Proxy for DeviceProxy {
1383    type Protocol = DeviceMarker;
1384
1385    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1386        Self::new(inner)
1387    }
1388
1389    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1390        self.client.into_channel().map_err(|client| Self { client })
1391    }
1392
1393    fn as_channel(&self) -> &::fidl::AsyncChannel {
1394        self.client.as_channel()
1395    }
1396}
1397
1398impl DeviceProxy {
1399    /// Create a new Proxy for fuchsia.hardware.google.nanohub/Device.
1400    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1401        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1402        Self { client: fidl::client::Client::new(channel, protocol_name) }
1403    }
1404
1405    /// Get a Stream of events from the remote end of the protocol.
1406    ///
1407    /// # Panics
1408    ///
1409    /// Panics if the event stream was already taken.
1410    pub fn take_event_stream(&self) -> DeviceEventStream {
1411        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
1412    }
1413
1414    /// Request to sent to nanohub to load the firmware.
1415    pub fn r#download_firmware(
1416        &self,
1417        mut firmware: fidl::Vmo,
1418        mut offset: u64,
1419    ) -> fidl::client::QueryResponseFut<
1420        DeviceDownloadFirmwareResult,
1421        fidl::encoding::DefaultFuchsiaResourceDialect,
1422    > {
1423        DeviceProxyInterface::r#download_firmware(self, firmware, offset)
1424    }
1425
1426    /// The name of the firmware binary running on the MCU.
1427    pub fn r#get_firmware_name(
1428        &self,
1429    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
1430        DeviceProxyInterface::r#get_firmware_name(self)
1431    }
1432
1433    /// The version of the firmware binary running on the MCU.
1434    pub fn r#get_firmware_version(
1435        &self,
1436    ) -> fidl::client::QueryResponseFut<McuVersionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
1437    {
1438        DeviceProxyInterface::r#get_firmware_version(self)
1439    }
1440
1441    /// The time since boot recorded by the AP and the MCU.
1442    pub fn r#get_time_sync(
1443        &self,
1444    ) -> fidl::client::QueryResponseFut<
1445        DeviceGetTimeSyncResult,
1446        fidl::encoding::DefaultFuchsiaResourceDialect,
1447    > {
1448        DeviceProxyInterface::r#get_time_sync(self)
1449    }
1450
1451    /// Set an MCU wake lock request to prevent the MCU from entering a low-power state.
1452    pub fn r#set_wake_lock(
1453        &self,
1454        mut value: McuWakeLockValue,
1455    ) -> fidl::client::QueryResponseFut<
1456        DeviceSetWakeLockResult,
1457        fidl::encoding::DefaultFuchsiaResourceDialect,
1458    > {
1459        DeviceProxyInterface::r#set_wake_lock(self, value)
1460    }
1461
1462    /// Get the current duration of time the MCU will remain awake.
1463    pub fn r#get_wake_up_event_duration(
1464        &self,
1465    ) -> fidl::client::QueryResponseFut<
1466        DeviceGetWakeUpEventDurationResult,
1467        fidl::encoding::DefaultFuchsiaResourceDialect,
1468    > {
1469        DeviceProxyInterface::r#get_wake_up_event_duration(self)
1470    }
1471
1472    /// Set a duration of time for the MCU to remain awake.
1473    pub fn r#set_wake_up_event_duration(
1474        &self,
1475        mut duration: i64,
1476    ) -> fidl::client::QueryResponseFut<
1477        DeviceSetWakeUpEventDurationResult,
1478        fidl::encoding::DefaultFuchsiaResourceDialect,
1479    > {
1480        DeviceProxyInterface::r#set_wake_up_event_duration(self, duration)
1481    }
1482
1483    /// Initiates a hardware reset.
1484    pub fn r#hardware_reset(
1485        &self,
1486        mut isp_pin_0: PinState,
1487        mut isp_pin_1: PinState,
1488        mut isp_pin_2: PinState,
1489    ) -> fidl::client::QueryResponseFut<
1490        DeviceHardwareResetResult,
1491        fidl::encoding::DefaultFuchsiaResourceDialect,
1492    > {
1493        DeviceProxyInterface::r#hardware_reset(self, isp_pin_0, isp_pin_1, isp_pin_2)
1494    }
1495}
1496
1497impl DeviceProxyInterface for DeviceProxy {
1498    type DownloadFirmwareResponseFut = fidl::client::QueryResponseFut<
1499        DeviceDownloadFirmwareResult,
1500        fidl::encoding::DefaultFuchsiaResourceDialect,
1501    >;
1502    fn r#download_firmware(
1503        &self,
1504        mut firmware: fidl::Vmo,
1505        mut offset: u64,
1506    ) -> Self::DownloadFirmwareResponseFut {
1507        fn _decode(
1508            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1509        ) -> Result<DeviceDownloadFirmwareResult, fidl::Error> {
1510            let _response = fidl::client::decode_transaction_body::<
1511                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1512                fidl::encoding::DefaultFuchsiaResourceDialect,
1513                0x7bba8137e24661e5,
1514            >(_buf?)?;
1515            Ok(_response.map(|x| x))
1516        }
1517        self.client
1518            .send_query_and_decode::<DeviceDownloadFirmwareRequest, DeviceDownloadFirmwareResult>(
1519                (firmware, offset),
1520                0x7bba8137e24661e5,
1521                fidl::encoding::DynamicFlags::empty(),
1522                _decode,
1523            )
1524    }
1525
1526    type GetFirmwareNameResponseFut =
1527        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
1528    fn r#get_firmware_name(&self) -> Self::GetFirmwareNameResponseFut {
1529        fn _decode(
1530            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1531        ) -> Result<String, fidl::Error> {
1532            let _response = fidl::client::decode_transaction_body::<
1533                DeviceGetFirmwareNameResponse,
1534                fidl::encoding::DefaultFuchsiaResourceDialect,
1535                0x1649434b5e5bcb8d,
1536            >(_buf?)?;
1537            Ok(_response.firmware_name)
1538        }
1539        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
1540            (),
1541            0x1649434b5e5bcb8d,
1542            fidl::encoding::DynamicFlags::empty(),
1543            _decode,
1544        )
1545    }
1546
1547    type GetFirmwareVersionResponseFut = fidl::client::QueryResponseFut<
1548        McuVersionInfo,
1549        fidl::encoding::DefaultFuchsiaResourceDialect,
1550    >;
1551    fn r#get_firmware_version(&self) -> Self::GetFirmwareVersionResponseFut {
1552        fn _decode(
1553            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1554        ) -> Result<McuVersionInfo, fidl::Error> {
1555            let _response = fidl::client::decode_transaction_body::<
1556                DeviceGetFirmwareVersionResponse,
1557                fidl::encoding::DefaultFuchsiaResourceDialect,
1558                0x4f0599abcc95736b,
1559            >(_buf?)?;
1560            Ok(_response.version_info)
1561        }
1562        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, McuVersionInfo>(
1563            (),
1564            0x4f0599abcc95736b,
1565            fidl::encoding::DynamicFlags::empty(),
1566            _decode,
1567        )
1568    }
1569
1570    type GetTimeSyncResponseFut = fidl::client::QueryResponseFut<
1571        DeviceGetTimeSyncResult,
1572        fidl::encoding::DefaultFuchsiaResourceDialect,
1573    >;
1574    fn r#get_time_sync(&self) -> Self::GetTimeSyncResponseFut {
1575        fn _decode(
1576            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1577        ) -> Result<DeviceGetTimeSyncResult, fidl::Error> {
1578            let _response = fidl::client::decode_transaction_body::<
1579                fidl::encoding::ResultType<McuTimeSyncInfo, i32>,
1580                fidl::encoding::DefaultFuchsiaResourceDialect,
1581                0x4406991222e3975d,
1582            >(_buf?)?;
1583            Ok(_response.map(|x| x))
1584        }
1585        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetTimeSyncResult>(
1586            (),
1587            0x4406991222e3975d,
1588            fidl::encoding::DynamicFlags::empty(),
1589            _decode,
1590        )
1591    }
1592
1593    type SetWakeLockResponseFut = fidl::client::QueryResponseFut<
1594        DeviceSetWakeLockResult,
1595        fidl::encoding::DefaultFuchsiaResourceDialect,
1596    >;
1597    fn r#set_wake_lock(&self, mut value: McuWakeLockValue) -> Self::SetWakeLockResponseFut {
1598        fn _decode(
1599            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1600        ) -> Result<DeviceSetWakeLockResult, fidl::Error> {
1601            let _response = fidl::client::decode_transaction_body::<
1602                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1603                fidl::encoding::DefaultFuchsiaResourceDialect,
1604                0x9f83f614affa1dc,
1605            >(_buf?)?;
1606            Ok(_response.map(|x| x))
1607        }
1608        self.client.send_query_and_decode::<DeviceSetWakeLockRequest, DeviceSetWakeLockResult>(
1609            (value,),
1610            0x9f83f614affa1dc,
1611            fidl::encoding::DynamicFlags::empty(),
1612            _decode,
1613        )
1614    }
1615
1616    type GetWakeUpEventDurationResponseFut = fidl::client::QueryResponseFut<
1617        DeviceGetWakeUpEventDurationResult,
1618        fidl::encoding::DefaultFuchsiaResourceDialect,
1619    >;
1620    fn r#get_wake_up_event_duration(&self) -> Self::GetWakeUpEventDurationResponseFut {
1621        fn _decode(
1622            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1623        ) -> Result<DeviceGetWakeUpEventDurationResult, fidl::Error> {
1624            let _response = fidl::client::decode_transaction_body::<
1625                fidl::encoding::ResultType<DeviceGetWakeUpEventDurationResponse, i32>,
1626                fidl::encoding::DefaultFuchsiaResourceDialect,
1627                0x45c79749f65e7176,
1628            >(_buf?)?;
1629            Ok(_response.map(|x| x.duration))
1630        }
1631        self.client.send_query_and_decode::<
1632            fidl::encoding::EmptyPayload,
1633            DeviceGetWakeUpEventDurationResult,
1634        >(
1635            (),
1636            0x45c79749f65e7176,
1637            fidl::encoding::DynamicFlags::empty(),
1638            _decode,
1639        )
1640    }
1641
1642    type SetWakeUpEventDurationResponseFut = fidl::client::QueryResponseFut<
1643        DeviceSetWakeUpEventDurationResult,
1644        fidl::encoding::DefaultFuchsiaResourceDialect,
1645    >;
1646    fn r#set_wake_up_event_duration(
1647        &self,
1648        mut duration: i64,
1649    ) -> Self::SetWakeUpEventDurationResponseFut {
1650        fn _decode(
1651            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1652        ) -> Result<DeviceSetWakeUpEventDurationResult, fidl::Error> {
1653            let _response = fidl::client::decode_transaction_body::<
1654                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1655                fidl::encoding::DefaultFuchsiaResourceDialect,
1656                0x1fa1771ffa5f570,
1657            >(_buf?)?;
1658            Ok(_response.map(|x| x))
1659        }
1660        self.client.send_query_and_decode::<
1661            DeviceSetWakeUpEventDurationRequest,
1662            DeviceSetWakeUpEventDurationResult,
1663        >(
1664            (duration,),
1665            0x1fa1771ffa5f570,
1666            fidl::encoding::DynamicFlags::empty(),
1667            _decode,
1668        )
1669    }
1670
1671    type HardwareResetResponseFut = fidl::client::QueryResponseFut<
1672        DeviceHardwareResetResult,
1673        fidl::encoding::DefaultFuchsiaResourceDialect,
1674    >;
1675    fn r#hardware_reset(
1676        &self,
1677        mut isp_pin_0: PinState,
1678        mut isp_pin_1: PinState,
1679        mut isp_pin_2: PinState,
1680    ) -> Self::HardwareResetResponseFut {
1681        fn _decode(
1682            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1683        ) -> Result<DeviceHardwareResetResult, fidl::Error> {
1684            let _response = fidl::client::decode_transaction_body::<
1685                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1686                fidl::encoding::DefaultFuchsiaResourceDialect,
1687                0x78e3d2ded2f929f,
1688            >(_buf?)?;
1689            Ok(_response.map(|x| x))
1690        }
1691        self.client.send_query_and_decode::<HardwareResetPinStates, DeviceHardwareResetResult>(
1692            (isp_pin_0, isp_pin_1, isp_pin_2),
1693            0x78e3d2ded2f929f,
1694            fidl::encoding::DynamicFlags::empty(),
1695            _decode,
1696        )
1697    }
1698}
1699
1700pub struct DeviceEventStream {
1701    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1702}
1703
1704impl std::marker::Unpin for DeviceEventStream {}
1705
1706impl futures::stream::FusedStream for DeviceEventStream {
1707    fn is_terminated(&self) -> bool {
1708        self.event_receiver.is_terminated()
1709    }
1710}
1711
1712impl futures::Stream for DeviceEventStream {
1713    type Item = Result<DeviceEvent, fidl::Error>;
1714
1715    fn poll_next(
1716        mut self: std::pin::Pin<&mut Self>,
1717        cx: &mut std::task::Context<'_>,
1718    ) -> std::task::Poll<Option<Self::Item>> {
1719        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1720            &mut self.event_receiver,
1721            cx
1722        )?) {
1723            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
1724            None => std::task::Poll::Ready(None),
1725        }
1726    }
1727}
1728
1729#[derive(Debug)]
1730pub enum DeviceEvent {
1731    #[non_exhaustive]
1732    _UnknownEvent {
1733        /// Ordinal of the event that was sent.
1734        ordinal: u64,
1735    },
1736}
1737
1738impl DeviceEvent {
1739    /// Decodes a message buffer as a [`DeviceEvent`].
1740    fn decode(
1741        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1742    ) -> Result<DeviceEvent, fidl::Error> {
1743        let (bytes, _handles) = buf.split_mut();
1744        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1745        debug_assert_eq!(tx_header.tx_id, 0);
1746        match tx_header.ordinal {
1747            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1748                Ok(DeviceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1749            }
1750            _ => Err(fidl::Error::UnknownOrdinal {
1751                ordinal: tx_header.ordinal,
1752                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1753            }),
1754        }
1755    }
1756}
1757
1758/// A Stream of incoming requests for fuchsia.hardware.google.nanohub/Device.
1759pub struct DeviceRequestStream {
1760    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1761    is_terminated: bool,
1762}
1763
1764impl std::marker::Unpin for DeviceRequestStream {}
1765
1766impl futures::stream::FusedStream for DeviceRequestStream {
1767    fn is_terminated(&self) -> bool {
1768        self.is_terminated
1769    }
1770}
1771
1772impl fidl::endpoints::RequestStream for DeviceRequestStream {
1773    type Protocol = DeviceMarker;
1774    type ControlHandle = DeviceControlHandle;
1775
1776    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1777        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1778    }
1779
1780    fn control_handle(&self) -> Self::ControlHandle {
1781        DeviceControlHandle { inner: self.inner.clone() }
1782    }
1783
1784    fn into_inner(
1785        self,
1786    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1787    {
1788        (self.inner, self.is_terminated)
1789    }
1790
1791    fn from_inner(
1792        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1793        is_terminated: bool,
1794    ) -> Self {
1795        Self { inner, is_terminated }
1796    }
1797}
1798
1799impl futures::Stream for DeviceRequestStream {
1800    type Item = Result<DeviceRequest, fidl::Error>;
1801
1802    fn poll_next(
1803        mut self: std::pin::Pin<&mut Self>,
1804        cx: &mut std::task::Context<'_>,
1805    ) -> std::task::Poll<Option<Self::Item>> {
1806        let this = &mut *self;
1807        if this.inner.check_shutdown(cx) {
1808            this.is_terminated = true;
1809            return std::task::Poll::Ready(None);
1810        }
1811        if this.is_terminated {
1812            panic!("polled DeviceRequestStream after completion");
1813        }
1814        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1815            |bytes, handles| {
1816                match this.inner.channel().read_etc(cx, bytes, handles) {
1817                    std::task::Poll::Ready(Ok(())) => {}
1818                    std::task::Poll::Pending => return std::task::Poll::Pending,
1819                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1820                        this.is_terminated = true;
1821                        return std::task::Poll::Ready(None);
1822                    }
1823                    std::task::Poll::Ready(Err(e)) => {
1824                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1825                            e.into(),
1826                        ))));
1827                    }
1828                }
1829
1830                // A message has been received from the channel
1831                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1832
1833                std::task::Poll::Ready(Some(match header.ordinal {
1834                    0x7bba8137e24661e5 => {
1835                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1836                        let mut req = fidl::new_empty!(
1837                            DeviceDownloadFirmwareRequest,
1838                            fidl::encoding::DefaultFuchsiaResourceDialect
1839                        );
1840                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceDownloadFirmwareRequest>(&header, _body_bytes, handles, &mut req)?;
1841                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1842                        Ok(DeviceRequest::DownloadFirmware {
1843                            firmware: req.firmware,
1844                            offset: req.offset,
1845
1846                            responder: DeviceDownloadFirmwareResponder {
1847                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1848                                tx_id: header.tx_id,
1849                            },
1850                        })
1851                    }
1852                    0x1649434b5e5bcb8d => {
1853                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1854                        let mut req = fidl::new_empty!(
1855                            fidl::encoding::EmptyPayload,
1856                            fidl::encoding::DefaultFuchsiaResourceDialect
1857                        );
1858                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1859                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1860                        Ok(DeviceRequest::GetFirmwareName {
1861                            responder: DeviceGetFirmwareNameResponder {
1862                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1863                                tx_id: header.tx_id,
1864                            },
1865                        })
1866                    }
1867                    0x4f0599abcc95736b => {
1868                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1869                        let mut req = fidl::new_empty!(
1870                            fidl::encoding::EmptyPayload,
1871                            fidl::encoding::DefaultFuchsiaResourceDialect
1872                        );
1873                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1874                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1875                        Ok(DeviceRequest::GetFirmwareVersion {
1876                            responder: DeviceGetFirmwareVersionResponder {
1877                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1878                                tx_id: header.tx_id,
1879                            },
1880                        })
1881                    }
1882                    0x4406991222e3975d => {
1883                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1884                        let mut req = fidl::new_empty!(
1885                            fidl::encoding::EmptyPayload,
1886                            fidl::encoding::DefaultFuchsiaResourceDialect
1887                        );
1888                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1889                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1890                        Ok(DeviceRequest::GetTimeSync {
1891                            responder: DeviceGetTimeSyncResponder {
1892                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1893                                tx_id: header.tx_id,
1894                            },
1895                        })
1896                    }
1897                    0x9f83f614affa1dc => {
1898                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1899                        let mut req = fidl::new_empty!(
1900                            DeviceSetWakeLockRequest,
1901                            fidl::encoding::DefaultFuchsiaResourceDialect
1902                        );
1903                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetWakeLockRequest>(&header, _body_bytes, handles, &mut req)?;
1904                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1905                        Ok(DeviceRequest::SetWakeLock {
1906                            value: req.value,
1907
1908                            responder: DeviceSetWakeLockResponder {
1909                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1910                                tx_id: header.tx_id,
1911                            },
1912                        })
1913                    }
1914                    0x45c79749f65e7176 => {
1915                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1916                        let mut req = fidl::new_empty!(
1917                            fidl::encoding::EmptyPayload,
1918                            fidl::encoding::DefaultFuchsiaResourceDialect
1919                        );
1920                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1921                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1922                        Ok(DeviceRequest::GetWakeUpEventDuration {
1923                            responder: DeviceGetWakeUpEventDurationResponder {
1924                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1925                                tx_id: header.tx_id,
1926                            },
1927                        })
1928                    }
1929                    0x1fa1771ffa5f570 => {
1930                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1931                        let mut req = fidl::new_empty!(
1932                            DeviceSetWakeUpEventDurationRequest,
1933                            fidl::encoding::DefaultFuchsiaResourceDialect
1934                        );
1935                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetWakeUpEventDurationRequest>(&header, _body_bytes, handles, &mut req)?;
1936                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1937                        Ok(DeviceRequest::SetWakeUpEventDuration {
1938                            duration: req.duration,
1939
1940                            responder: DeviceSetWakeUpEventDurationResponder {
1941                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1942                                tx_id: header.tx_id,
1943                            },
1944                        })
1945                    }
1946                    0x78e3d2ded2f929f => {
1947                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1948                        let mut req = fidl::new_empty!(
1949                            HardwareResetPinStates,
1950                            fidl::encoding::DefaultFuchsiaResourceDialect
1951                        );
1952                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HardwareResetPinStates>(&header, _body_bytes, handles, &mut req)?;
1953                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1954                        Ok(DeviceRequest::HardwareReset {
1955                            isp_pin_0: req.isp_pin_0,
1956                            isp_pin_1: req.isp_pin_1,
1957                            isp_pin_2: req.isp_pin_2,
1958
1959                            responder: DeviceHardwareResetResponder {
1960                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1961                                tx_id: header.tx_id,
1962                            },
1963                        })
1964                    }
1965                    _ if header.tx_id == 0
1966                        && header
1967                            .dynamic_flags()
1968                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1969                    {
1970                        Ok(DeviceRequest::_UnknownMethod {
1971                            ordinal: header.ordinal,
1972                            control_handle: DeviceControlHandle { inner: this.inner.clone() },
1973                            method_type: fidl::MethodType::OneWay,
1974                        })
1975                    }
1976                    _ if header
1977                        .dynamic_flags()
1978                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1979                    {
1980                        this.inner.send_framework_err(
1981                            fidl::encoding::FrameworkErr::UnknownMethod,
1982                            header.tx_id,
1983                            header.ordinal,
1984                            header.dynamic_flags(),
1985                            (bytes, handles),
1986                        )?;
1987                        Ok(DeviceRequest::_UnknownMethod {
1988                            ordinal: header.ordinal,
1989                            control_handle: DeviceControlHandle { inner: this.inner.clone() },
1990                            method_type: fidl::MethodType::TwoWay,
1991                        })
1992                    }
1993                    _ => Err(fidl::Error::UnknownOrdinal {
1994                        ordinal: header.ordinal,
1995                        protocol_name:
1996                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1997                    }),
1998                }))
1999            },
2000        )
2001    }
2002}
2003
2004/// Client is expected to pass the vmo handle to nanohub when issuing a DownloadFirmware request.
2005#[derive(Debug)]
2006pub enum DeviceRequest {
2007    /// Request to sent to nanohub to load the firmware.
2008    DownloadFirmware {
2009        firmware: fidl::Vmo,
2010        offset: u64,
2011        responder: DeviceDownloadFirmwareResponder,
2012    },
2013    /// The name of the firmware binary running on the MCU.
2014    GetFirmwareName { responder: DeviceGetFirmwareNameResponder },
2015    /// The version of the firmware binary running on the MCU.
2016    GetFirmwareVersion { responder: DeviceGetFirmwareVersionResponder },
2017    /// The time since boot recorded by the AP and the MCU.
2018    GetTimeSync { responder: DeviceGetTimeSyncResponder },
2019    /// Set an MCU wake lock request to prevent the MCU from entering a low-power state.
2020    SetWakeLock { value: McuWakeLockValue, responder: DeviceSetWakeLockResponder },
2021    /// Get the current duration of time the MCU will remain awake.
2022    GetWakeUpEventDuration { responder: DeviceGetWakeUpEventDurationResponder },
2023    /// Set a duration of time for the MCU to remain awake.
2024    SetWakeUpEventDuration { duration: i64, responder: DeviceSetWakeUpEventDurationResponder },
2025    /// Initiates a hardware reset.
2026    HardwareReset {
2027        isp_pin_0: PinState,
2028        isp_pin_1: PinState,
2029        isp_pin_2: PinState,
2030        responder: DeviceHardwareResetResponder,
2031    },
2032    /// An interaction was received which does not match any known method.
2033    #[non_exhaustive]
2034    _UnknownMethod {
2035        /// Ordinal of the method that was called.
2036        ordinal: u64,
2037        control_handle: DeviceControlHandle,
2038        method_type: fidl::MethodType,
2039    },
2040}
2041
2042impl DeviceRequest {
2043    #[allow(irrefutable_let_patterns)]
2044    pub fn into_download_firmware(
2045        self,
2046    ) -> Option<(fidl::Vmo, u64, DeviceDownloadFirmwareResponder)> {
2047        if let DeviceRequest::DownloadFirmware { firmware, offset, responder } = self {
2048            Some((firmware, offset, responder))
2049        } else {
2050            None
2051        }
2052    }
2053
2054    #[allow(irrefutable_let_patterns)]
2055    pub fn into_get_firmware_name(self) -> Option<(DeviceGetFirmwareNameResponder)> {
2056        if let DeviceRequest::GetFirmwareName { responder } = self {
2057            Some((responder))
2058        } else {
2059            None
2060        }
2061    }
2062
2063    #[allow(irrefutable_let_patterns)]
2064    pub fn into_get_firmware_version(self) -> Option<(DeviceGetFirmwareVersionResponder)> {
2065        if let DeviceRequest::GetFirmwareVersion { responder } = self {
2066            Some((responder))
2067        } else {
2068            None
2069        }
2070    }
2071
2072    #[allow(irrefutable_let_patterns)]
2073    pub fn into_get_time_sync(self) -> Option<(DeviceGetTimeSyncResponder)> {
2074        if let DeviceRequest::GetTimeSync { responder } = self { Some((responder)) } else { None }
2075    }
2076
2077    #[allow(irrefutable_let_patterns)]
2078    pub fn into_set_wake_lock(self) -> Option<(McuWakeLockValue, DeviceSetWakeLockResponder)> {
2079        if let DeviceRequest::SetWakeLock { value, responder } = self {
2080            Some((value, responder))
2081        } else {
2082            None
2083        }
2084    }
2085
2086    #[allow(irrefutable_let_patterns)]
2087    pub fn into_get_wake_up_event_duration(
2088        self,
2089    ) -> Option<(DeviceGetWakeUpEventDurationResponder)> {
2090        if let DeviceRequest::GetWakeUpEventDuration { responder } = self {
2091            Some((responder))
2092        } else {
2093            None
2094        }
2095    }
2096
2097    #[allow(irrefutable_let_patterns)]
2098    pub fn into_set_wake_up_event_duration(
2099        self,
2100    ) -> Option<(i64, DeviceSetWakeUpEventDurationResponder)> {
2101        if let DeviceRequest::SetWakeUpEventDuration { duration, responder } = self {
2102            Some((duration, responder))
2103        } else {
2104            None
2105        }
2106    }
2107
2108    #[allow(irrefutable_let_patterns)]
2109    pub fn into_hardware_reset(
2110        self,
2111    ) -> Option<(PinState, PinState, PinState, DeviceHardwareResetResponder)> {
2112        if let DeviceRequest::HardwareReset { isp_pin_0, isp_pin_1, isp_pin_2, responder } = self {
2113            Some((isp_pin_0, isp_pin_1, isp_pin_2, responder))
2114        } else {
2115            None
2116        }
2117    }
2118
2119    /// Name of the method defined in FIDL
2120    pub fn method_name(&self) -> &'static str {
2121        match *self {
2122            DeviceRequest::DownloadFirmware { .. } => "download_firmware",
2123            DeviceRequest::GetFirmwareName { .. } => "get_firmware_name",
2124            DeviceRequest::GetFirmwareVersion { .. } => "get_firmware_version",
2125            DeviceRequest::GetTimeSync { .. } => "get_time_sync",
2126            DeviceRequest::SetWakeLock { .. } => "set_wake_lock",
2127            DeviceRequest::GetWakeUpEventDuration { .. } => "get_wake_up_event_duration",
2128            DeviceRequest::SetWakeUpEventDuration { .. } => "set_wake_up_event_duration",
2129            DeviceRequest::HardwareReset { .. } => "hardware_reset",
2130            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2131                "unknown one-way method"
2132            }
2133            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2134                "unknown two-way method"
2135            }
2136        }
2137    }
2138}
2139
2140#[derive(Debug, Clone)]
2141pub struct DeviceControlHandle {
2142    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2143}
2144
2145impl DeviceControlHandle {
2146    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2147        self.inner.shutdown_with_epitaph(status.into())
2148    }
2149}
2150
2151impl fidl::endpoints::ControlHandle for DeviceControlHandle {
2152    fn shutdown(&self) {
2153        self.inner.shutdown()
2154    }
2155
2156    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2157        self.inner.shutdown_with_epitaph(status)
2158    }
2159
2160    fn is_closed(&self) -> bool {
2161        self.inner.channel().is_closed()
2162    }
2163    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2164        self.inner.channel().on_closed()
2165    }
2166
2167    #[cfg(target_os = "fuchsia")]
2168    fn signal_peer(
2169        &self,
2170        clear_mask: zx::Signals,
2171        set_mask: zx::Signals,
2172    ) -> Result<(), zx_status::Status> {
2173        use fidl::Peered;
2174        self.inner.channel().signal_peer(clear_mask, set_mask)
2175    }
2176}
2177
2178impl DeviceControlHandle {}
2179
2180#[must_use = "FIDL methods require a response to be sent"]
2181#[derive(Debug)]
2182pub struct DeviceDownloadFirmwareResponder {
2183    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2184    tx_id: u32,
2185}
2186
2187/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2188/// if the responder is dropped without sending a response, so that the client
2189/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2190impl std::ops::Drop for DeviceDownloadFirmwareResponder {
2191    fn drop(&mut self) {
2192        self.control_handle.shutdown();
2193        // Safety: drops once, never accessed again
2194        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2195    }
2196}
2197
2198impl fidl::endpoints::Responder for DeviceDownloadFirmwareResponder {
2199    type ControlHandle = DeviceControlHandle;
2200
2201    fn control_handle(&self) -> &DeviceControlHandle {
2202        &self.control_handle
2203    }
2204
2205    fn drop_without_shutdown(mut self) {
2206        // Safety: drops once, never accessed again due to mem::forget
2207        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2208        // Prevent Drop from running (which would shut down the channel)
2209        std::mem::forget(self);
2210    }
2211}
2212
2213impl DeviceDownloadFirmwareResponder {
2214    /// Sends a response to the FIDL transaction.
2215    ///
2216    /// Sets the channel to shutdown if an error occurs.
2217    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2218        let _result = self.send_raw(result);
2219        if _result.is_err() {
2220            self.control_handle.shutdown();
2221        }
2222        self.drop_without_shutdown();
2223        _result
2224    }
2225
2226    /// Similar to "send" but does not shutdown the channel if an error occurs.
2227    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2228        let _result = self.send_raw(result);
2229        self.drop_without_shutdown();
2230        _result
2231    }
2232
2233    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2234        self.control_handle
2235            .inner
2236            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2237                result,
2238                self.tx_id,
2239                0x7bba8137e24661e5,
2240                fidl::encoding::DynamicFlags::empty(),
2241            )
2242    }
2243}
2244
2245#[must_use = "FIDL methods require a response to be sent"]
2246#[derive(Debug)]
2247pub struct DeviceGetFirmwareNameResponder {
2248    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2249    tx_id: u32,
2250}
2251
2252/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2253/// if the responder is dropped without sending a response, so that the client
2254/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2255impl std::ops::Drop for DeviceGetFirmwareNameResponder {
2256    fn drop(&mut self) {
2257        self.control_handle.shutdown();
2258        // Safety: drops once, never accessed again
2259        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2260    }
2261}
2262
2263impl fidl::endpoints::Responder for DeviceGetFirmwareNameResponder {
2264    type ControlHandle = DeviceControlHandle;
2265
2266    fn control_handle(&self) -> &DeviceControlHandle {
2267        &self.control_handle
2268    }
2269
2270    fn drop_without_shutdown(mut self) {
2271        // Safety: drops once, never accessed again due to mem::forget
2272        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2273        // Prevent Drop from running (which would shut down the channel)
2274        std::mem::forget(self);
2275    }
2276}
2277
2278impl DeviceGetFirmwareNameResponder {
2279    /// Sends a response to the FIDL transaction.
2280    ///
2281    /// Sets the channel to shutdown if an error occurs.
2282    pub fn send(self, mut firmware_name: &str) -> Result<(), fidl::Error> {
2283        let _result = self.send_raw(firmware_name);
2284        if _result.is_err() {
2285            self.control_handle.shutdown();
2286        }
2287        self.drop_without_shutdown();
2288        _result
2289    }
2290
2291    /// Similar to "send" but does not shutdown the channel if an error occurs.
2292    pub fn send_no_shutdown_on_err(self, mut firmware_name: &str) -> Result<(), fidl::Error> {
2293        let _result = self.send_raw(firmware_name);
2294        self.drop_without_shutdown();
2295        _result
2296    }
2297
2298    fn send_raw(&self, mut firmware_name: &str) -> Result<(), fidl::Error> {
2299        self.control_handle.inner.send::<DeviceGetFirmwareNameResponse>(
2300            (firmware_name,),
2301            self.tx_id,
2302            0x1649434b5e5bcb8d,
2303            fidl::encoding::DynamicFlags::empty(),
2304        )
2305    }
2306}
2307
2308#[must_use = "FIDL methods require a response to be sent"]
2309#[derive(Debug)]
2310pub struct DeviceGetFirmwareVersionResponder {
2311    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2312    tx_id: u32,
2313}
2314
2315/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2316/// if the responder is dropped without sending a response, so that the client
2317/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2318impl std::ops::Drop for DeviceGetFirmwareVersionResponder {
2319    fn drop(&mut self) {
2320        self.control_handle.shutdown();
2321        // Safety: drops once, never accessed again
2322        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2323    }
2324}
2325
2326impl fidl::endpoints::Responder for DeviceGetFirmwareVersionResponder {
2327    type ControlHandle = DeviceControlHandle;
2328
2329    fn control_handle(&self) -> &DeviceControlHandle {
2330        &self.control_handle
2331    }
2332
2333    fn drop_without_shutdown(mut self) {
2334        // Safety: drops once, never accessed again due to mem::forget
2335        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2336        // Prevent Drop from running (which would shut down the channel)
2337        std::mem::forget(self);
2338    }
2339}
2340
2341impl DeviceGetFirmwareVersionResponder {
2342    /// Sends a response to the FIDL transaction.
2343    ///
2344    /// Sets the channel to shutdown if an error occurs.
2345    pub fn send(self, mut version_info: &McuVersionInfo) -> Result<(), fidl::Error> {
2346        let _result = self.send_raw(version_info);
2347        if _result.is_err() {
2348            self.control_handle.shutdown();
2349        }
2350        self.drop_without_shutdown();
2351        _result
2352    }
2353
2354    /// Similar to "send" but does not shutdown the channel if an error occurs.
2355    pub fn send_no_shutdown_on_err(
2356        self,
2357        mut version_info: &McuVersionInfo,
2358    ) -> Result<(), fidl::Error> {
2359        let _result = self.send_raw(version_info);
2360        self.drop_without_shutdown();
2361        _result
2362    }
2363
2364    fn send_raw(&self, mut version_info: &McuVersionInfo) -> Result<(), fidl::Error> {
2365        self.control_handle.inner.send::<DeviceGetFirmwareVersionResponse>(
2366            (version_info,),
2367            self.tx_id,
2368            0x4f0599abcc95736b,
2369            fidl::encoding::DynamicFlags::empty(),
2370        )
2371    }
2372}
2373
2374#[must_use = "FIDL methods require a response to be sent"]
2375#[derive(Debug)]
2376pub struct DeviceGetTimeSyncResponder {
2377    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2378    tx_id: u32,
2379}
2380
2381/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2382/// if the responder is dropped without sending a response, so that the client
2383/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2384impl std::ops::Drop for DeviceGetTimeSyncResponder {
2385    fn drop(&mut self) {
2386        self.control_handle.shutdown();
2387        // Safety: drops once, never accessed again
2388        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2389    }
2390}
2391
2392impl fidl::endpoints::Responder for DeviceGetTimeSyncResponder {
2393    type ControlHandle = DeviceControlHandle;
2394
2395    fn control_handle(&self) -> &DeviceControlHandle {
2396        &self.control_handle
2397    }
2398
2399    fn drop_without_shutdown(mut self) {
2400        // Safety: drops once, never accessed again due to mem::forget
2401        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2402        // Prevent Drop from running (which would shut down the channel)
2403        std::mem::forget(self);
2404    }
2405}
2406
2407impl DeviceGetTimeSyncResponder {
2408    /// Sends a response to the FIDL transaction.
2409    ///
2410    /// Sets the channel to shutdown if an error occurs.
2411    pub fn send(self, mut result: Result<&McuTimeSyncInfo, i32>) -> Result<(), fidl::Error> {
2412        let _result = self.send_raw(result);
2413        if _result.is_err() {
2414            self.control_handle.shutdown();
2415        }
2416        self.drop_without_shutdown();
2417        _result
2418    }
2419
2420    /// Similar to "send" but does not shutdown the channel if an error occurs.
2421    pub fn send_no_shutdown_on_err(
2422        self,
2423        mut result: Result<&McuTimeSyncInfo, i32>,
2424    ) -> Result<(), fidl::Error> {
2425        let _result = self.send_raw(result);
2426        self.drop_without_shutdown();
2427        _result
2428    }
2429
2430    fn send_raw(&self, mut result: Result<&McuTimeSyncInfo, i32>) -> Result<(), fidl::Error> {
2431        self.control_handle.inner.send::<fidl::encoding::ResultType<McuTimeSyncInfo, i32>>(
2432            result,
2433            self.tx_id,
2434            0x4406991222e3975d,
2435            fidl::encoding::DynamicFlags::empty(),
2436        )
2437    }
2438}
2439
2440#[must_use = "FIDL methods require a response to be sent"]
2441#[derive(Debug)]
2442pub struct DeviceSetWakeLockResponder {
2443    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2444    tx_id: u32,
2445}
2446
2447/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2448/// if the responder is dropped without sending a response, so that the client
2449/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2450impl std::ops::Drop for DeviceSetWakeLockResponder {
2451    fn drop(&mut self) {
2452        self.control_handle.shutdown();
2453        // Safety: drops once, never accessed again
2454        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2455    }
2456}
2457
2458impl fidl::endpoints::Responder for DeviceSetWakeLockResponder {
2459    type ControlHandle = DeviceControlHandle;
2460
2461    fn control_handle(&self) -> &DeviceControlHandle {
2462        &self.control_handle
2463    }
2464
2465    fn drop_without_shutdown(mut self) {
2466        // Safety: drops once, never accessed again due to mem::forget
2467        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2468        // Prevent Drop from running (which would shut down the channel)
2469        std::mem::forget(self);
2470    }
2471}
2472
2473impl DeviceSetWakeLockResponder {
2474    /// Sends a response to the FIDL transaction.
2475    ///
2476    /// Sets the channel to shutdown if an error occurs.
2477    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2478        let _result = self.send_raw(result);
2479        if _result.is_err() {
2480            self.control_handle.shutdown();
2481        }
2482        self.drop_without_shutdown();
2483        _result
2484    }
2485
2486    /// Similar to "send" but does not shutdown the channel if an error occurs.
2487    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2488        let _result = self.send_raw(result);
2489        self.drop_without_shutdown();
2490        _result
2491    }
2492
2493    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2494        self.control_handle
2495            .inner
2496            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2497                result,
2498                self.tx_id,
2499                0x9f83f614affa1dc,
2500                fidl::encoding::DynamicFlags::empty(),
2501            )
2502    }
2503}
2504
2505#[must_use = "FIDL methods require a response to be sent"]
2506#[derive(Debug)]
2507pub struct DeviceGetWakeUpEventDurationResponder {
2508    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2509    tx_id: u32,
2510}
2511
2512/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2513/// if the responder is dropped without sending a response, so that the client
2514/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2515impl std::ops::Drop for DeviceGetWakeUpEventDurationResponder {
2516    fn drop(&mut self) {
2517        self.control_handle.shutdown();
2518        // Safety: drops once, never accessed again
2519        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2520    }
2521}
2522
2523impl fidl::endpoints::Responder for DeviceGetWakeUpEventDurationResponder {
2524    type ControlHandle = DeviceControlHandle;
2525
2526    fn control_handle(&self) -> &DeviceControlHandle {
2527        &self.control_handle
2528    }
2529
2530    fn drop_without_shutdown(mut self) {
2531        // Safety: drops once, never accessed again due to mem::forget
2532        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2533        // Prevent Drop from running (which would shut down the channel)
2534        std::mem::forget(self);
2535    }
2536}
2537
2538impl DeviceGetWakeUpEventDurationResponder {
2539    /// Sends a response to the FIDL transaction.
2540    ///
2541    /// Sets the channel to shutdown if an error occurs.
2542    pub fn send(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
2543        let _result = self.send_raw(result);
2544        if _result.is_err() {
2545            self.control_handle.shutdown();
2546        }
2547        self.drop_without_shutdown();
2548        _result
2549    }
2550
2551    /// Similar to "send" but does not shutdown the channel if an error occurs.
2552    pub fn send_no_shutdown_on_err(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
2553        let _result = self.send_raw(result);
2554        self.drop_without_shutdown();
2555        _result
2556    }
2557
2558    fn send_raw(&self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
2559        self.control_handle.inner.send::<fidl::encoding::ResultType<
2560            DeviceGetWakeUpEventDurationResponse,
2561            i32,
2562        >>(
2563            result.map(|duration| (duration,)),
2564            self.tx_id,
2565            0x45c79749f65e7176,
2566            fidl::encoding::DynamicFlags::empty(),
2567        )
2568    }
2569}
2570
2571#[must_use = "FIDL methods require a response to be sent"]
2572#[derive(Debug)]
2573pub struct DeviceSetWakeUpEventDurationResponder {
2574    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2575    tx_id: u32,
2576}
2577
2578/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2579/// if the responder is dropped without sending a response, so that the client
2580/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2581impl std::ops::Drop for DeviceSetWakeUpEventDurationResponder {
2582    fn drop(&mut self) {
2583        self.control_handle.shutdown();
2584        // Safety: drops once, never accessed again
2585        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2586    }
2587}
2588
2589impl fidl::endpoints::Responder for DeviceSetWakeUpEventDurationResponder {
2590    type ControlHandle = DeviceControlHandle;
2591
2592    fn control_handle(&self) -> &DeviceControlHandle {
2593        &self.control_handle
2594    }
2595
2596    fn drop_without_shutdown(mut self) {
2597        // Safety: drops once, never accessed again due to mem::forget
2598        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2599        // Prevent Drop from running (which would shut down the channel)
2600        std::mem::forget(self);
2601    }
2602}
2603
2604impl DeviceSetWakeUpEventDurationResponder {
2605    /// Sends a response to the FIDL transaction.
2606    ///
2607    /// Sets the channel to shutdown if an error occurs.
2608    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2609        let _result = self.send_raw(result);
2610        if _result.is_err() {
2611            self.control_handle.shutdown();
2612        }
2613        self.drop_without_shutdown();
2614        _result
2615    }
2616
2617    /// Similar to "send" but does not shutdown the channel if an error occurs.
2618    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2619        let _result = self.send_raw(result);
2620        self.drop_without_shutdown();
2621        _result
2622    }
2623
2624    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2625        self.control_handle
2626            .inner
2627            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2628                result,
2629                self.tx_id,
2630                0x1fa1771ffa5f570,
2631                fidl::encoding::DynamicFlags::empty(),
2632            )
2633    }
2634}
2635
2636#[must_use = "FIDL methods require a response to be sent"]
2637#[derive(Debug)]
2638pub struct DeviceHardwareResetResponder {
2639    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2640    tx_id: u32,
2641}
2642
2643/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2644/// if the responder is dropped without sending a response, so that the client
2645/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2646impl std::ops::Drop for DeviceHardwareResetResponder {
2647    fn drop(&mut self) {
2648        self.control_handle.shutdown();
2649        // Safety: drops once, never accessed again
2650        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2651    }
2652}
2653
2654impl fidl::endpoints::Responder for DeviceHardwareResetResponder {
2655    type ControlHandle = DeviceControlHandle;
2656
2657    fn control_handle(&self) -> &DeviceControlHandle {
2658        &self.control_handle
2659    }
2660
2661    fn drop_without_shutdown(mut self) {
2662        // Safety: drops once, never accessed again due to mem::forget
2663        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2664        // Prevent Drop from running (which would shut down the channel)
2665        std::mem::forget(self);
2666    }
2667}
2668
2669impl DeviceHardwareResetResponder {
2670    /// Sends a response to the FIDL transaction.
2671    ///
2672    /// Sets the channel to shutdown if an error occurs.
2673    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2674        let _result = self.send_raw(result);
2675        if _result.is_err() {
2676            self.control_handle.shutdown();
2677        }
2678        self.drop_without_shutdown();
2679        _result
2680    }
2681
2682    /// Similar to "send" but does not shutdown the channel if an error occurs.
2683    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2684        let _result = self.send_raw(result);
2685        self.drop_without_shutdown();
2686        _result
2687    }
2688
2689    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2690        self.control_handle
2691            .inner
2692            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2693                result,
2694                self.tx_id,
2695                0x78e3d2ded2f929f,
2696                fidl::encoding::DynamicFlags::empty(),
2697            )
2698    }
2699}
2700
2701#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2702pub struct DisplayDeviceMarker;
2703
2704impl fidl::endpoints::ProtocolMarker for DisplayDeviceMarker {
2705    type Proxy = DisplayDeviceProxy;
2706    type RequestStream = DisplayDeviceRequestStream;
2707    #[cfg(target_os = "fuchsia")]
2708    type SynchronousProxy = DisplayDeviceSynchronousProxy;
2709
2710    const DEBUG_NAME: &'static str = "fuchsia.hardware.google.nanohub.DisplayDevice";
2711}
2712impl fidl::endpoints::DiscoverableProtocolMarker for DisplayDeviceMarker {}
2713pub type DisplayDeviceGetDisplayStateResult = Result<DisplayState, i32>;
2714pub type DisplayDeviceGetDisplayInfoResult = Result<DisplaySyncInfo, i32>;
2715pub type DisplayDeviceGetDisplaySelectResult = Result<DisplayDeviceGetDisplaySelectResponse, i32>;
2716pub type DisplayDeviceSetDisplaySelectResult = Result<(), i32>;
2717
2718pub trait DisplayDeviceProxyInterface: Send + Sync {
2719    type GetDisplayStateResponseFut: std::future::Future<Output = Result<DisplayDeviceGetDisplayStateResult, fidl::Error>>
2720        + Send;
2721    fn r#get_display_state(&self) -> Self::GetDisplayStateResponseFut;
2722    type GetDisplayInfoResponseFut: std::future::Future<Output = Result<DisplayDeviceGetDisplayInfoResult, fidl::Error>>
2723        + Send;
2724    fn r#get_display_info(&self) -> Self::GetDisplayInfoResponseFut;
2725    type GetDisplaySelectResponseFut: std::future::Future<Output = Result<DisplayDeviceGetDisplaySelectResult, fidl::Error>>
2726        + Send;
2727    fn r#get_display_select(&self) -> Self::GetDisplaySelectResponseFut;
2728    type SetDisplaySelectResponseFut: std::future::Future<Output = Result<DisplayDeviceSetDisplaySelectResult, fidl::Error>>
2729        + Send;
2730    fn r#set_display_select(
2731        &self,
2732        payload: &DisplayDeviceSetDisplaySelectRequest,
2733    ) -> Self::SetDisplaySelectResponseFut;
2734}
2735#[derive(Debug)]
2736#[cfg(target_os = "fuchsia")]
2737pub struct DisplayDeviceSynchronousProxy {
2738    client: fidl::client::sync::Client,
2739}
2740
2741#[cfg(target_os = "fuchsia")]
2742impl fidl::endpoints::SynchronousProxy for DisplayDeviceSynchronousProxy {
2743    type Proxy = DisplayDeviceProxy;
2744    type Protocol = DisplayDeviceMarker;
2745
2746    fn from_channel(inner: fidl::Channel) -> Self {
2747        Self::new(inner)
2748    }
2749
2750    fn into_channel(self) -> fidl::Channel {
2751        self.client.into_channel()
2752    }
2753
2754    fn as_channel(&self) -> &fidl::Channel {
2755        self.client.as_channel()
2756    }
2757}
2758
2759#[cfg(target_os = "fuchsia")]
2760impl DisplayDeviceSynchronousProxy {
2761    pub fn new(channel: fidl::Channel) -> Self {
2762        Self { client: fidl::client::sync::Client::new(channel) }
2763    }
2764
2765    pub fn into_channel(self) -> fidl::Channel {
2766        self.client.into_channel()
2767    }
2768
2769    /// Waits until an event arrives and returns it. It is safe for other
2770    /// threads to make concurrent requests while waiting for an event.
2771    pub fn wait_for_event(
2772        &self,
2773        deadline: zx::MonotonicInstant,
2774    ) -> Result<DisplayDeviceEvent, fidl::Error> {
2775        DisplayDeviceEvent::decode(self.client.wait_for_event::<DisplayDeviceMarker>(deadline)?)
2776    }
2777
2778    /// Gets the current state of the display.
2779    pub fn r#get_display_state(
2780        &self,
2781        ___deadline: zx::MonotonicInstant,
2782    ) -> Result<DisplayDeviceGetDisplayStateResult, fidl::Error> {
2783        let _response = self.client.send_query::<
2784            fidl::encoding::EmptyPayload,
2785            fidl::encoding::ResultType<DisplayState, i32>,
2786            DisplayDeviceMarker,
2787        >(
2788            (),
2789            0x1648924f6e003444,
2790            fidl::encoding::DynamicFlags::empty(),
2791            ___deadline,
2792        )?;
2793        Ok(_response.map(|x| x))
2794    }
2795
2796    /// Gets synchronization information for the display. This can include
2797    /// the display's mode, panel mode, and brightness levels.
2798    pub fn r#get_display_info(
2799        &self,
2800        ___deadline: zx::MonotonicInstant,
2801    ) -> Result<DisplayDeviceGetDisplayInfoResult, fidl::Error> {
2802        let _response = self.client.send_query::<
2803            fidl::encoding::EmptyPayload,
2804            fidl::encoding::ResultType<DisplaySyncInfo, i32>,
2805            DisplayDeviceMarker,
2806        >(
2807            (),
2808            0x311c8e4cb6b1b4d1,
2809            fidl::encoding::DynamicFlags::empty(),
2810            ___deadline,
2811        )?;
2812        Ok(_response.map(|x| x))
2813    }
2814
2815    /// Gets the current display owner, which is either the AP (Application
2816    /// Processor) or the MCU (Microcontroller Unit).
2817    pub fn r#get_display_select(
2818        &self,
2819        ___deadline: zx::MonotonicInstant,
2820    ) -> Result<DisplayDeviceGetDisplaySelectResult, fidl::Error> {
2821        let _response = self.client.send_query::<
2822            fidl::encoding::EmptyPayload,
2823            fidl::encoding::ResultType<DisplayDeviceGetDisplaySelectResponse, i32>,
2824            DisplayDeviceMarker,
2825        >(
2826            (),
2827            0x6191c86cffd6323,
2828            fidl::encoding::DynamicFlags::empty(),
2829            ___deadline,
2830        )?;
2831        Ok(_response.map(|x| x))
2832    }
2833
2834    /// Sets the display owner to be either the AP (Application Processor) or
2835    /// the MCU (Microcontroller Unit).
2836    pub fn r#set_display_select(
2837        &self,
2838        mut payload: &DisplayDeviceSetDisplaySelectRequest,
2839        ___deadline: zx::MonotonicInstant,
2840    ) -> Result<DisplayDeviceSetDisplaySelectResult, fidl::Error> {
2841        let _response = self.client.send_query::<
2842            DisplayDeviceSetDisplaySelectRequest,
2843            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2844            DisplayDeviceMarker,
2845        >(
2846            payload,
2847            0x2b07f6ba12e7a412,
2848            fidl::encoding::DynamicFlags::empty(),
2849            ___deadline,
2850        )?;
2851        Ok(_response.map(|x| x))
2852    }
2853}
2854
2855#[cfg(target_os = "fuchsia")]
2856impl From<DisplayDeviceSynchronousProxy> for zx::NullableHandle {
2857    fn from(value: DisplayDeviceSynchronousProxy) -> Self {
2858        value.into_channel().into()
2859    }
2860}
2861
2862#[cfg(target_os = "fuchsia")]
2863impl From<fidl::Channel> for DisplayDeviceSynchronousProxy {
2864    fn from(value: fidl::Channel) -> Self {
2865        Self::new(value)
2866    }
2867}
2868
2869#[cfg(target_os = "fuchsia")]
2870impl fidl::endpoints::FromClient for DisplayDeviceSynchronousProxy {
2871    type Protocol = DisplayDeviceMarker;
2872
2873    fn from_client(value: fidl::endpoints::ClientEnd<DisplayDeviceMarker>) -> Self {
2874        Self::new(value.into_channel())
2875    }
2876}
2877
2878#[derive(Debug, Clone)]
2879pub struct DisplayDeviceProxy {
2880    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2881}
2882
2883impl fidl::endpoints::Proxy for DisplayDeviceProxy {
2884    type Protocol = DisplayDeviceMarker;
2885
2886    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2887        Self::new(inner)
2888    }
2889
2890    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2891        self.client.into_channel().map_err(|client| Self { client })
2892    }
2893
2894    fn as_channel(&self) -> &::fidl::AsyncChannel {
2895        self.client.as_channel()
2896    }
2897}
2898
2899impl DisplayDeviceProxy {
2900    /// Create a new Proxy for fuchsia.hardware.google.nanohub/DisplayDevice.
2901    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2902        let protocol_name = <DisplayDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2903        Self { client: fidl::client::Client::new(channel, protocol_name) }
2904    }
2905
2906    /// Get a Stream of events from the remote end of the protocol.
2907    ///
2908    /// # Panics
2909    ///
2910    /// Panics if the event stream was already taken.
2911    pub fn take_event_stream(&self) -> DisplayDeviceEventStream {
2912        DisplayDeviceEventStream { event_receiver: self.client.take_event_receiver() }
2913    }
2914
2915    /// Gets the current state of the display.
2916    pub fn r#get_display_state(
2917        &self,
2918    ) -> fidl::client::QueryResponseFut<
2919        DisplayDeviceGetDisplayStateResult,
2920        fidl::encoding::DefaultFuchsiaResourceDialect,
2921    > {
2922        DisplayDeviceProxyInterface::r#get_display_state(self)
2923    }
2924
2925    /// Gets synchronization information for the display. This can include
2926    /// the display's mode, panel mode, and brightness levels.
2927    pub fn r#get_display_info(
2928        &self,
2929    ) -> fidl::client::QueryResponseFut<
2930        DisplayDeviceGetDisplayInfoResult,
2931        fidl::encoding::DefaultFuchsiaResourceDialect,
2932    > {
2933        DisplayDeviceProxyInterface::r#get_display_info(self)
2934    }
2935
2936    /// Gets the current display owner, which is either the AP (Application
2937    /// Processor) or the MCU (Microcontroller Unit).
2938    pub fn r#get_display_select(
2939        &self,
2940    ) -> fidl::client::QueryResponseFut<
2941        DisplayDeviceGetDisplaySelectResult,
2942        fidl::encoding::DefaultFuchsiaResourceDialect,
2943    > {
2944        DisplayDeviceProxyInterface::r#get_display_select(self)
2945    }
2946
2947    /// Sets the display owner to be either the AP (Application Processor) or
2948    /// the MCU (Microcontroller Unit).
2949    pub fn r#set_display_select(
2950        &self,
2951        mut payload: &DisplayDeviceSetDisplaySelectRequest,
2952    ) -> fidl::client::QueryResponseFut<
2953        DisplayDeviceSetDisplaySelectResult,
2954        fidl::encoding::DefaultFuchsiaResourceDialect,
2955    > {
2956        DisplayDeviceProxyInterface::r#set_display_select(self, payload)
2957    }
2958}
2959
2960impl DisplayDeviceProxyInterface for DisplayDeviceProxy {
2961    type GetDisplayStateResponseFut = fidl::client::QueryResponseFut<
2962        DisplayDeviceGetDisplayStateResult,
2963        fidl::encoding::DefaultFuchsiaResourceDialect,
2964    >;
2965    fn r#get_display_state(&self) -> Self::GetDisplayStateResponseFut {
2966        fn _decode(
2967            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2968        ) -> Result<DisplayDeviceGetDisplayStateResult, fidl::Error> {
2969            let _response = fidl::client::decode_transaction_body::<
2970                fidl::encoding::ResultType<DisplayState, i32>,
2971                fidl::encoding::DefaultFuchsiaResourceDialect,
2972                0x1648924f6e003444,
2973            >(_buf?)?;
2974            Ok(_response.map(|x| x))
2975        }
2976        self.client.send_query_and_decode::<
2977            fidl::encoding::EmptyPayload,
2978            DisplayDeviceGetDisplayStateResult,
2979        >(
2980            (),
2981            0x1648924f6e003444,
2982            fidl::encoding::DynamicFlags::empty(),
2983            _decode,
2984        )
2985    }
2986
2987    type GetDisplayInfoResponseFut = fidl::client::QueryResponseFut<
2988        DisplayDeviceGetDisplayInfoResult,
2989        fidl::encoding::DefaultFuchsiaResourceDialect,
2990    >;
2991    fn r#get_display_info(&self) -> Self::GetDisplayInfoResponseFut {
2992        fn _decode(
2993            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2994        ) -> Result<DisplayDeviceGetDisplayInfoResult, fidl::Error> {
2995            let _response = fidl::client::decode_transaction_body::<
2996                fidl::encoding::ResultType<DisplaySyncInfo, i32>,
2997                fidl::encoding::DefaultFuchsiaResourceDialect,
2998                0x311c8e4cb6b1b4d1,
2999            >(_buf?)?;
3000            Ok(_response.map(|x| x))
3001        }
3002        self.client.send_query_and_decode::<
3003            fidl::encoding::EmptyPayload,
3004            DisplayDeviceGetDisplayInfoResult,
3005        >(
3006            (),
3007            0x311c8e4cb6b1b4d1,
3008            fidl::encoding::DynamicFlags::empty(),
3009            _decode,
3010        )
3011    }
3012
3013    type GetDisplaySelectResponseFut = fidl::client::QueryResponseFut<
3014        DisplayDeviceGetDisplaySelectResult,
3015        fidl::encoding::DefaultFuchsiaResourceDialect,
3016    >;
3017    fn r#get_display_select(&self) -> Self::GetDisplaySelectResponseFut {
3018        fn _decode(
3019            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3020        ) -> Result<DisplayDeviceGetDisplaySelectResult, fidl::Error> {
3021            let _response = fidl::client::decode_transaction_body::<
3022                fidl::encoding::ResultType<DisplayDeviceGetDisplaySelectResponse, i32>,
3023                fidl::encoding::DefaultFuchsiaResourceDialect,
3024                0x6191c86cffd6323,
3025            >(_buf?)?;
3026            Ok(_response.map(|x| x))
3027        }
3028        self.client.send_query_and_decode::<
3029            fidl::encoding::EmptyPayload,
3030            DisplayDeviceGetDisplaySelectResult,
3031        >(
3032            (),
3033            0x6191c86cffd6323,
3034            fidl::encoding::DynamicFlags::empty(),
3035            _decode,
3036        )
3037    }
3038
3039    type SetDisplaySelectResponseFut = fidl::client::QueryResponseFut<
3040        DisplayDeviceSetDisplaySelectResult,
3041        fidl::encoding::DefaultFuchsiaResourceDialect,
3042    >;
3043    fn r#set_display_select(
3044        &self,
3045        mut payload: &DisplayDeviceSetDisplaySelectRequest,
3046    ) -> Self::SetDisplaySelectResponseFut {
3047        fn _decode(
3048            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3049        ) -> Result<DisplayDeviceSetDisplaySelectResult, fidl::Error> {
3050            let _response = fidl::client::decode_transaction_body::<
3051                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3052                fidl::encoding::DefaultFuchsiaResourceDialect,
3053                0x2b07f6ba12e7a412,
3054            >(_buf?)?;
3055            Ok(_response.map(|x| x))
3056        }
3057        self.client.send_query_and_decode::<
3058            DisplayDeviceSetDisplaySelectRequest,
3059            DisplayDeviceSetDisplaySelectResult,
3060        >(
3061            payload,
3062            0x2b07f6ba12e7a412,
3063            fidl::encoding::DynamicFlags::empty(),
3064            _decode,
3065        )
3066    }
3067}
3068
3069pub struct DisplayDeviceEventStream {
3070    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3071}
3072
3073impl std::marker::Unpin for DisplayDeviceEventStream {}
3074
3075impl futures::stream::FusedStream for DisplayDeviceEventStream {
3076    fn is_terminated(&self) -> bool {
3077        self.event_receiver.is_terminated()
3078    }
3079}
3080
3081impl futures::Stream for DisplayDeviceEventStream {
3082    type Item = Result<DisplayDeviceEvent, fidl::Error>;
3083
3084    fn poll_next(
3085        mut self: std::pin::Pin<&mut Self>,
3086        cx: &mut std::task::Context<'_>,
3087    ) -> std::task::Poll<Option<Self::Item>> {
3088        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3089            &mut self.event_receiver,
3090            cx
3091        )?) {
3092            Some(buf) => std::task::Poll::Ready(Some(DisplayDeviceEvent::decode(buf))),
3093            None => std::task::Poll::Ready(None),
3094        }
3095    }
3096}
3097
3098#[derive(Debug)]
3099pub enum DisplayDeviceEvent {}
3100
3101impl DisplayDeviceEvent {
3102    /// Decodes a message buffer as a [`DisplayDeviceEvent`].
3103    fn decode(
3104        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3105    ) -> Result<DisplayDeviceEvent, fidl::Error> {
3106        let (bytes, _handles) = buf.split_mut();
3107        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3108        debug_assert_eq!(tx_header.tx_id, 0);
3109        match tx_header.ordinal {
3110            _ => Err(fidl::Error::UnknownOrdinal {
3111                ordinal: tx_header.ordinal,
3112                protocol_name: <DisplayDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3113            }),
3114        }
3115    }
3116}
3117
3118/// A Stream of incoming requests for fuchsia.hardware.google.nanohub/DisplayDevice.
3119pub struct DisplayDeviceRequestStream {
3120    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3121    is_terminated: bool,
3122}
3123
3124impl std::marker::Unpin for DisplayDeviceRequestStream {}
3125
3126impl futures::stream::FusedStream for DisplayDeviceRequestStream {
3127    fn is_terminated(&self) -> bool {
3128        self.is_terminated
3129    }
3130}
3131
3132impl fidl::endpoints::RequestStream for DisplayDeviceRequestStream {
3133    type Protocol = DisplayDeviceMarker;
3134    type ControlHandle = DisplayDeviceControlHandle;
3135
3136    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3137        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3138    }
3139
3140    fn control_handle(&self) -> Self::ControlHandle {
3141        DisplayDeviceControlHandle { inner: self.inner.clone() }
3142    }
3143
3144    fn into_inner(
3145        self,
3146    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3147    {
3148        (self.inner, self.is_terminated)
3149    }
3150
3151    fn from_inner(
3152        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3153        is_terminated: bool,
3154    ) -> Self {
3155        Self { inner, is_terminated }
3156    }
3157}
3158
3159impl futures::Stream for DisplayDeviceRequestStream {
3160    type Item = Result<DisplayDeviceRequest, fidl::Error>;
3161
3162    fn poll_next(
3163        mut self: std::pin::Pin<&mut Self>,
3164        cx: &mut std::task::Context<'_>,
3165    ) -> std::task::Poll<Option<Self::Item>> {
3166        let this = &mut *self;
3167        if this.inner.check_shutdown(cx) {
3168            this.is_terminated = true;
3169            return std::task::Poll::Ready(None);
3170        }
3171        if this.is_terminated {
3172            panic!("polled DisplayDeviceRequestStream after completion");
3173        }
3174        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3175            |bytes, handles| {
3176                match this.inner.channel().read_etc(cx, bytes, handles) {
3177                    std::task::Poll::Ready(Ok(())) => {}
3178                    std::task::Poll::Pending => return std::task::Poll::Pending,
3179                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3180                        this.is_terminated = true;
3181                        return std::task::Poll::Ready(None);
3182                    }
3183                    std::task::Poll::Ready(Err(e)) => {
3184                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3185                            e.into(),
3186                        ))));
3187                    }
3188                }
3189
3190                // A message has been received from the channel
3191                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3192
3193                std::task::Poll::Ready(Some(match header.ordinal {
3194                    0x1648924f6e003444 => {
3195                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3196                        let mut req = fidl::new_empty!(
3197                            fidl::encoding::EmptyPayload,
3198                            fidl::encoding::DefaultFuchsiaResourceDialect
3199                        );
3200                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3201                        let control_handle =
3202                            DisplayDeviceControlHandle { inner: this.inner.clone() };
3203                        Ok(DisplayDeviceRequest::GetDisplayState {
3204                            responder: DisplayDeviceGetDisplayStateResponder {
3205                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3206                                tx_id: header.tx_id,
3207                            },
3208                        })
3209                    }
3210                    0x311c8e4cb6b1b4d1 => {
3211                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3212                        let mut req = fidl::new_empty!(
3213                            fidl::encoding::EmptyPayload,
3214                            fidl::encoding::DefaultFuchsiaResourceDialect
3215                        );
3216                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3217                        let control_handle =
3218                            DisplayDeviceControlHandle { inner: this.inner.clone() };
3219                        Ok(DisplayDeviceRequest::GetDisplayInfo {
3220                            responder: DisplayDeviceGetDisplayInfoResponder {
3221                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3222                                tx_id: header.tx_id,
3223                            },
3224                        })
3225                    }
3226                    0x6191c86cffd6323 => {
3227                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3228                        let mut req = fidl::new_empty!(
3229                            fidl::encoding::EmptyPayload,
3230                            fidl::encoding::DefaultFuchsiaResourceDialect
3231                        );
3232                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3233                        let control_handle =
3234                            DisplayDeviceControlHandle { inner: this.inner.clone() };
3235                        Ok(DisplayDeviceRequest::GetDisplaySelect {
3236                            responder: DisplayDeviceGetDisplaySelectResponder {
3237                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3238                                tx_id: header.tx_id,
3239                            },
3240                        })
3241                    }
3242                    0x2b07f6ba12e7a412 => {
3243                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3244                        let mut req = fidl::new_empty!(
3245                            DisplayDeviceSetDisplaySelectRequest,
3246                            fidl::encoding::DefaultFuchsiaResourceDialect
3247                        );
3248                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DisplayDeviceSetDisplaySelectRequest>(&header, _body_bytes, handles, &mut req)?;
3249                        let control_handle =
3250                            DisplayDeviceControlHandle { inner: this.inner.clone() };
3251                        Ok(DisplayDeviceRequest::SetDisplaySelect {
3252                            payload: req,
3253                            responder: DisplayDeviceSetDisplaySelectResponder {
3254                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3255                                tx_id: header.tx_id,
3256                            },
3257                        })
3258                    }
3259                    _ => Err(fidl::Error::UnknownOrdinal {
3260                        ordinal: header.ordinal,
3261                        protocol_name:
3262                            <DisplayDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3263                    }),
3264                }))
3265            },
3266        )
3267    }
3268}
3269
3270/// Protocol for interacting with the Google-specific display hardware.
3271#[derive(Debug)]
3272pub enum DisplayDeviceRequest {
3273    /// Gets the current state of the display.
3274    GetDisplayState { responder: DisplayDeviceGetDisplayStateResponder },
3275    /// Gets synchronization information for the display. This can include
3276    /// the display's mode, panel mode, and brightness levels.
3277    GetDisplayInfo { responder: DisplayDeviceGetDisplayInfoResponder },
3278    /// Gets the current display owner, which is either the AP (Application
3279    /// Processor) or the MCU (Microcontroller Unit).
3280    GetDisplaySelect { responder: DisplayDeviceGetDisplaySelectResponder },
3281    /// Sets the display owner to be either the AP (Application Processor) or
3282    /// the MCU (Microcontroller Unit).
3283    SetDisplaySelect {
3284        payload: DisplayDeviceSetDisplaySelectRequest,
3285        responder: DisplayDeviceSetDisplaySelectResponder,
3286    },
3287}
3288
3289impl DisplayDeviceRequest {
3290    #[allow(irrefutable_let_patterns)]
3291    pub fn into_get_display_state(self) -> Option<(DisplayDeviceGetDisplayStateResponder)> {
3292        if let DisplayDeviceRequest::GetDisplayState { responder } = self {
3293            Some((responder))
3294        } else {
3295            None
3296        }
3297    }
3298
3299    #[allow(irrefutable_let_patterns)]
3300    pub fn into_get_display_info(self) -> Option<(DisplayDeviceGetDisplayInfoResponder)> {
3301        if let DisplayDeviceRequest::GetDisplayInfo { responder } = self {
3302            Some((responder))
3303        } else {
3304            None
3305        }
3306    }
3307
3308    #[allow(irrefutable_let_patterns)]
3309    pub fn into_get_display_select(self) -> Option<(DisplayDeviceGetDisplaySelectResponder)> {
3310        if let DisplayDeviceRequest::GetDisplaySelect { responder } = self {
3311            Some((responder))
3312        } else {
3313            None
3314        }
3315    }
3316
3317    #[allow(irrefutable_let_patterns)]
3318    pub fn into_set_display_select(
3319        self,
3320    ) -> Option<(DisplayDeviceSetDisplaySelectRequest, DisplayDeviceSetDisplaySelectResponder)>
3321    {
3322        if let DisplayDeviceRequest::SetDisplaySelect { payload, responder } = self {
3323            Some((payload, responder))
3324        } else {
3325            None
3326        }
3327    }
3328
3329    /// Name of the method defined in FIDL
3330    pub fn method_name(&self) -> &'static str {
3331        match *self {
3332            DisplayDeviceRequest::GetDisplayState { .. } => "get_display_state",
3333            DisplayDeviceRequest::GetDisplayInfo { .. } => "get_display_info",
3334            DisplayDeviceRequest::GetDisplaySelect { .. } => "get_display_select",
3335            DisplayDeviceRequest::SetDisplaySelect { .. } => "set_display_select",
3336        }
3337    }
3338}
3339
3340#[derive(Debug, Clone)]
3341pub struct DisplayDeviceControlHandle {
3342    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3343}
3344
3345impl DisplayDeviceControlHandle {
3346    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3347        self.inner.shutdown_with_epitaph(status.into())
3348    }
3349}
3350
3351impl fidl::endpoints::ControlHandle for DisplayDeviceControlHandle {
3352    fn shutdown(&self) {
3353        self.inner.shutdown()
3354    }
3355
3356    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3357        self.inner.shutdown_with_epitaph(status)
3358    }
3359
3360    fn is_closed(&self) -> bool {
3361        self.inner.channel().is_closed()
3362    }
3363    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3364        self.inner.channel().on_closed()
3365    }
3366
3367    #[cfg(target_os = "fuchsia")]
3368    fn signal_peer(
3369        &self,
3370        clear_mask: zx::Signals,
3371        set_mask: zx::Signals,
3372    ) -> Result<(), zx_status::Status> {
3373        use fidl::Peered;
3374        self.inner.channel().signal_peer(clear_mask, set_mask)
3375    }
3376}
3377
3378impl DisplayDeviceControlHandle {}
3379
3380#[must_use = "FIDL methods require a response to be sent"]
3381#[derive(Debug)]
3382pub struct DisplayDeviceGetDisplayStateResponder {
3383    control_handle: std::mem::ManuallyDrop<DisplayDeviceControlHandle>,
3384    tx_id: u32,
3385}
3386
3387/// Set the the channel to be shutdown (see [`DisplayDeviceControlHandle::shutdown`])
3388/// if the responder is dropped without sending a response, so that the client
3389/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3390impl std::ops::Drop for DisplayDeviceGetDisplayStateResponder {
3391    fn drop(&mut self) {
3392        self.control_handle.shutdown();
3393        // Safety: drops once, never accessed again
3394        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3395    }
3396}
3397
3398impl fidl::endpoints::Responder for DisplayDeviceGetDisplayStateResponder {
3399    type ControlHandle = DisplayDeviceControlHandle;
3400
3401    fn control_handle(&self) -> &DisplayDeviceControlHandle {
3402        &self.control_handle
3403    }
3404
3405    fn drop_without_shutdown(mut self) {
3406        // Safety: drops once, never accessed again due to mem::forget
3407        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3408        // Prevent Drop from running (which would shut down the channel)
3409        std::mem::forget(self);
3410    }
3411}
3412
3413impl DisplayDeviceGetDisplayStateResponder {
3414    /// Sends a response to the FIDL transaction.
3415    ///
3416    /// Sets the channel to shutdown if an error occurs.
3417    pub fn send(self, mut result: Result<&DisplayState, i32>) -> Result<(), fidl::Error> {
3418        let _result = self.send_raw(result);
3419        if _result.is_err() {
3420            self.control_handle.shutdown();
3421        }
3422        self.drop_without_shutdown();
3423        _result
3424    }
3425
3426    /// Similar to "send" but does not shutdown the channel if an error occurs.
3427    pub fn send_no_shutdown_on_err(
3428        self,
3429        mut result: Result<&DisplayState, i32>,
3430    ) -> Result<(), fidl::Error> {
3431        let _result = self.send_raw(result);
3432        self.drop_without_shutdown();
3433        _result
3434    }
3435
3436    fn send_raw(&self, mut result: Result<&DisplayState, i32>) -> Result<(), fidl::Error> {
3437        self.control_handle.inner.send::<fidl::encoding::ResultType<DisplayState, i32>>(
3438            result,
3439            self.tx_id,
3440            0x1648924f6e003444,
3441            fidl::encoding::DynamicFlags::empty(),
3442        )
3443    }
3444}
3445
3446#[must_use = "FIDL methods require a response to be sent"]
3447#[derive(Debug)]
3448pub struct DisplayDeviceGetDisplayInfoResponder {
3449    control_handle: std::mem::ManuallyDrop<DisplayDeviceControlHandle>,
3450    tx_id: u32,
3451}
3452
3453/// Set the the channel to be shutdown (see [`DisplayDeviceControlHandle::shutdown`])
3454/// if the responder is dropped without sending a response, so that the client
3455/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3456impl std::ops::Drop for DisplayDeviceGetDisplayInfoResponder {
3457    fn drop(&mut self) {
3458        self.control_handle.shutdown();
3459        // Safety: drops once, never accessed again
3460        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3461    }
3462}
3463
3464impl fidl::endpoints::Responder for DisplayDeviceGetDisplayInfoResponder {
3465    type ControlHandle = DisplayDeviceControlHandle;
3466
3467    fn control_handle(&self) -> &DisplayDeviceControlHandle {
3468        &self.control_handle
3469    }
3470
3471    fn drop_without_shutdown(mut self) {
3472        // Safety: drops once, never accessed again due to mem::forget
3473        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3474        // Prevent Drop from running (which would shut down the channel)
3475        std::mem::forget(self);
3476    }
3477}
3478
3479impl DisplayDeviceGetDisplayInfoResponder {
3480    /// Sends a response to the FIDL transaction.
3481    ///
3482    /// Sets the channel to shutdown if an error occurs.
3483    pub fn send(self, mut result: Result<&DisplaySyncInfo, i32>) -> Result<(), fidl::Error> {
3484        let _result = self.send_raw(result);
3485        if _result.is_err() {
3486            self.control_handle.shutdown();
3487        }
3488        self.drop_without_shutdown();
3489        _result
3490    }
3491
3492    /// Similar to "send" but does not shutdown the channel if an error occurs.
3493    pub fn send_no_shutdown_on_err(
3494        self,
3495        mut result: Result<&DisplaySyncInfo, i32>,
3496    ) -> Result<(), fidl::Error> {
3497        let _result = self.send_raw(result);
3498        self.drop_without_shutdown();
3499        _result
3500    }
3501
3502    fn send_raw(&self, mut result: Result<&DisplaySyncInfo, i32>) -> Result<(), fidl::Error> {
3503        self.control_handle.inner.send::<fidl::encoding::ResultType<DisplaySyncInfo, i32>>(
3504            result,
3505            self.tx_id,
3506            0x311c8e4cb6b1b4d1,
3507            fidl::encoding::DynamicFlags::empty(),
3508        )
3509    }
3510}
3511
3512#[must_use = "FIDL methods require a response to be sent"]
3513#[derive(Debug)]
3514pub struct DisplayDeviceGetDisplaySelectResponder {
3515    control_handle: std::mem::ManuallyDrop<DisplayDeviceControlHandle>,
3516    tx_id: u32,
3517}
3518
3519/// Set the the channel to be shutdown (see [`DisplayDeviceControlHandle::shutdown`])
3520/// if the responder is dropped without sending a response, so that the client
3521/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3522impl std::ops::Drop for DisplayDeviceGetDisplaySelectResponder {
3523    fn drop(&mut self) {
3524        self.control_handle.shutdown();
3525        // Safety: drops once, never accessed again
3526        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3527    }
3528}
3529
3530impl fidl::endpoints::Responder for DisplayDeviceGetDisplaySelectResponder {
3531    type ControlHandle = DisplayDeviceControlHandle;
3532
3533    fn control_handle(&self) -> &DisplayDeviceControlHandle {
3534        &self.control_handle
3535    }
3536
3537    fn drop_without_shutdown(mut self) {
3538        // Safety: drops once, never accessed again due to mem::forget
3539        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3540        // Prevent Drop from running (which would shut down the channel)
3541        std::mem::forget(self);
3542    }
3543}
3544
3545impl DisplayDeviceGetDisplaySelectResponder {
3546    /// Sends a response to the FIDL transaction.
3547    ///
3548    /// Sets the channel to shutdown if an error occurs.
3549    pub fn send(
3550        self,
3551        mut result: Result<&DisplayDeviceGetDisplaySelectResponse, i32>,
3552    ) -> Result<(), fidl::Error> {
3553        let _result = self.send_raw(result);
3554        if _result.is_err() {
3555            self.control_handle.shutdown();
3556        }
3557        self.drop_without_shutdown();
3558        _result
3559    }
3560
3561    /// Similar to "send" but does not shutdown the channel if an error occurs.
3562    pub fn send_no_shutdown_on_err(
3563        self,
3564        mut result: Result<&DisplayDeviceGetDisplaySelectResponse, i32>,
3565    ) -> Result<(), fidl::Error> {
3566        let _result = self.send_raw(result);
3567        self.drop_without_shutdown();
3568        _result
3569    }
3570
3571    fn send_raw(
3572        &self,
3573        mut result: Result<&DisplayDeviceGetDisplaySelectResponse, i32>,
3574    ) -> Result<(), fidl::Error> {
3575        self.control_handle.inner.send::<fidl::encoding::ResultType<
3576            DisplayDeviceGetDisplaySelectResponse,
3577            i32,
3578        >>(
3579            result,
3580            self.tx_id,
3581            0x6191c86cffd6323,
3582            fidl::encoding::DynamicFlags::empty(),
3583        )
3584    }
3585}
3586
3587#[must_use = "FIDL methods require a response to be sent"]
3588#[derive(Debug)]
3589pub struct DisplayDeviceSetDisplaySelectResponder {
3590    control_handle: std::mem::ManuallyDrop<DisplayDeviceControlHandle>,
3591    tx_id: u32,
3592}
3593
3594/// Set the the channel to be shutdown (see [`DisplayDeviceControlHandle::shutdown`])
3595/// if the responder is dropped without sending a response, so that the client
3596/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3597impl std::ops::Drop for DisplayDeviceSetDisplaySelectResponder {
3598    fn drop(&mut self) {
3599        self.control_handle.shutdown();
3600        // Safety: drops once, never accessed again
3601        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3602    }
3603}
3604
3605impl fidl::endpoints::Responder for DisplayDeviceSetDisplaySelectResponder {
3606    type ControlHandle = DisplayDeviceControlHandle;
3607
3608    fn control_handle(&self) -> &DisplayDeviceControlHandle {
3609        &self.control_handle
3610    }
3611
3612    fn drop_without_shutdown(mut self) {
3613        // Safety: drops once, never accessed again due to mem::forget
3614        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3615        // Prevent Drop from running (which would shut down the channel)
3616        std::mem::forget(self);
3617    }
3618}
3619
3620impl DisplayDeviceSetDisplaySelectResponder {
3621    /// Sends a response to the FIDL transaction.
3622    ///
3623    /// Sets the channel to shutdown if an error occurs.
3624    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3625        let _result = self.send_raw(result);
3626        if _result.is_err() {
3627            self.control_handle.shutdown();
3628        }
3629        self.drop_without_shutdown();
3630        _result
3631    }
3632
3633    /// Similar to "send" but does not shutdown the channel if an error occurs.
3634    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3635        let _result = self.send_raw(result);
3636        self.drop_without_shutdown();
3637        _result
3638    }
3639
3640    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3641        self.control_handle
3642            .inner
3643            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3644                result,
3645                self.tx_id,
3646                0x2b07f6ba12e7a412,
3647                fidl::encoding::DynamicFlags::empty(),
3648            )
3649    }
3650}
3651
3652#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3653pub struct HangingDataChannelMarker;
3654
3655impl fidl::endpoints::ProtocolMarker for HangingDataChannelMarker {
3656    type Proxy = HangingDataChannelProxy;
3657    type RequestStream = HangingDataChannelRequestStream;
3658    #[cfg(target_os = "fuchsia")]
3659    type SynchronousProxy = HangingDataChannelSynchronousProxy;
3660
3661    const DEBUG_NAME: &'static str = "(anonymous) HangingDataChannel";
3662}
3663pub type HangingDataChannelReadResult = Result<HangingDataChannelReadResponse, i32>;
3664pub type HangingDataChannelWriteResult = Result<(), i32>;
3665
3666pub trait HangingDataChannelProxyInterface: Send + Sync {
3667    type ReadResponseFut: std::future::Future<Output = Result<HangingDataChannelReadResult, fidl::Error>>
3668        + Send;
3669    fn r#read(&self) -> Self::ReadResponseFut;
3670    type WriteResponseFut: std::future::Future<Output = Result<HangingDataChannelWriteResult, fidl::Error>>
3671        + Send;
3672    fn r#write(&self, payload: &HangingDataChannelWriteRequest) -> Self::WriteResponseFut;
3673}
3674#[derive(Debug)]
3675#[cfg(target_os = "fuchsia")]
3676pub struct HangingDataChannelSynchronousProxy {
3677    client: fidl::client::sync::Client,
3678}
3679
3680#[cfg(target_os = "fuchsia")]
3681impl fidl::endpoints::SynchronousProxy for HangingDataChannelSynchronousProxy {
3682    type Proxy = HangingDataChannelProxy;
3683    type Protocol = HangingDataChannelMarker;
3684
3685    fn from_channel(inner: fidl::Channel) -> Self {
3686        Self::new(inner)
3687    }
3688
3689    fn into_channel(self) -> fidl::Channel {
3690        self.client.into_channel()
3691    }
3692
3693    fn as_channel(&self) -> &fidl::Channel {
3694        self.client.as_channel()
3695    }
3696}
3697
3698#[cfg(target_os = "fuchsia")]
3699impl HangingDataChannelSynchronousProxy {
3700    pub fn new(channel: fidl::Channel) -> Self {
3701        Self { client: fidl::client::sync::Client::new(channel) }
3702    }
3703
3704    pub fn into_channel(self) -> fidl::Channel {
3705        self.client.into_channel()
3706    }
3707
3708    /// Waits until an event arrives and returns it. It is safe for other
3709    /// threads to make concurrent requests while waiting for an event.
3710    pub fn wait_for_event(
3711        &self,
3712        deadline: zx::MonotonicInstant,
3713    ) -> Result<HangingDataChannelEvent, fidl::Error> {
3714        HangingDataChannelEvent::decode(
3715            self.client.wait_for_event::<HangingDataChannelMarker>(deadline)?,
3716        )
3717    }
3718
3719    /// The call will return the next datagram to be read from the channel.
3720    /// This call has hanging get semantics and will return once data is available.
3721    pub fn r#read(
3722        &self,
3723        ___deadline: zx::MonotonicInstant,
3724    ) -> Result<HangingDataChannelReadResult, fidl::Error> {
3725        let _response = self.client.send_query::<
3726            fidl::encoding::EmptyPayload,
3727            fidl::encoding::FlexibleResultType<HangingDataChannelReadResponse, i32>,
3728            HangingDataChannelMarker,
3729        >(
3730            (),
3731            0x160be10337c2484f,
3732            fidl::encoding::DynamicFlags::FLEXIBLE,
3733            ___deadline,
3734        )?
3735        .into_result::<HangingDataChannelMarker>("read")?;
3736        Ok(_response.map(|x| x))
3737    }
3738
3739    /// The call will return once the data is fully committed.
3740    ///
3741    /// If the driver is not ready for a write, it will return
3742    /// ZX_ERR_NO_RESOURCES
3743    pub fn r#write(
3744        &self,
3745        mut payload: &HangingDataChannelWriteRequest,
3746        ___deadline: zx::MonotonicInstant,
3747    ) -> Result<HangingDataChannelWriteResult, fidl::Error> {
3748        let _response = self.client.send_query::<
3749            HangingDataChannelWriteRequest,
3750            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
3751            HangingDataChannelMarker,
3752        >(
3753            payload,
3754            0x6addfd084eb16746,
3755            fidl::encoding::DynamicFlags::FLEXIBLE,
3756            ___deadline,
3757        )?
3758        .into_result::<HangingDataChannelMarker>("write")?;
3759        Ok(_response.map(|x| x))
3760    }
3761}
3762
3763#[cfg(target_os = "fuchsia")]
3764impl From<HangingDataChannelSynchronousProxy> for zx::NullableHandle {
3765    fn from(value: HangingDataChannelSynchronousProxy) -> Self {
3766        value.into_channel().into()
3767    }
3768}
3769
3770#[cfg(target_os = "fuchsia")]
3771impl From<fidl::Channel> for HangingDataChannelSynchronousProxy {
3772    fn from(value: fidl::Channel) -> Self {
3773        Self::new(value)
3774    }
3775}
3776
3777#[cfg(target_os = "fuchsia")]
3778impl fidl::endpoints::FromClient for HangingDataChannelSynchronousProxy {
3779    type Protocol = HangingDataChannelMarker;
3780
3781    fn from_client(value: fidl::endpoints::ClientEnd<HangingDataChannelMarker>) -> Self {
3782        Self::new(value.into_channel())
3783    }
3784}
3785
3786#[derive(Debug, Clone)]
3787pub struct HangingDataChannelProxy {
3788    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3789}
3790
3791impl fidl::endpoints::Proxy for HangingDataChannelProxy {
3792    type Protocol = HangingDataChannelMarker;
3793
3794    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3795        Self::new(inner)
3796    }
3797
3798    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3799        self.client.into_channel().map_err(|client| Self { client })
3800    }
3801
3802    fn as_channel(&self) -> &::fidl::AsyncChannel {
3803        self.client.as_channel()
3804    }
3805}
3806
3807impl HangingDataChannelProxy {
3808    /// Create a new Proxy for fuchsia.hardware.google.nanohub/HangingDataChannel.
3809    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3810        let protocol_name =
3811            <HangingDataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3812        Self { client: fidl::client::Client::new(channel, protocol_name) }
3813    }
3814
3815    /// Get a Stream of events from the remote end of the protocol.
3816    ///
3817    /// # Panics
3818    ///
3819    /// Panics if the event stream was already taken.
3820    pub fn take_event_stream(&self) -> HangingDataChannelEventStream {
3821        HangingDataChannelEventStream { event_receiver: self.client.take_event_receiver() }
3822    }
3823
3824    /// The call will return the next datagram to be read from the channel.
3825    /// This call has hanging get semantics and will return once data is available.
3826    pub fn r#read(
3827        &self,
3828    ) -> fidl::client::QueryResponseFut<
3829        HangingDataChannelReadResult,
3830        fidl::encoding::DefaultFuchsiaResourceDialect,
3831    > {
3832        HangingDataChannelProxyInterface::r#read(self)
3833    }
3834
3835    /// The call will return once the data is fully committed.
3836    ///
3837    /// If the driver is not ready for a write, it will return
3838    /// ZX_ERR_NO_RESOURCES
3839    pub fn r#write(
3840        &self,
3841        mut payload: &HangingDataChannelWriteRequest,
3842    ) -> fidl::client::QueryResponseFut<
3843        HangingDataChannelWriteResult,
3844        fidl::encoding::DefaultFuchsiaResourceDialect,
3845    > {
3846        HangingDataChannelProxyInterface::r#write(self, payload)
3847    }
3848}
3849
3850impl HangingDataChannelProxyInterface for HangingDataChannelProxy {
3851    type ReadResponseFut = fidl::client::QueryResponseFut<
3852        HangingDataChannelReadResult,
3853        fidl::encoding::DefaultFuchsiaResourceDialect,
3854    >;
3855    fn r#read(&self) -> Self::ReadResponseFut {
3856        fn _decode(
3857            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3858        ) -> Result<HangingDataChannelReadResult, fidl::Error> {
3859            let _response = fidl::client::decode_transaction_body::<
3860                fidl::encoding::FlexibleResultType<HangingDataChannelReadResponse, i32>,
3861                fidl::encoding::DefaultFuchsiaResourceDialect,
3862                0x160be10337c2484f,
3863            >(_buf?)?
3864            .into_result::<HangingDataChannelMarker>("read")?;
3865            Ok(_response.map(|x| x))
3866        }
3867        self.client
3868            .send_query_and_decode::<fidl::encoding::EmptyPayload, HangingDataChannelReadResult>(
3869                (),
3870                0x160be10337c2484f,
3871                fidl::encoding::DynamicFlags::FLEXIBLE,
3872                _decode,
3873            )
3874    }
3875
3876    type WriteResponseFut = fidl::client::QueryResponseFut<
3877        HangingDataChannelWriteResult,
3878        fidl::encoding::DefaultFuchsiaResourceDialect,
3879    >;
3880    fn r#write(&self, mut payload: &HangingDataChannelWriteRequest) -> Self::WriteResponseFut {
3881        fn _decode(
3882            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3883        ) -> Result<HangingDataChannelWriteResult, fidl::Error> {
3884            let _response = fidl::client::decode_transaction_body::<
3885                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
3886                fidl::encoding::DefaultFuchsiaResourceDialect,
3887                0x6addfd084eb16746,
3888            >(_buf?)?
3889            .into_result::<HangingDataChannelMarker>("write")?;
3890            Ok(_response.map(|x| x))
3891        }
3892        self.client
3893            .send_query_and_decode::<HangingDataChannelWriteRequest, HangingDataChannelWriteResult>(
3894                payload,
3895                0x6addfd084eb16746,
3896                fidl::encoding::DynamicFlags::FLEXIBLE,
3897                _decode,
3898            )
3899    }
3900}
3901
3902pub struct HangingDataChannelEventStream {
3903    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3904}
3905
3906impl std::marker::Unpin for HangingDataChannelEventStream {}
3907
3908impl futures::stream::FusedStream for HangingDataChannelEventStream {
3909    fn is_terminated(&self) -> bool {
3910        self.event_receiver.is_terminated()
3911    }
3912}
3913
3914impl futures::Stream for HangingDataChannelEventStream {
3915    type Item = Result<HangingDataChannelEvent, fidl::Error>;
3916
3917    fn poll_next(
3918        mut self: std::pin::Pin<&mut Self>,
3919        cx: &mut std::task::Context<'_>,
3920    ) -> std::task::Poll<Option<Self::Item>> {
3921        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3922            &mut self.event_receiver,
3923            cx
3924        )?) {
3925            Some(buf) => std::task::Poll::Ready(Some(HangingDataChannelEvent::decode(buf))),
3926            None => std::task::Poll::Ready(None),
3927        }
3928    }
3929}
3930
3931#[derive(Debug)]
3932pub enum HangingDataChannelEvent {
3933    #[non_exhaustive]
3934    _UnknownEvent {
3935        /// Ordinal of the event that was sent.
3936        ordinal: u64,
3937    },
3938}
3939
3940impl HangingDataChannelEvent {
3941    /// Decodes a message buffer as a [`HangingDataChannelEvent`].
3942    fn decode(
3943        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3944    ) -> Result<HangingDataChannelEvent, fidl::Error> {
3945        let (bytes, _handles) = buf.split_mut();
3946        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3947        debug_assert_eq!(tx_header.tx_id, 0);
3948        match tx_header.ordinal {
3949            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3950                Ok(HangingDataChannelEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3951            }
3952            _ => Err(fidl::Error::UnknownOrdinal {
3953                ordinal: tx_header.ordinal,
3954                protocol_name:
3955                    <HangingDataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3956            }),
3957        }
3958    }
3959}
3960
3961/// A Stream of incoming requests for fuchsia.hardware.google.nanohub/HangingDataChannel.
3962pub struct HangingDataChannelRequestStream {
3963    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3964    is_terminated: bool,
3965}
3966
3967impl std::marker::Unpin for HangingDataChannelRequestStream {}
3968
3969impl futures::stream::FusedStream for HangingDataChannelRequestStream {
3970    fn is_terminated(&self) -> bool {
3971        self.is_terminated
3972    }
3973}
3974
3975impl fidl::endpoints::RequestStream for HangingDataChannelRequestStream {
3976    type Protocol = HangingDataChannelMarker;
3977    type ControlHandle = HangingDataChannelControlHandle;
3978
3979    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3980        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3981    }
3982
3983    fn control_handle(&self) -> Self::ControlHandle {
3984        HangingDataChannelControlHandle { inner: self.inner.clone() }
3985    }
3986
3987    fn into_inner(
3988        self,
3989    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3990    {
3991        (self.inner, self.is_terminated)
3992    }
3993
3994    fn from_inner(
3995        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3996        is_terminated: bool,
3997    ) -> Self {
3998        Self { inner, is_terminated }
3999    }
4000}
4001
4002impl futures::Stream for HangingDataChannelRequestStream {
4003    type Item = Result<HangingDataChannelRequest, fidl::Error>;
4004
4005    fn poll_next(
4006        mut self: std::pin::Pin<&mut Self>,
4007        cx: &mut std::task::Context<'_>,
4008    ) -> std::task::Poll<Option<Self::Item>> {
4009        let this = &mut *self;
4010        if this.inner.check_shutdown(cx) {
4011            this.is_terminated = true;
4012            return std::task::Poll::Ready(None);
4013        }
4014        if this.is_terminated {
4015            panic!("polled HangingDataChannelRequestStream after completion");
4016        }
4017        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4018            |bytes, handles| {
4019                match this.inner.channel().read_etc(cx, bytes, handles) {
4020                    std::task::Poll::Ready(Ok(())) => {}
4021                    std::task::Poll::Pending => return std::task::Poll::Pending,
4022                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4023                        this.is_terminated = true;
4024                        return std::task::Poll::Ready(None);
4025                    }
4026                    std::task::Poll::Ready(Err(e)) => {
4027                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4028                            e.into(),
4029                        ))));
4030                    }
4031                }
4032
4033                // A message has been received from the channel
4034                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4035
4036                std::task::Poll::Ready(Some(match header.ordinal {
4037                0x160be10337c2484f => {
4038                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4039                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
4040                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4041                    let control_handle = HangingDataChannelControlHandle {
4042                        inner: this.inner.clone(),
4043                    };
4044                    Ok(HangingDataChannelRequest::Read {
4045                        responder: HangingDataChannelReadResponder {
4046                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4047                            tx_id: header.tx_id,
4048                        },
4049                    })
4050                }
4051                0x6addfd084eb16746 => {
4052                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4053                    let mut req = fidl::new_empty!(HangingDataChannelWriteRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4054                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HangingDataChannelWriteRequest>(&header, _body_bytes, handles, &mut req)?;
4055                    let control_handle = HangingDataChannelControlHandle {
4056                        inner: this.inner.clone(),
4057                    };
4058                    Ok(HangingDataChannelRequest::Write {payload: req,
4059                        responder: HangingDataChannelWriteResponder {
4060                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4061                            tx_id: header.tx_id,
4062                        },
4063                    })
4064                }
4065                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4066                    Ok(HangingDataChannelRequest::_UnknownMethod {
4067                        ordinal: header.ordinal,
4068                        control_handle: HangingDataChannelControlHandle { inner: this.inner.clone() },
4069                        method_type: fidl::MethodType::OneWay,
4070                    })
4071                }
4072                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4073                    this.inner.send_framework_err(
4074                        fidl::encoding::FrameworkErr::UnknownMethod,
4075                        header.tx_id,
4076                        header.ordinal,
4077                        header.dynamic_flags(),
4078                        (bytes, handles),
4079                    )?;
4080                    Ok(HangingDataChannelRequest::_UnknownMethod {
4081                        ordinal: header.ordinal,
4082                        control_handle: HangingDataChannelControlHandle { inner: this.inner.clone() },
4083                        method_type: fidl::MethodType::TwoWay,
4084                    })
4085                }
4086                _ => Err(fidl::Error::UnknownOrdinal {
4087                    ordinal: header.ordinal,
4088                    protocol_name: <HangingDataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4089                }),
4090            }))
4091            },
4092        )
4093    }
4094}
4095
4096/// Provides a bound / connected session to a particular DataChannel. New connections should use the
4097/// UnboundHangingDataChannel to open a session of this procotol.
4098/// Calls to Read() on a HangingDataChannel will operate as a Hanging-Get, only returning once data
4099/// becomes available.
4100#[derive(Debug)]
4101pub enum HangingDataChannelRequest {
4102    /// The call will return the next datagram to be read from the channel.
4103    /// This call has hanging get semantics and will return once data is available.
4104    Read { responder: HangingDataChannelReadResponder },
4105    /// The call will return once the data is fully committed.
4106    ///
4107    /// If the driver is not ready for a write, it will return
4108    /// ZX_ERR_NO_RESOURCES
4109    Write { payload: HangingDataChannelWriteRequest, responder: HangingDataChannelWriteResponder },
4110    /// An interaction was received which does not match any known method.
4111    #[non_exhaustive]
4112    _UnknownMethod {
4113        /// Ordinal of the method that was called.
4114        ordinal: u64,
4115        control_handle: HangingDataChannelControlHandle,
4116        method_type: fidl::MethodType,
4117    },
4118}
4119
4120impl HangingDataChannelRequest {
4121    #[allow(irrefutable_let_patterns)]
4122    pub fn into_read(self) -> Option<(HangingDataChannelReadResponder)> {
4123        if let HangingDataChannelRequest::Read { responder } = self {
4124            Some((responder))
4125        } else {
4126            None
4127        }
4128    }
4129
4130    #[allow(irrefutable_let_patterns)]
4131    pub fn into_write(
4132        self,
4133    ) -> Option<(HangingDataChannelWriteRequest, HangingDataChannelWriteResponder)> {
4134        if let HangingDataChannelRequest::Write { payload, responder } = self {
4135            Some((payload, responder))
4136        } else {
4137            None
4138        }
4139    }
4140
4141    /// Name of the method defined in FIDL
4142    pub fn method_name(&self) -> &'static str {
4143        match *self {
4144            HangingDataChannelRequest::Read { .. } => "read",
4145            HangingDataChannelRequest::Write { .. } => "write",
4146            HangingDataChannelRequest::_UnknownMethod {
4147                method_type: fidl::MethodType::OneWay,
4148                ..
4149            } => "unknown one-way method",
4150            HangingDataChannelRequest::_UnknownMethod {
4151                method_type: fidl::MethodType::TwoWay,
4152                ..
4153            } => "unknown two-way method",
4154        }
4155    }
4156}
4157
4158#[derive(Debug, Clone)]
4159pub struct HangingDataChannelControlHandle {
4160    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4161}
4162
4163impl HangingDataChannelControlHandle {
4164    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4165        self.inner.shutdown_with_epitaph(status.into())
4166    }
4167}
4168
4169impl fidl::endpoints::ControlHandle for HangingDataChannelControlHandle {
4170    fn shutdown(&self) {
4171        self.inner.shutdown()
4172    }
4173
4174    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4175        self.inner.shutdown_with_epitaph(status)
4176    }
4177
4178    fn is_closed(&self) -> bool {
4179        self.inner.channel().is_closed()
4180    }
4181    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4182        self.inner.channel().on_closed()
4183    }
4184
4185    #[cfg(target_os = "fuchsia")]
4186    fn signal_peer(
4187        &self,
4188        clear_mask: zx::Signals,
4189        set_mask: zx::Signals,
4190    ) -> Result<(), zx_status::Status> {
4191        use fidl::Peered;
4192        self.inner.channel().signal_peer(clear_mask, set_mask)
4193    }
4194}
4195
4196impl HangingDataChannelControlHandle {}
4197
4198#[must_use = "FIDL methods require a response to be sent"]
4199#[derive(Debug)]
4200pub struct HangingDataChannelReadResponder {
4201    control_handle: std::mem::ManuallyDrop<HangingDataChannelControlHandle>,
4202    tx_id: u32,
4203}
4204
4205/// Set the the channel to be shutdown (see [`HangingDataChannelControlHandle::shutdown`])
4206/// if the responder is dropped without sending a response, so that the client
4207/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4208impl std::ops::Drop for HangingDataChannelReadResponder {
4209    fn drop(&mut self) {
4210        self.control_handle.shutdown();
4211        // Safety: drops once, never accessed again
4212        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4213    }
4214}
4215
4216impl fidl::endpoints::Responder for HangingDataChannelReadResponder {
4217    type ControlHandle = HangingDataChannelControlHandle;
4218
4219    fn control_handle(&self) -> &HangingDataChannelControlHandle {
4220        &self.control_handle
4221    }
4222
4223    fn drop_without_shutdown(mut self) {
4224        // Safety: drops once, never accessed again due to mem::forget
4225        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4226        // Prevent Drop from running (which would shut down the channel)
4227        std::mem::forget(self);
4228    }
4229}
4230
4231impl HangingDataChannelReadResponder {
4232    /// Sends a response to the FIDL transaction.
4233    ///
4234    /// Sets the channel to shutdown if an error occurs.
4235    pub fn send(
4236        self,
4237        mut result: Result<HangingDataChannelReadResponse, i32>,
4238    ) -> Result<(), fidl::Error> {
4239        let _result = self.send_raw(result);
4240        if _result.is_err() {
4241            self.control_handle.shutdown();
4242        }
4243        self.drop_without_shutdown();
4244        _result
4245    }
4246
4247    /// Similar to "send" but does not shutdown the channel if an error occurs.
4248    pub fn send_no_shutdown_on_err(
4249        self,
4250        mut result: Result<HangingDataChannelReadResponse, i32>,
4251    ) -> Result<(), fidl::Error> {
4252        let _result = self.send_raw(result);
4253        self.drop_without_shutdown();
4254        _result
4255    }
4256
4257    fn send_raw(
4258        &self,
4259        mut result: Result<HangingDataChannelReadResponse, i32>,
4260    ) -> Result<(), fidl::Error> {
4261        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4262            HangingDataChannelReadResponse,
4263            i32,
4264        >>(
4265            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
4266            self.tx_id,
4267            0x160be10337c2484f,
4268            fidl::encoding::DynamicFlags::FLEXIBLE,
4269        )
4270    }
4271}
4272
4273#[must_use = "FIDL methods require a response to be sent"]
4274#[derive(Debug)]
4275pub struct HangingDataChannelWriteResponder {
4276    control_handle: std::mem::ManuallyDrop<HangingDataChannelControlHandle>,
4277    tx_id: u32,
4278}
4279
4280/// Set the the channel to be shutdown (see [`HangingDataChannelControlHandle::shutdown`])
4281/// if the responder is dropped without sending a response, so that the client
4282/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4283impl std::ops::Drop for HangingDataChannelWriteResponder {
4284    fn drop(&mut self) {
4285        self.control_handle.shutdown();
4286        // Safety: drops once, never accessed again
4287        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4288    }
4289}
4290
4291impl fidl::endpoints::Responder for HangingDataChannelWriteResponder {
4292    type ControlHandle = HangingDataChannelControlHandle;
4293
4294    fn control_handle(&self) -> &HangingDataChannelControlHandle {
4295        &self.control_handle
4296    }
4297
4298    fn drop_without_shutdown(mut self) {
4299        // Safety: drops once, never accessed again due to mem::forget
4300        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4301        // Prevent Drop from running (which would shut down the channel)
4302        std::mem::forget(self);
4303    }
4304}
4305
4306impl HangingDataChannelWriteResponder {
4307    /// Sends a response to the FIDL transaction.
4308    ///
4309    /// Sets the channel to shutdown if an error occurs.
4310    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4311        let _result = self.send_raw(result);
4312        if _result.is_err() {
4313            self.control_handle.shutdown();
4314        }
4315        self.drop_without_shutdown();
4316        _result
4317    }
4318
4319    /// Similar to "send" but does not shutdown the channel if an error occurs.
4320    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4321        let _result = self.send_raw(result);
4322        self.drop_without_shutdown();
4323        _result
4324    }
4325
4326    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4327        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4328            fidl::encoding::EmptyStruct,
4329            i32,
4330        >>(
4331            fidl::encoding::FlexibleResult::new(result),
4332            self.tx_id,
4333            0x6addfd084eb16746,
4334            fidl::encoding::DynamicFlags::FLEXIBLE,
4335        )
4336    }
4337}
4338
4339#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4340pub struct LifecycleObserverMarker;
4341
4342impl fidl::endpoints::ProtocolMarker for LifecycleObserverMarker {
4343    type Proxy = LifecycleObserverProxy;
4344    type RequestStream = LifecycleObserverRequestStream;
4345    #[cfg(target_os = "fuchsia")]
4346    type SynchronousProxy = LifecycleObserverSynchronousProxy;
4347
4348    const DEBUG_NAME: &'static str = "(anonymous) LifecycleObserver";
4349}
4350
4351pub trait LifecycleObserverProxyInterface: Send + Sync {}
4352#[derive(Debug)]
4353#[cfg(target_os = "fuchsia")]
4354pub struct LifecycleObserverSynchronousProxy {
4355    client: fidl::client::sync::Client,
4356}
4357
4358#[cfg(target_os = "fuchsia")]
4359impl fidl::endpoints::SynchronousProxy for LifecycleObserverSynchronousProxy {
4360    type Proxy = LifecycleObserverProxy;
4361    type Protocol = LifecycleObserverMarker;
4362
4363    fn from_channel(inner: fidl::Channel) -> Self {
4364        Self::new(inner)
4365    }
4366
4367    fn into_channel(self) -> fidl::Channel {
4368        self.client.into_channel()
4369    }
4370
4371    fn as_channel(&self) -> &fidl::Channel {
4372        self.client.as_channel()
4373    }
4374}
4375
4376#[cfg(target_os = "fuchsia")]
4377impl LifecycleObserverSynchronousProxy {
4378    pub fn new(channel: fidl::Channel) -> Self {
4379        Self { client: fidl::client::sync::Client::new(channel) }
4380    }
4381
4382    pub fn into_channel(self) -> fidl::Channel {
4383        self.client.into_channel()
4384    }
4385
4386    /// Waits until an event arrives and returns it. It is safe for other
4387    /// threads to make concurrent requests while waiting for an event.
4388    pub fn wait_for_event(
4389        &self,
4390        deadline: zx::MonotonicInstant,
4391    ) -> Result<LifecycleObserverEvent, fidl::Error> {
4392        LifecycleObserverEvent::decode(
4393            self.client.wait_for_event::<LifecycleObserverMarker>(deadline)?,
4394        )
4395    }
4396}
4397
4398#[cfg(target_os = "fuchsia")]
4399impl From<LifecycleObserverSynchronousProxy> for zx::NullableHandle {
4400    fn from(value: LifecycleObserverSynchronousProxy) -> Self {
4401        value.into_channel().into()
4402    }
4403}
4404
4405#[cfg(target_os = "fuchsia")]
4406impl From<fidl::Channel> for LifecycleObserverSynchronousProxy {
4407    fn from(value: fidl::Channel) -> Self {
4408        Self::new(value)
4409    }
4410}
4411
4412#[cfg(target_os = "fuchsia")]
4413impl fidl::endpoints::FromClient for LifecycleObserverSynchronousProxy {
4414    type Protocol = LifecycleObserverMarker;
4415
4416    fn from_client(value: fidl::endpoints::ClientEnd<LifecycleObserverMarker>) -> Self {
4417        Self::new(value.into_channel())
4418    }
4419}
4420
4421#[derive(Debug, Clone)]
4422pub struct LifecycleObserverProxy {
4423    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4424}
4425
4426impl fidl::endpoints::Proxy for LifecycleObserverProxy {
4427    type Protocol = LifecycleObserverMarker;
4428
4429    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4430        Self::new(inner)
4431    }
4432
4433    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4434        self.client.into_channel().map_err(|client| Self { client })
4435    }
4436
4437    fn as_channel(&self) -> &::fidl::AsyncChannel {
4438        self.client.as_channel()
4439    }
4440}
4441
4442impl LifecycleObserverProxy {
4443    /// Create a new Proxy for fuchsia.hardware.google.nanohub/LifecycleObserver.
4444    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4445        let protocol_name =
4446            <LifecycleObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4447        Self { client: fidl::client::Client::new(channel, protocol_name) }
4448    }
4449
4450    /// Get a Stream of events from the remote end of the protocol.
4451    ///
4452    /// # Panics
4453    ///
4454    /// Panics if the event stream was already taken.
4455    pub fn take_event_stream(&self) -> LifecycleObserverEventStream {
4456        LifecycleObserverEventStream { event_receiver: self.client.take_event_receiver() }
4457    }
4458}
4459
4460impl LifecycleObserverProxyInterface for LifecycleObserverProxy {}
4461
4462pub struct LifecycleObserverEventStream {
4463    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4464}
4465
4466impl std::marker::Unpin for LifecycleObserverEventStream {}
4467
4468impl futures::stream::FusedStream for LifecycleObserverEventStream {
4469    fn is_terminated(&self) -> bool {
4470        self.event_receiver.is_terminated()
4471    }
4472}
4473
4474impl futures::Stream for LifecycleObserverEventStream {
4475    type Item = Result<LifecycleObserverEvent, fidl::Error>;
4476
4477    fn poll_next(
4478        mut self: std::pin::Pin<&mut Self>,
4479        cx: &mut std::task::Context<'_>,
4480    ) -> std::task::Poll<Option<Self::Item>> {
4481        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4482            &mut self.event_receiver,
4483            cx
4484        )?) {
4485            Some(buf) => std::task::Poll::Ready(Some(LifecycleObserverEvent::decode(buf))),
4486            None => std::task::Poll::Ready(None),
4487        }
4488    }
4489}
4490
4491#[derive(Debug)]
4492pub enum LifecycleObserverEvent {
4493    OnLifecycleChange { event: LifecycleEvent },
4494}
4495
4496impl LifecycleObserverEvent {
4497    #[allow(irrefutable_let_patterns)]
4498    pub fn into_on_lifecycle_change(self) -> Option<LifecycleEvent> {
4499        if let LifecycleObserverEvent::OnLifecycleChange { event } = self {
4500            Some((event))
4501        } else {
4502            None
4503        }
4504    }
4505
4506    /// Decodes a message buffer as a [`LifecycleObserverEvent`].
4507    fn decode(
4508        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4509    ) -> Result<LifecycleObserverEvent, fidl::Error> {
4510        let (bytes, _handles) = buf.split_mut();
4511        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4512        debug_assert_eq!(tx_header.tx_id, 0);
4513        match tx_header.ordinal {
4514            0x7034eb94979bd8de => {
4515                let mut out = fidl::new_empty!(
4516                    LifecycleObserverOnLifecycleChangeRequest,
4517                    fidl::encoding::DefaultFuchsiaResourceDialect
4518                );
4519                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LifecycleObserverOnLifecycleChangeRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
4520                Ok((LifecycleObserverEvent::OnLifecycleChange { event: out.event }))
4521            }
4522            _ => Err(fidl::Error::UnknownOrdinal {
4523                ordinal: tx_header.ordinal,
4524                protocol_name:
4525                    <LifecycleObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4526            }),
4527        }
4528    }
4529}
4530
4531/// A Stream of incoming requests for fuchsia.hardware.google.nanohub/LifecycleObserver.
4532pub struct LifecycleObserverRequestStream {
4533    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4534    is_terminated: bool,
4535}
4536
4537impl std::marker::Unpin for LifecycleObserverRequestStream {}
4538
4539impl futures::stream::FusedStream for LifecycleObserverRequestStream {
4540    fn is_terminated(&self) -> bool {
4541        self.is_terminated
4542    }
4543}
4544
4545impl fidl::endpoints::RequestStream for LifecycleObserverRequestStream {
4546    type Protocol = LifecycleObserverMarker;
4547    type ControlHandle = LifecycleObserverControlHandle;
4548
4549    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4550        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4551    }
4552
4553    fn control_handle(&self) -> Self::ControlHandle {
4554        LifecycleObserverControlHandle { inner: self.inner.clone() }
4555    }
4556
4557    fn into_inner(
4558        self,
4559    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4560    {
4561        (self.inner, self.is_terminated)
4562    }
4563
4564    fn from_inner(
4565        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4566        is_terminated: bool,
4567    ) -> Self {
4568        Self { inner, is_terminated }
4569    }
4570}
4571
4572impl futures::Stream for LifecycleObserverRequestStream {
4573    type Item = Result<LifecycleObserverRequest, fidl::Error>;
4574
4575    fn poll_next(
4576        mut self: std::pin::Pin<&mut Self>,
4577        cx: &mut std::task::Context<'_>,
4578    ) -> std::task::Poll<Option<Self::Item>> {
4579        let this = &mut *self;
4580        if this.inner.check_shutdown(cx) {
4581            this.is_terminated = true;
4582            return std::task::Poll::Ready(None);
4583        }
4584        if this.is_terminated {
4585            panic!("polled LifecycleObserverRequestStream after completion");
4586        }
4587        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4588            |bytes, handles| {
4589                match this.inner.channel().read_etc(cx, bytes, handles) {
4590                    std::task::Poll::Ready(Ok(())) => {}
4591                    std::task::Poll::Pending => return std::task::Poll::Pending,
4592                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4593                        this.is_terminated = true;
4594                        return std::task::Poll::Ready(None);
4595                    }
4596                    std::task::Poll::Ready(Err(e)) => {
4597                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4598                            e.into(),
4599                        ))));
4600                    }
4601                }
4602
4603                // A message has been received from the channel
4604                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4605
4606                std::task::Poll::Ready(Some(match header.ordinal {
4607                    _ => Err(fidl::Error::UnknownOrdinal {
4608                        ordinal: header.ordinal,
4609                        protocol_name:
4610                            <LifecycleObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4611                    }),
4612                }))
4613            },
4614        )
4615    }
4616}
4617
4618/// Observer interface for lifecycle events.
4619#[derive(Debug)]
4620pub enum LifecycleObserverRequest {}
4621
4622impl LifecycleObserverRequest {
4623    /// Name of the method defined in FIDL
4624    pub fn method_name(&self) -> &'static str {
4625        match *self {}
4626    }
4627}
4628
4629#[derive(Debug, Clone)]
4630pub struct LifecycleObserverControlHandle {
4631    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4632}
4633
4634impl LifecycleObserverControlHandle {
4635    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4636        self.inner.shutdown_with_epitaph(status.into())
4637    }
4638}
4639
4640impl fidl::endpoints::ControlHandle for LifecycleObserverControlHandle {
4641    fn shutdown(&self) {
4642        self.inner.shutdown()
4643    }
4644
4645    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4646        self.inner.shutdown_with_epitaph(status)
4647    }
4648
4649    fn is_closed(&self) -> bool {
4650        self.inner.channel().is_closed()
4651    }
4652    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4653        self.inner.channel().on_closed()
4654    }
4655
4656    #[cfg(target_os = "fuchsia")]
4657    fn signal_peer(
4658        &self,
4659        clear_mask: zx::Signals,
4660        set_mask: zx::Signals,
4661    ) -> Result<(), zx_status::Status> {
4662        use fidl::Peered;
4663        self.inner.channel().signal_peer(clear_mask, set_mask)
4664    }
4665}
4666
4667impl LifecycleObserverControlHandle {
4668    pub fn send_on_lifecycle_change(&self, mut event: LifecycleEvent) -> Result<(), fidl::Error> {
4669        self.inner.send::<LifecycleObserverOnLifecycleChangeRequest>(
4670            (event,),
4671            0,
4672            0x7034eb94979bd8de,
4673            fidl::encoding::DynamicFlags::empty(),
4674        )
4675    }
4676}
4677
4678#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4679pub struct UnboundHangingDataChannelMarker;
4680
4681impl fidl::endpoints::ProtocolMarker for UnboundHangingDataChannelMarker {
4682    type Proxy = UnboundHangingDataChannelProxy;
4683    type RequestStream = UnboundHangingDataChannelRequestStream;
4684    #[cfg(target_os = "fuchsia")]
4685    type SynchronousProxy = UnboundHangingDataChannelSynchronousProxy;
4686
4687    const DEBUG_NAME: &'static str = "(anonymous) UnboundHangingDataChannel";
4688}
4689pub type UnboundHangingDataChannelBindResult = Result<(), i32>;
4690
4691pub trait UnboundHangingDataChannelProxyInterface: Send + Sync {
4692    type BindResponseFut: std::future::Future<Output = Result<UnboundHangingDataChannelBindResult, fidl::Error>>
4693        + Send;
4694    fn r#bind(&self, payload: UnboundHangingDataChannelBindRequest) -> Self::BindResponseFut;
4695    type GetIdentifierResponseFut: std::future::Future<
4696            Output = Result<UnboundHangingDataChannelGetIdentifierResponse, fidl::Error>,
4697        > + Send;
4698    fn r#get_identifier(&self) -> Self::GetIdentifierResponseFut;
4699}
4700#[derive(Debug)]
4701#[cfg(target_os = "fuchsia")]
4702pub struct UnboundHangingDataChannelSynchronousProxy {
4703    client: fidl::client::sync::Client,
4704}
4705
4706#[cfg(target_os = "fuchsia")]
4707impl fidl::endpoints::SynchronousProxy for UnboundHangingDataChannelSynchronousProxy {
4708    type Proxy = UnboundHangingDataChannelProxy;
4709    type Protocol = UnboundHangingDataChannelMarker;
4710
4711    fn from_channel(inner: fidl::Channel) -> Self {
4712        Self::new(inner)
4713    }
4714
4715    fn into_channel(self) -> fidl::Channel {
4716        self.client.into_channel()
4717    }
4718
4719    fn as_channel(&self) -> &fidl::Channel {
4720        self.client.as_channel()
4721    }
4722}
4723
4724#[cfg(target_os = "fuchsia")]
4725impl UnboundHangingDataChannelSynchronousProxy {
4726    pub fn new(channel: fidl::Channel) -> Self {
4727        Self { client: fidl::client::sync::Client::new(channel) }
4728    }
4729
4730    pub fn into_channel(self) -> fidl::Channel {
4731        self.client.into_channel()
4732    }
4733
4734    /// Waits until an event arrives and returns it. It is safe for other
4735    /// threads to make concurrent requests while waiting for an event.
4736    pub fn wait_for_event(
4737        &self,
4738        deadline: zx::MonotonicInstant,
4739    ) -> Result<UnboundHangingDataChannelEvent, fidl::Error> {
4740        UnboundHangingDataChannelEvent::decode(
4741            self.client.wait_for_event::<UnboundHangingDataChannelMarker>(deadline)?,
4742        )
4743    }
4744
4745    /// Returns a bound client
4746    /// Will return ZX_ERR_ALREADY_BOUND if no instances are available
4747    pub fn r#bind(
4748        &self,
4749        mut payload: UnboundHangingDataChannelBindRequest,
4750        ___deadline: zx::MonotonicInstant,
4751    ) -> Result<UnboundHangingDataChannelBindResult, fidl::Error> {
4752        let _response = self.client.send_query::<
4753            UnboundHangingDataChannelBindRequest,
4754            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
4755            UnboundHangingDataChannelMarker,
4756        >(
4757            &mut payload,
4758            0x62be1ffca6ea4090,
4759            fidl::encoding::DynamicFlags::FLEXIBLE,
4760            ___deadline,
4761        )?
4762        .into_result::<UnboundHangingDataChannelMarker>("bind")?;
4763        Ok(_response.map(|x| x))
4764    }
4765
4766    /// Returns the identifier associated with this connection.
4767    pub fn r#get_identifier(
4768        &self,
4769        ___deadline: zx::MonotonicInstant,
4770    ) -> Result<UnboundHangingDataChannelGetIdentifierResponse, fidl::Error> {
4771        let _response = self.client.send_query::<
4772            fidl::encoding::EmptyPayload,
4773            fidl::encoding::FlexibleType<UnboundHangingDataChannelGetIdentifierResponse>,
4774            UnboundHangingDataChannelMarker,
4775        >(
4776            (),
4777            0x63d3f258532f3b0,
4778            fidl::encoding::DynamicFlags::FLEXIBLE,
4779            ___deadline,
4780        )?
4781        .into_result::<UnboundHangingDataChannelMarker>("get_identifier")?;
4782        Ok(_response)
4783    }
4784}
4785
4786#[cfg(target_os = "fuchsia")]
4787impl From<UnboundHangingDataChannelSynchronousProxy> for zx::NullableHandle {
4788    fn from(value: UnboundHangingDataChannelSynchronousProxy) -> Self {
4789        value.into_channel().into()
4790    }
4791}
4792
4793#[cfg(target_os = "fuchsia")]
4794impl From<fidl::Channel> for UnboundHangingDataChannelSynchronousProxy {
4795    fn from(value: fidl::Channel) -> Self {
4796        Self::new(value)
4797    }
4798}
4799
4800#[cfg(target_os = "fuchsia")]
4801impl fidl::endpoints::FromClient for UnboundHangingDataChannelSynchronousProxy {
4802    type Protocol = UnboundHangingDataChannelMarker;
4803
4804    fn from_client(value: fidl::endpoints::ClientEnd<UnboundHangingDataChannelMarker>) -> Self {
4805        Self::new(value.into_channel())
4806    }
4807}
4808
4809#[derive(Debug, Clone)]
4810pub struct UnboundHangingDataChannelProxy {
4811    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4812}
4813
4814impl fidl::endpoints::Proxy for UnboundHangingDataChannelProxy {
4815    type Protocol = UnboundHangingDataChannelMarker;
4816
4817    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4818        Self::new(inner)
4819    }
4820
4821    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4822        self.client.into_channel().map_err(|client| Self { client })
4823    }
4824
4825    fn as_channel(&self) -> &::fidl::AsyncChannel {
4826        self.client.as_channel()
4827    }
4828}
4829
4830impl UnboundHangingDataChannelProxy {
4831    /// Create a new Proxy for fuchsia.hardware.google.nanohub/UnboundHangingDataChannel.
4832    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4833        let protocol_name =
4834            <UnboundHangingDataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4835        Self { client: fidl::client::Client::new(channel, protocol_name) }
4836    }
4837
4838    /// Get a Stream of events from the remote end of the protocol.
4839    ///
4840    /// # Panics
4841    ///
4842    /// Panics if the event stream was already taken.
4843    pub fn take_event_stream(&self) -> UnboundHangingDataChannelEventStream {
4844        UnboundHangingDataChannelEventStream { event_receiver: self.client.take_event_receiver() }
4845    }
4846
4847    /// Returns a bound client
4848    /// Will return ZX_ERR_ALREADY_BOUND if no instances are available
4849    pub fn r#bind(
4850        &self,
4851        mut payload: UnboundHangingDataChannelBindRequest,
4852    ) -> fidl::client::QueryResponseFut<
4853        UnboundHangingDataChannelBindResult,
4854        fidl::encoding::DefaultFuchsiaResourceDialect,
4855    > {
4856        UnboundHangingDataChannelProxyInterface::r#bind(self, payload)
4857    }
4858
4859    /// Returns the identifier associated with this connection.
4860    pub fn r#get_identifier(
4861        &self,
4862    ) -> fidl::client::QueryResponseFut<
4863        UnboundHangingDataChannelGetIdentifierResponse,
4864        fidl::encoding::DefaultFuchsiaResourceDialect,
4865    > {
4866        UnboundHangingDataChannelProxyInterface::r#get_identifier(self)
4867    }
4868}
4869
4870impl UnboundHangingDataChannelProxyInterface for UnboundHangingDataChannelProxy {
4871    type BindResponseFut = fidl::client::QueryResponseFut<
4872        UnboundHangingDataChannelBindResult,
4873        fidl::encoding::DefaultFuchsiaResourceDialect,
4874    >;
4875    fn r#bind(&self, mut payload: UnboundHangingDataChannelBindRequest) -> Self::BindResponseFut {
4876        fn _decode(
4877            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4878        ) -> Result<UnboundHangingDataChannelBindResult, fidl::Error> {
4879            let _response = fidl::client::decode_transaction_body::<
4880                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
4881                fidl::encoding::DefaultFuchsiaResourceDialect,
4882                0x62be1ffca6ea4090,
4883            >(_buf?)?
4884            .into_result::<UnboundHangingDataChannelMarker>("bind")?;
4885            Ok(_response.map(|x| x))
4886        }
4887        self.client.send_query_and_decode::<
4888            UnboundHangingDataChannelBindRequest,
4889            UnboundHangingDataChannelBindResult,
4890        >(
4891            &mut payload,
4892            0x62be1ffca6ea4090,
4893            fidl::encoding::DynamicFlags::FLEXIBLE,
4894            _decode,
4895        )
4896    }
4897
4898    type GetIdentifierResponseFut = fidl::client::QueryResponseFut<
4899        UnboundHangingDataChannelGetIdentifierResponse,
4900        fidl::encoding::DefaultFuchsiaResourceDialect,
4901    >;
4902    fn r#get_identifier(&self) -> Self::GetIdentifierResponseFut {
4903        fn _decode(
4904            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4905        ) -> Result<UnboundHangingDataChannelGetIdentifierResponse, fidl::Error> {
4906            let _response = fidl::client::decode_transaction_body::<
4907                fidl::encoding::FlexibleType<UnboundHangingDataChannelGetIdentifierResponse>,
4908                fidl::encoding::DefaultFuchsiaResourceDialect,
4909                0x63d3f258532f3b0,
4910            >(_buf?)?
4911            .into_result::<UnboundHangingDataChannelMarker>("get_identifier")?;
4912            Ok(_response)
4913        }
4914        self.client.send_query_and_decode::<
4915            fidl::encoding::EmptyPayload,
4916            UnboundHangingDataChannelGetIdentifierResponse,
4917        >(
4918            (),
4919            0x63d3f258532f3b0,
4920            fidl::encoding::DynamicFlags::FLEXIBLE,
4921            _decode,
4922        )
4923    }
4924}
4925
4926pub struct UnboundHangingDataChannelEventStream {
4927    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4928}
4929
4930impl std::marker::Unpin for UnboundHangingDataChannelEventStream {}
4931
4932impl futures::stream::FusedStream for UnboundHangingDataChannelEventStream {
4933    fn is_terminated(&self) -> bool {
4934        self.event_receiver.is_terminated()
4935    }
4936}
4937
4938impl futures::Stream for UnboundHangingDataChannelEventStream {
4939    type Item = Result<UnboundHangingDataChannelEvent, fidl::Error>;
4940
4941    fn poll_next(
4942        mut self: std::pin::Pin<&mut Self>,
4943        cx: &mut std::task::Context<'_>,
4944    ) -> std::task::Poll<Option<Self::Item>> {
4945        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4946            &mut self.event_receiver,
4947            cx
4948        )?) {
4949            Some(buf) => std::task::Poll::Ready(Some(UnboundHangingDataChannelEvent::decode(buf))),
4950            None => std::task::Poll::Ready(None),
4951        }
4952    }
4953}
4954
4955#[derive(Debug)]
4956pub enum UnboundHangingDataChannelEvent {
4957    #[non_exhaustive]
4958    _UnknownEvent {
4959        /// Ordinal of the event that was sent.
4960        ordinal: u64,
4961    },
4962}
4963
4964impl UnboundHangingDataChannelEvent {
4965    /// Decodes a message buffer as a [`UnboundHangingDataChannelEvent`].
4966    fn decode(
4967        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4968    ) -> Result<UnboundHangingDataChannelEvent, fidl::Error> {
4969        let (bytes, _handles) = buf.split_mut();
4970        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4971        debug_assert_eq!(tx_header.tx_id, 0);
4972        match tx_header.ordinal {
4973            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4974                Ok(UnboundHangingDataChannelEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4975            }
4976            _ => Err(fidl::Error::UnknownOrdinal {
4977                ordinal: tx_header.ordinal,
4978                protocol_name:
4979                    <UnboundHangingDataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4980            }),
4981        }
4982    }
4983}
4984
4985/// A Stream of incoming requests for fuchsia.hardware.google.nanohub/UnboundHangingDataChannel.
4986pub struct UnboundHangingDataChannelRequestStream {
4987    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4988    is_terminated: bool,
4989}
4990
4991impl std::marker::Unpin for UnboundHangingDataChannelRequestStream {}
4992
4993impl futures::stream::FusedStream for UnboundHangingDataChannelRequestStream {
4994    fn is_terminated(&self) -> bool {
4995        self.is_terminated
4996    }
4997}
4998
4999impl fidl::endpoints::RequestStream for UnboundHangingDataChannelRequestStream {
5000    type Protocol = UnboundHangingDataChannelMarker;
5001    type ControlHandle = UnboundHangingDataChannelControlHandle;
5002
5003    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5004        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5005    }
5006
5007    fn control_handle(&self) -> Self::ControlHandle {
5008        UnboundHangingDataChannelControlHandle { inner: self.inner.clone() }
5009    }
5010
5011    fn into_inner(
5012        self,
5013    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5014    {
5015        (self.inner, self.is_terminated)
5016    }
5017
5018    fn from_inner(
5019        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5020        is_terminated: bool,
5021    ) -> Self {
5022        Self { inner, is_terminated }
5023    }
5024}
5025
5026impl futures::Stream for UnboundHangingDataChannelRequestStream {
5027    type Item = Result<UnboundHangingDataChannelRequest, fidl::Error>;
5028
5029    fn poll_next(
5030        mut self: std::pin::Pin<&mut Self>,
5031        cx: &mut std::task::Context<'_>,
5032    ) -> std::task::Poll<Option<Self::Item>> {
5033        let this = &mut *self;
5034        if this.inner.check_shutdown(cx) {
5035            this.is_terminated = true;
5036            return std::task::Poll::Ready(None);
5037        }
5038        if this.is_terminated {
5039            panic!("polled UnboundHangingDataChannelRequestStream after completion");
5040        }
5041        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5042            |bytes, handles| {
5043                match this.inner.channel().read_etc(cx, bytes, handles) {
5044                    std::task::Poll::Ready(Ok(())) => {}
5045                    std::task::Poll::Pending => return std::task::Poll::Pending,
5046                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5047                        this.is_terminated = true;
5048                        return std::task::Poll::Ready(None);
5049                    }
5050                    std::task::Poll::Ready(Err(e)) => {
5051                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5052                            e.into(),
5053                        ))));
5054                    }
5055                }
5056
5057                // A message has been received from the channel
5058                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5059
5060                std::task::Poll::Ready(Some(match header.ordinal {
5061                0x62be1ffca6ea4090 => {
5062                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5063                    let mut req = fidl::new_empty!(UnboundHangingDataChannelBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5064                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UnboundHangingDataChannelBindRequest>(&header, _body_bytes, handles, &mut req)?;
5065                    let control_handle = UnboundHangingDataChannelControlHandle {
5066                        inner: this.inner.clone(),
5067                    };
5068                    Ok(UnboundHangingDataChannelRequest::Bind {payload: req,
5069                        responder: UnboundHangingDataChannelBindResponder {
5070                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5071                            tx_id: header.tx_id,
5072                        },
5073                    })
5074                }
5075                0x63d3f258532f3b0 => {
5076                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5077                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5078                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5079                    let control_handle = UnboundHangingDataChannelControlHandle {
5080                        inner: this.inner.clone(),
5081                    };
5082                    Ok(UnboundHangingDataChannelRequest::GetIdentifier {
5083                        responder: UnboundHangingDataChannelGetIdentifierResponder {
5084                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5085                            tx_id: header.tx_id,
5086                        },
5087                    })
5088                }
5089                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5090                    Ok(UnboundHangingDataChannelRequest::_UnknownMethod {
5091                        ordinal: header.ordinal,
5092                        control_handle: UnboundHangingDataChannelControlHandle { inner: this.inner.clone() },
5093                        method_type: fidl::MethodType::OneWay,
5094                    })
5095                }
5096                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5097                    this.inner.send_framework_err(
5098                        fidl::encoding::FrameworkErr::UnknownMethod,
5099                        header.tx_id,
5100                        header.ordinal,
5101                        header.dynamic_flags(),
5102                        (bytes, handles),
5103                    )?;
5104                    Ok(UnboundHangingDataChannelRequest::_UnknownMethod {
5105                        ordinal: header.ordinal,
5106                        control_handle: UnboundHangingDataChannelControlHandle { inner: this.inner.clone() },
5107                        method_type: fidl::MethodType::TwoWay,
5108                    })
5109                }
5110                _ => Err(fidl::Error::UnknownOrdinal {
5111                    ordinal: header.ordinal,
5112                    protocol_name: <UnboundHangingDataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5113                }),
5114            }))
5115            },
5116        )
5117    }
5118}
5119
5120#[derive(Debug)]
5121pub enum UnboundHangingDataChannelRequest {
5122    /// Returns a bound client
5123    /// Will return ZX_ERR_ALREADY_BOUND if no instances are available
5124    Bind {
5125        payload: UnboundHangingDataChannelBindRequest,
5126        responder: UnboundHangingDataChannelBindResponder,
5127    },
5128    /// Returns the identifier associated with this connection.
5129    GetIdentifier { responder: UnboundHangingDataChannelGetIdentifierResponder },
5130    /// An interaction was received which does not match any known method.
5131    #[non_exhaustive]
5132    _UnknownMethod {
5133        /// Ordinal of the method that was called.
5134        ordinal: u64,
5135        control_handle: UnboundHangingDataChannelControlHandle,
5136        method_type: fidl::MethodType,
5137    },
5138}
5139
5140impl UnboundHangingDataChannelRequest {
5141    #[allow(irrefutable_let_patterns)]
5142    pub fn into_bind(
5143        self,
5144    ) -> Option<(UnboundHangingDataChannelBindRequest, UnboundHangingDataChannelBindResponder)>
5145    {
5146        if let UnboundHangingDataChannelRequest::Bind { payload, responder } = self {
5147            Some((payload, responder))
5148        } else {
5149            None
5150        }
5151    }
5152
5153    #[allow(irrefutable_let_patterns)]
5154    pub fn into_get_identifier(self) -> Option<(UnboundHangingDataChannelGetIdentifierResponder)> {
5155        if let UnboundHangingDataChannelRequest::GetIdentifier { responder } = self {
5156            Some((responder))
5157        } else {
5158            None
5159        }
5160    }
5161
5162    /// Name of the method defined in FIDL
5163    pub fn method_name(&self) -> &'static str {
5164        match *self {
5165            UnboundHangingDataChannelRequest::Bind { .. } => "bind",
5166            UnboundHangingDataChannelRequest::GetIdentifier { .. } => "get_identifier",
5167            UnboundHangingDataChannelRequest::_UnknownMethod {
5168                method_type: fidl::MethodType::OneWay,
5169                ..
5170            } => "unknown one-way method",
5171            UnboundHangingDataChannelRequest::_UnknownMethod {
5172                method_type: fidl::MethodType::TwoWay,
5173                ..
5174            } => "unknown two-way method",
5175        }
5176    }
5177}
5178
5179#[derive(Debug, Clone)]
5180pub struct UnboundHangingDataChannelControlHandle {
5181    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5182}
5183
5184impl UnboundHangingDataChannelControlHandle {
5185    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
5186        self.inner.shutdown_with_epitaph(status.into())
5187    }
5188}
5189
5190impl fidl::endpoints::ControlHandle for UnboundHangingDataChannelControlHandle {
5191    fn shutdown(&self) {
5192        self.inner.shutdown()
5193    }
5194
5195    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
5196        self.inner.shutdown_with_epitaph(status)
5197    }
5198
5199    fn is_closed(&self) -> bool {
5200        self.inner.channel().is_closed()
5201    }
5202    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5203        self.inner.channel().on_closed()
5204    }
5205
5206    #[cfg(target_os = "fuchsia")]
5207    fn signal_peer(
5208        &self,
5209        clear_mask: zx::Signals,
5210        set_mask: zx::Signals,
5211    ) -> Result<(), zx_status::Status> {
5212        use fidl::Peered;
5213        self.inner.channel().signal_peer(clear_mask, set_mask)
5214    }
5215}
5216
5217impl UnboundHangingDataChannelControlHandle {}
5218
5219#[must_use = "FIDL methods require a response to be sent"]
5220#[derive(Debug)]
5221pub struct UnboundHangingDataChannelBindResponder {
5222    control_handle: std::mem::ManuallyDrop<UnboundHangingDataChannelControlHandle>,
5223    tx_id: u32,
5224}
5225
5226/// Set the the channel to be shutdown (see [`UnboundHangingDataChannelControlHandle::shutdown`])
5227/// if the responder is dropped without sending a response, so that the client
5228/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5229impl std::ops::Drop for UnboundHangingDataChannelBindResponder {
5230    fn drop(&mut self) {
5231        self.control_handle.shutdown();
5232        // Safety: drops once, never accessed again
5233        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5234    }
5235}
5236
5237impl fidl::endpoints::Responder for UnboundHangingDataChannelBindResponder {
5238    type ControlHandle = UnboundHangingDataChannelControlHandle;
5239
5240    fn control_handle(&self) -> &UnboundHangingDataChannelControlHandle {
5241        &self.control_handle
5242    }
5243
5244    fn drop_without_shutdown(mut self) {
5245        // Safety: drops once, never accessed again due to mem::forget
5246        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5247        // Prevent Drop from running (which would shut down the channel)
5248        std::mem::forget(self);
5249    }
5250}
5251
5252impl UnboundHangingDataChannelBindResponder {
5253    /// Sends a response to the FIDL transaction.
5254    ///
5255    /// Sets the channel to shutdown if an error occurs.
5256    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5257        let _result = self.send_raw(result);
5258        if _result.is_err() {
5259            self.control_handle.shutdown();
5260        }
5261        self.drop_without_shutdown();
5262        _result
5263    }
5264
5265    /// Similar to "send" but does not shutdown the channel if an error occurs.
5266    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5267        let _result = self.send_raw(result);
5268        self.drop_without_shutdown();
5269        _result
5270    }
5271
5272    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5273        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5274            fidl::encoding::EmptyStruct,
5275            i32,
5276        >>(
5277            fidl::encoding::FlexibleResult::new(result),
5278            self.tx_id,
5279            0x62be1ffca6ea4090,
5280            fidl::encoding::DynamicFlags::FLEXIBLE,
5281        )
5282    }
5283}
5284
5285#[must_use = "FIDL methods require a response to be sent"]
5286#[derive(Debug)]
5287pub struct UnboundHangingDataChannelGetIdentifierResponder {
5288    control_handle: std::mem::ManuallyDrop<UnboundHangingDataChannelControlHandle>,
5289    tx_id: u32,
5290}
5291
5292/// Set the the channel to be shutdown (see [`UnboundHangingDataChannelControlHandle::shutdown`])
5293/// if the responder is dropped without sending a response, so that the client
5294/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5295impl std::ops::Drop for UnboundHangingDataChannelGetIdentifierResponder {
5296    fn drop(&mut self) {
5297        self.control_handle.shutdown();
5298        // Safety: drops once, never accessed again
5299        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5300    }
5301}
5302
5303impl fidl::endpoints::Responder for UnboundHangingDataChannelGetIdentifierResponder {
5304    type ControlHandle = UnboundHangingDataChannelControlHandle;
5305
5306    fn control_handle(&self) -> &UnboundHangingDataChannelControlHandle {
5307        &self.control_handle
5308    }
5309
5310    fn drop_without_shutdown(mut self) {
5311        // Safety: drops once, never accessed again due to mem::forget
5312        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5313        // Prevent Drop from running (which would shut down the channel)
5314        std::mem::forget(self);
5315    }
5316}
5317
5318impl UnboundHangingDataChannelGetIdentifierResponder {
5319    /// Sends a response to the FIDL transaction.
5320    ///
5321    /// Sets the channel to shutdown if an error occurs.
5322    pub fn send(
5323        self,
5324        mut payload: &UnboundHangingDataChannelGetIdentifierResponse,
5325    ) -> Result<(), fidl::Error> {
5326        let _result = self.send_raw(payload);
5327        if _result.is_err() {
5328            self.control_handle.shutdown();
5329        }
5330        self.drop_without_shutdown();
5331        _result
5332    }
5333
5334    /// Similar to "send" but does not shutdown the channel if an error occurs.
5335    pub fn send_no_shutdown_on_err(
5336        self,
5337        mut payload: &UnboundHangingDataChannelGetIdentifierResponse,
5338    ) -> Result<(), fidl::Error> {
5339        let _result = self.send_raw(payload);
5340        self.drop_without_shutdown();
5341        _result
5342    }
5343
5344    fn send_raw(
5345        &self,
5346        mut payload: &UnboundHangingDataChannelGetIdentifierResponse,
5347    ) -> Result<(), fidl::Error> {
5348        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
5349            UnboundHangingDataChannelGetIdentifierResponse,
5350        >>(
5351            fidl::encoding::Flexible::new(payload),
5352            self.tx_id,
5353            0x63d3f258532f3b0,
5354            fidl::encoding::DynamicFlags::FLEXIBLE,
5355        )
5356    }
5357}
5358
5359#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5360pub struct UnboundWaitableDataChannelMarker;
5361
5362impl fidl::endpoints::ProtocolMarker for UnboundWaitableDataChannelMarker {
5363    type Proxy = UnboundWaitableDataChannelProxy;
5364    type RequestStream = UnboundWaitableDataChannelRequestStream;
5365    #[cfg(target_os = "fuchsia")]
5366    type SynchronousProxy = UnboundWaitableDataChannelSynchronousProxy;
5367
5368    const DEBUG_NAME: &'static str = "(anonymous) UnboundWaitableDataChannel";
5369}
5370pub type UnboundWaitableDataChannelBindResult = Result<(), i32>;
5371
5372pub trait UnboundWaitableDataChannelProxyInterface: Send + Sync {
5373    type BindResponseFut: std::future::Future<Output = Result<UnboundWaitableDataChannelBindResult, fidl::Error>>
5374        + Send;
5375    fn r#bind(&self, payload: UnboundWaitableDataChannelBindRequest) -> Self::BindResponseFut;
5376    type GetIdentifierResponseFut: std::future::Future<
5377            Output = Result<UnboundWaitableDataChannelGetIdentifierResponse, fidl::Error>,
5378        > + Send;
5379    fn r#get_identifier(&self) -> Self::GetIdentifierResponseFut;
5380}
5381#[derive(Debug)]
5382#[cfg(target_os = "fuchsia")]
5383pub struct UnboundWaitableDataChannelSynchronousProxy {
5384    client: fidl::client::sync::Client,
5385}
5386
5387#[cfg(target_os = "fuchsia")]
5388impl fidl::endpoints::SynchronousProxy for UnboundWaitableDataChannelSynchronousProxy {
5389    type Proxy = UnboundWaitableDataChannelProxy;
5390    type Protocol = UnboundWaitableDataChannelMarker;
5391
5392    fn from_channel(inner: fidl::Channel) -> Self {
5393        Self::new(inner)
5394    }
5395
5396    fn into_channel(self) -> fidl::Channel {
5397        self.client.into_channel()
5398    }
5399
5400    fn as_channel(&self) -> &fidl::Channel {
5401        self.client.as_channel()
5402    }
5403}
5404
5405#[cfg(target_os = "fuchsia")]
5406impl UnboundWaitableDataChannelSynchronousProxy {
5407    pub fn new(channel: fidl::Channel) -> Self {
5408        Self { client: fidl::client::sync::Client::new(channel) }
5409    }
5410
5411    pub fn into_channel(self) -> fidl::Channel {
5412        self.client.into_channel()
5413    }
5414
5415    /// Waits until an event arrives and returns it. It is safe for other
5416    /// threads to make concurrent requests while waiting for an event.
5417    pub fn wait_for_event(
5418        &self,
5419        deadline: zx::MonotonicInstant,
5420    ) -> Result<UnboundWaitableDataChannelEvent, fidl::Error> {
5421        UnboundWaitableDataChannelEvent::decode(
5422            self.client.wait_for_event::<UnboundWaitableDataChannelMarker>(deadline)?,
5423        )
5424    }
5425
5426    /// Set event used to signal device state, using the signals above,
5427    /// and returns a bound client.
5428    /// Will return ZX_ERR_ALREADY_BOUND if no instances are available.
5429    pub fn r#bind(
5430        &self,
5431        mut payload: UnboundWaitableDataChannelBindRequest,
5432        ___deadline: zx::MonotonicInstant,
5433    ) -> Result<UnboundWaitableDataChannelBindResult, fidl::Error> {
5434        let _response = self.client.send_query::<
5435            UnboundWaitableDataChannelBindRequest,
5436            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
5437            UnboundWaitableDataChannelMarker,
5438        >(
5439            &mut payload,
5440            0x135713194412491e,
5441            fidl::encoding::DynamicFlags::FLEXIBLE,
5442            ___deadline,
5443        )?
5444        .into_result::<UnboundWaitableDataChannelMarker>("bind")?;
5445        Ok(_response.map(|x| x))
5446    }
5447
5448    /// Returns the identifier associated with this connection.
5449    pub fn r#get_identifier(
5450        &self,
5451        ___deadline: zx::MonotonicInstant,
5452    ) -> Result<UnboundWaitableDataChannelGetIdentifierResponse, fidl::Error> {
5453        let _response = self.client.send_query::<
5454            fidl::encoding::EmptyPayload,
5455            fidl::encoding::FlexibleType<UnboundWaitableDataChannelGetIdentifierResponse>,
5456            UnboundWaitableDataChannelMarker,
5457        >(
5458            (),
5459            0x6a36e55ac6beb9d6,
5460            fidl::encoding::DynamicFlags::FLEXIBLE,
5461            ___deadline,
5462        )?
5463        .into_result::<UnboundWaitableDataChannelMarker>("get_identifier")?;
5464        Ok(_response)
5465    }
5466}
5467
5468#[cfg(target_os = "fuchsia")]
5469impl From<UnboundWaitableDataChannelSynchronousProxy> for zx::NullableHandle {
5470    fn from(value: UnboundWaitableDataChannelSynchronousProxy) -> Self {
5471        value.into_channel().into()
5472    }
5473}
5474
5475#[cfg(target_os = "fuchsia")]
5476impl From<fidl::Channel> for UnboundWaitableDataChannelSynchronousProxy {
5477    fn from(value: fidl::Channel) -> Self {
5478        Self::new(value)
5479    }
5480}
5481
5482#[cfg(target_os = "fuchsia")]
5483impl fidl::endpoints::FromClient for UnboundWaitableDataChannelSynchronousProxy {
5484    type Protocol = UnboundWaitableDataChannelMarker;
5485
5486    fn from_client(value: fidl::endpoints::ClientEnd<UnboundWaitableDataChannelMarker>) -> Self {
5487        Self::new(value.into_channel())
5488    }
5489}
5490
5491#[derive(Debug, Clone)]
5492pub struct UnboundWaitableDataChannelProxy {
5493    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5494}
5495
5496impl fidl::endpoints::Proxy for UnboundWaitableDataChannelProxy {
5497    type Protocol = UnboundWaitableDataChannelMarker;
5498
5499    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5500        Self::new(inner)
5501    }
5502
5503    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5504        self.client.into_channel().map_err(|client| Self { client })
5505    }
5506
5507    fn as_channel(&self) -> &::fidl::AsyncChannel {
5508        self.client.as_channel()
5509    }
5510}
5511
5512impl UnboundWaitableDataChannelProxy {
5513    /// Create a new Proxy for fuchsia.hardware.google.nanohub/UnboundWaitableDataChannel.
5514    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5515        let protocol_name =
5516            <UnboundWaitableDataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5517        Self { client: fidl::client::Client::new(channel, protocol_name) }
5518    }
5519
5520    /// Get a Stream of events from the remote end of the protocol.
5521    ///
5522    /// # Panics
5523    ///
5524    /// Panics if the event stream was already taken.
5525    pub fn take_event_stream(&self) -> UnboundWaitableDataChannelEventStream {
5526        UnboundWaitableDataChannelEventStream { event_receiver: self.client.take_event_receiver() }
5527    }
5528
5529    /// Set event used to signal device state, using the signals above,
5530    /// and returns a bound client.
5531    /// Will return ZX_ERR_ALREADY_BOUND if no instances are available.
5532    pub fn r#bind(
5533        &self,
5534        mut payload: UnboundWaitableDataChannelBindRequest,
5535    ) -> fidl::client::QueryResponseFut<
5536        UnboundWaitableDataChannelBindResult,
5537        fidl::encoding::DefaultFuchsiaResourceDialect,
5538    > {
5539        UnboundWaitableDataChannelProxyInterface::r#bind(self, payload)
5540    }
5541
5542    /// Returns the identifier associated with this connection.
5543    pub fn r#get_identifier(
5544        &self,
5545    ) -> fidl::client::QueryResponseFut<
5546        UnboundWaitableDataChannelGetIdentifierResponse,
5547        fidl::encoding::DefaultFuchsiaResourceDialect,
5548    > {
5549        UnboundWaitableDataChannelProxyInterface::r#get_identifier(self)
5550    }
5551}
5552
5553impl UnboundWaitableDataChannelProxyInterface for UnboundWaitableDataChannelProxy {
5554    type BindResponseFut = fidl::client::QueryResponseFut<
5555        UnboundWaitableDataChannelBindResult,
5556        fidl::encoding::DefaultFuchsiaResourceDialect,
5557    >;
5558    fn r#bind(&self, mut payload: UnboundWaitableDataChannelBindRequest) -> Self::BindResponseFut {
5559        fn _decode(
5560            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5561        ) -> Result<UnboundWaitableDataChannelBindResult, fidl::Error> {
5562            let _response = fidl::client::decode_transaction_body::<
5563                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
5564                fidl::encoding::DefaultFuchsiaResourceDialect,
5565                0x135713194412491e,
5566            >(_buf?)?
5567            .into_result::<UnboundWaitableDataChannelMarker>("bind")?;
5568            Ok(_response.map(|x| x))
5569        }
5570        self.client.send_query_and_decode::<
5571            UnboundWaitableDataChannelBindRequest,
5572            UnboundWaitableDataChannelBindResult,
5573        >(
5574            &mut payload,
5575            0x135713194412491e,
5576            fidl::encoding::DynamicFlags::FLEXIBLE,
5577            _decode,
5578        )
5579    }
5580
5581    type GetIdentifierResponseFut = fidl::client::QueryResponseFut<
5582        UnboundWaitableDataChannelGetIdentifierResponse,
5583        fidl::encoding::DefaultFuchsiaResourceDialect,
5584    >;
5585    fn r#get_identifier(&self) -> Self::GetIdentifierResponseFut {
5586        fn _decode(
5587            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5588        ) -> Result<UnboundWaitableDataChannelGetIdentifierResponse, fidl::Error> {
5589            let _response = fidl::client::decode_transaction_body::<
5590                fidl::encoding::FlexibleType<UnboundWaitableDataChannelGetIdentifierResponse>,
5591                fidl::encoding::DefaultFuchsiaResourceDialect,
5592                0x6a36e55ac6beb9d6,
5593            >(_buf?)?
5594            .into_result::<UnboundWaitableDataChannelMarker>("get_identifier")?;
5595            Ok(_response)
5596        }
5597        self.client.send_query_and_decode::<
5598            fidl::encoding::EmptyPayload,
5599            UnboundWaitableDataChannelGetIdentifierResponse,
5600        >(
5601            (),
5602            0x6a36e55ac6beb9d6,
5603            fidl::encoding::DynamicFlags::FLEXIBLE,
5604            _decode,
5605        )
5606    }
5607}
5608
5609pub struct UnboundWaitableDataChannelEventStream {
5610    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5611}
5612
5613impl std::marker::Unpin for UnboundWaitableDataChannelEventStream {}
5614
5615impl futures::stream::FusedStream for UnboundWaitableDataChannelEventStream {
5616    fn is_terminated(&self) -> bool {
5617        self.event_receiver.is_terminated()
5618    }
5619}
5620
5621impl futures::Stream for UnboundWaitableDataChannelEventStream {
5622    type Item = Result<UnboundWaitableDataChannelEvent, fidl::Error>;
5623
5624    fn poll_next(
5625        mut self: std::pin::Pin<&mut Self>,
5626        cx: &mut std::task::Context<'_>,
5627    ) -> std::task::Poll<Option<Self::Item>> {
5628        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5629            &mut self.event_receiver,
5630            cx
5631        )?) {
5632            Some(buf) => std::task::Poll::Ready(Some(UnboundWaitableDataChannelEvent::decode(buf))),
5633            None => std::task::Poll::Ready(None),
5634        }
5635    }
5636}
5637
5638#[derive(Debug)]
5639pub enum UnboundWaitableDataChannelEvent {
5640    #[non_exhaustive]
5641    _UnknownEvent {
5642        /// Ordinal of the event that was sent.
5643        ordinal: u64,
5644    },
5645}
5646
5647impl UnboundWaitableDataChannelEvent {
5648    /// Decodes a message buffer as a [`UnboundWaitableDataChannelEvent`].
5649    fn decode(
5650        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5651    ) -> Result<UnboundWaitableDataChannelEvent, fidl::Error> {
5652        let (bytes, _handles) = buf.split_mut();
5653        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5654        debug_assert_eq!(tx_header.tx_id, 0);
5655        match tx_header.ordinal {
5656            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5657                Ok(UnboundWaitableDataChannelEvent::_UnknownEvent {
5658                    ordinal: tx_header.ordinal,
5659                })
5660            }
5661            _ => Err(fidl::Error::UnknownOrdinal {
5662                ordinal: tx_header.ordinal,
5663                protocol_name: <UnboundWaitableDataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5664            })
5665        }
5666    }
5667}
5668
5669/// A Stream of incoming requests for fuchsia.hardware.google.nanohub/UnboundWaitableDataChannel.
5670pub struct UnboundWaitableDataChannelRequestStream {
5671    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5672    is_terminated: bool,
5673}
5674
5675impl std::marker::Unpin for UnboundWaitableDataChannelRequestStream {}
5676
5677impl futures::stream::FusedStream for UnboundWaitableDataChannelRequestStream {
5678    fn is_terminated(&self) -> bool {
5679        self.is_terminated
5680    }
5681}
5682
5683impl fidl::endpoints::RequestStream for UnboundWaitableDataChannelRequestStream {
5684    type Protocol = UnboundWaitableDataChannelMarker;
5685    type ControlHandle = UnboundWaitableDataChannelControlHandle;
5686
5687    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5688        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5689    }
5690
5691    fn control_handle(&self) -> Self::ControlHandle {
5692        UnboundWaitableDataChannelControlHandle { inner: self.inner.clone() }
5693    }
5694
5695    fn into_inner(
5696        self,
5697    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5698    {
5699        (self.inner, self.is_terminated)
5700    }
5701
5702    fn from_inner(
5703        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5704        is_terminated: bool,
5705    ) -> Self {
5706        Self { inner, is_terminated }
5707    }
5708}
5709
5710impl futures::Stream for UnboundWaitableDataChannelRequestStream {
5711    type Item = Result<UnboundWaitableDataChannelRequest, fidl::Error>;
5712
5713    fn poll_next(
5714        mut self: std::pin::Pin<&mut Self>,
5715        cx: &mut std::task::Context<'_>,
5716    ) -> std::task::Poll<Option<Self::Item>> {
5717        let this = &mut *self;
5718        if this.inner.check_shutdown(cx) {
5719            this.is_terminated = true;
5720            return std::task::Poll::Ready(None);
5721        }
5722        if this.is_terminated {
5723            panic!("polled UnboundWaitableDataChannelRequestStream after completion");
5724        }
5725        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5726            |bytes, handles| {
5727                match this.inner.channel().read_etc(cx, bytes, handles) {
5728                    std::task::Poll::Ready(Ok(())) => {}
5729                    std::task::Poll::Pending => return std::task::Poll::Pending,
5730                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5731                        this.is_terminated = true;
5732                        return std::task::Poll::Ready(None);
5733                    }
5734                    std::task::Poll::Ready(Err(e)) => {
5735                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5736                            e.into(),
5737                        ))));
5738                    }
5739                }
5740
5741                // A message has been received from the channel
5742                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5743
5744                std::task::Poll::Ready(Some(match header.ordinal {
5745                0x135713194412491e => {
5746                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5747                    let mut req = fidl::new_empty!(UnboundWaitableDataChannelBindRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5748                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UnboundWaitableDataChannelBindRequest>(&header, _body_bytes, handles, &mut req)?;
5749                    let control_handle = UnboundWaitableDataChannelControlHandle {
5750                        inner: this.inner.clone(),
5751                    };
5752                    Ok(UnboundWaitableDataChannelRequest::Bind {payload: req,
5753                        responder: UnboundWaitableDataChannelBindResponder {
5754                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5755                            tx_id: header.tx_id,
5756                        },
5757                    })
5758                }
5759                0x6a36e55ac6beb9d6 => {
5760                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5761                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5762                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5763                    let control_handle = UnboundWaitableDataChannelControlHandle {
5764                        inner: this.inner.clone(),
5765                    };
5766                    Ok(UnboundWaitableDataChannelRequest::GetIdentifier {
5767                        responder: UnboundWaitableDataChannelGetIdentifierResponder {
5768                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5769                            tx_id: header.tx_id,
5770                        },
5771                    })
5772                }
5773                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5774                    Ok(UnboundWaitableDataChannelRequest::_UnknownMethod {
5775                        ordinal: header.ordinal,
5776                        control_handle: UnboundWaitableDataChannelControlHandle { inner: this.inner.clone() },
5777                        method_type: fidl::MethodType::OneWay,
5778                    })
5779                }
5780                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5781                    this.inner.send_framework_err(
5782                        fidl::encoding::FrameworkErr::UnknownMethod,
5783                        header.tx_id,
5784                        header.ordinal,
5785                        header.dynamic_flags(),
5786                        (bytes, handles),
5787                    )?;
5788                    Ok(UnboundWaitableDataChannelRequest::_UnknownMethod {
5789                        ordinal: header.ordinal,
5790                        control_handle: UnboundWaitableDataChannelControlHandle { inner: this.inner.clone() },
5791                        method_type: fidl::MethodType::TwoWay,
5792                    })
5793                }
5794                _ => Err(fidl::Error::UnknownOrdinal {
5795                    ordinal: header.ordinal,
5796                    protocol_name: <UnboundWaitableDataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5797                }),
5798            }))
5799            },
5800        )
5801    }
5802}
5803
5804/// Provides both service instance disambiguation as well as a notion of a disconnected data channel
5805/// via bind interface. Callers should use this protocol to acquire a bound WaitableDataChannel.
5806#[derive(Debug)]
5807pub enum UnboundWaitableDataChannelRequest {
5808    /// Set event used to signal device state, using the signals above,
5809    /// and returns a bound client.
5810    /// Will return ZX_ERR_ALREADY_BOUND if no instances are available.
5811    Bind {
5812        payload: UnboundWaitableDataChannelBindRequest,
5813        responder: UnboundWaitableDataChannelBindResponder,
5814    },
5815    /// Returns the identifier associated with this connection.
5816    GetIdentifier { responder: UnboundWaitableDataChannelGetIdentifierResponder },
5817    /// An interaction was received which does not match any known method.
5818    #[non_exhaustive]
5819    _UnknownMethod {
5820        /// Ordinal of the method that was called.
5821        ordinal: u64,
5822        control_handle: UnboundWaitableDataChannelControlHandle,
5823        method_type: fidl::MethodType,
5824    },
5825}
5826
5827impl UnboundWaitableDataChannelRequest {
5828    #[allow(irrefutable_let_patterns)]
5829    pub fn into_bind(
5830        self,
5831    ) -> Option<(UnboundWaitableDataChannelBindRequest, UnboundWaitableDataChannelBindResponder)>
5832    {
5833        if let UnboundWaitableDataChannelRequest::Bind { payload, responder } = self {
5834            Some((payload, responder))
5835        } else {
5836            None
5837        }
5838    }
5839
5840    #[allow(irrefutable_let_patterns)]
5841    pub fn into_get_identifier(self) -> Option<(UnboundWaitableDataChannelGetIdentifierResponder)> {
5842        if let UnboundWaitableDataChannelRequest::GetIdentifier { responder } = self {
5843            Some((responder))
5844        } else {
5845            None
5846        }
5847    }
5848
5849    /// Name of the method defined in FIDL
5850    pub fn method_name(&self) -> &'static str {
5851        match *self {
5852            UnboundWaitableDataChannelRequest::Bind { .. } => "bind",
5853            UnboundWaitableDataChannelRequest::GetIdentifier { .. } => "get_identifier",
5854            UnboundWaitableDataChannelRequest::_UnknownMethod {
5855                method_type: fidl::MethodType::OneWay,
5856                ..
5857            } => "unknown one-way method",
5858            UnboundWaitableDataChannelRequest::_UnknownMethod {
5859                method_type: fidl::MethodType::TwoWay,
5860                ..
5861            } => "unknown two-way method",
5862        }
5863    }
5864}
5865
5866#[derive(Debug, Clone)]
5867pub struct UnboundWaitableDataChannelControlHandle {
5868    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5869}
5870
5871impl UnboundWaitableDataChannelControlHandle {
5872    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
5873        self.inner.shutdown_with_epitaph(status.into())
5874    }
5875}
5876
5877impl fidl::endpoints::ControlHandle for UnboundWaitableDataChannelControlHandle {
5878    fn shutdown(&self) {
5879        self.inner.shutdown()
5880    }
5881
5882    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
5883        self.inner.shutdown_with_epitaph(status)
5884    }
5885
5886    fn is_closed(&self) -> bool {
5887        self.inner.channel().is_closed()
5888    }
5889    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5890        self.inner.channel().on_closed()
5891    }
5892
5893    #[cfg(target_os = "fuchsia")]
5894    fn signal_peer(
5895        &self,
5896        clear_mask: zx::Signals,
5897        set_mask: zx::Signals,
5898    ) -> Result<(), zx_status::Status> {
5899        use fidl::Peered;
5900        self.inner.channel().signal_peer(clear_mask, set_mask)
5901    }
5902}
5903
5904impl UnboundWaitableDataChannelControlHandle {}
5905
5906#[must_use = "FIDL methods require a response to be sent"]
5907#[derive(Debug)]
5908pub struct UnboundWaitableDataChannelBindResponder {
5909    control_handle: std::mem::ManuallyDrop<UnboundWaitableDataChannelControlHandle>,
5910    tx_id: u32,
5911}
5912
5913/// Set the the channel to be shutdown (see [`UnboundWaitableDataChannelControlHandle::shutdown`])
5914/// if the responder is dropped without sending a response, so that the client
5915/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5916impl std::ops::Drop for UnboundWaitableDataChannelBindResponder {
5917    fn drop(&mut self) {
5918        self.control_handle.shutdown();
5919        // Safety: drops once, never accessed again
5920        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5921    }
5922}
5923
5924impl fidl::endpoints::Responder for UnboundWaitableDataChannelBindResponder {
5925    type ControlHandle = UnboundWaitableDataChannelControlHandle;
5926
5927    fn control_handle(&self) -> &UnboundWaitableDataChannelControlHandle {
5928        &self.control_handle
5929    }
5930
5931    fn drop_without_shutdown(mut self) {
5932        // Safety: drops once, never accessed again due to mem::forget
5933        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5934        // Prevent Drop from running (which would shut down the channel)
5935        std::mem::forget(self);
5936    }
5937}
5938
5939impl UnboundWaitableDataChannelBindResponder {
5940    /// Sends a response to the FIDL transaction.
5941    ///
5942    /// Sets the channel to shutdown if an error occurs.
5943    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5944        let _result = self.send_raw(result);
5945        if _result.is_err() {
5946            self.control_handle.shutdown();
5947        }
5948        self.drop_without_shutdown();
5949        _result
5950    }
5951
5952    /// Similar to "send" but does not shutdown the channel if an error occurs.
5953    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5954        let _result = self.send_raw(result);
5955        self.drop_without_shutdown();
5956        _result
5957    }
5958
5959    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5960        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5961            fidl::encoding::EmptyStruct,
5962            i32,
5963        >>(
5964            fidl::encoding::FlexibleResult::new(result),
5965            self.tx_id,
5966            0x135713194412491e,
5967            fidl::encoding::DynamicFlags::FLEXIBLE,
5968        )
5969    }
5970}
5971
5972#[must_use = "FIDL methods require a response to be sent"]
5973#[derive(Debug)]
5974pub struct UnboundWaitableDataChannelGetIdentifierResponder {
5975    control_handle: std::mem::ManuallyDrop<UnboundWaitableDataChannelControlHandle>,
5976    tx_id: u32,
5977}
5978
5979/// Set the the channel to be shutdown (see [`UnboundWaitableDataChannelControlHandle::shutdown`])
5980/// if the responder is dropped without sending a response, so that the client
5981/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5982impl std::ops::Drop for UnboundWaitableDataChannelGetIdentifierResponder {
5983    fn drop(&mut self) {
5984        self.control_handle.shutdown();
5985        // Safety: drops once, never accessed again
5986        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5987    }
5988}
5989
5990impl fidl::endpoints::Responder for UnboundWaitableDataChannelGetIdentifierResponder {
5991    type ControlHandle = UnboundWaitableDataChannelControlHandle;
5992
5993    fn control_handle(&self) -> &UnboundWaitableDataChannelControlHandle {
5994        &self.control_handle
5995    }
5996
5997    fn drop_without_shutdown(mut self) {
5998        // Safety: drops once, never accessed again due to mem::forget
5999        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6000        // Prevent Drop from running (which would shut down the channel)
6001        std::mem::forget(self);
6002    }
6003}
6004
6005impl UnboundWaitableDataChannelGetIdentifierResponder {
6006    /// Sends a response to the FIDL transaction.
6007    ///
6008    /// Sets the channel to shutdown if an error occurs.
6009    pub fn send(
6010        self,
6011        mut payload: &UnboundWaitableDataChannelGetIdentifierResponse,
6012    ) -> Result<(), fidl::Error> {
6013        let _result = self.send_raw(payload);
6014        if _result.is_err() {
6015            self.control_handle.shutdown();
6016        }
6017        self.drop_without_shutdown();
6018        _result
6019    }
6020
6021    /// Similar to "send" but does not shutdown the channel if an error occurs.
6022    pub fn send_no_shutdown_on_err(
6023        self,
6024        mut payload: &UnboundWaitableDataChannelGetIdentifierResponse,
6025    ) -> Result<(), fidl::Error> {
6026        let _result = self.send_raw(payload);
6027        self.drop_without_shutdown();
6028        _result
6029    }
6030
6031    fn send_raw(
6032        &self,
6033        mut payload: &UnboundWaitableDataChannelGetIdentifierResponse,
6034    ) -> Result<(), fidl::Error> {
6035        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
6036            UnboundWaitableDataChannelGetIdentifierResponse,
6037        >>(
6038            fidl::encoding::Flexible::new(payload),
6039            self.tx_id,
6040            0x6a36e55ac6beb9d6,
6041            fidl::encoding::DynamicFlags::FLEXIBLE,
6042        )
6043    }
6044}
6045
6046#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6047pub struct WaitableDataChannelMarker;
6048
6049impl fidl::endpoints::ProtocolMarker for WaitableDataChannelMarker {
6050    type Proxy = WaitableDataChannelProxy;
6051    type RequestStream = WaitableDataChannelRequestStream;
6052    #[cfg(target_os = "fuchsia")]
6053    type SynchronousProxy = WaitableDataChannelSynchronousProxy;
6054
6055    const DEBUG_NAME: &'static str = "(anonymous) WaitableDataChannel";
6056}
6057pub type WaitableDataChannelReadResult = Result<WaitableDataChannelReadResponse, i32>;
6058pub type WaitableDataChannelWriteResult = Result<(), i32>;
6059
6060pub trait WaitableDataChannelProxyInterface: Send + Sync {
6061    type ReadResponseFut: std::future::Future<Output = Result<WaitableDataChannelReadResult, fidl::Error>>
6062        + Send;
6063    fn r#read(&self) -> Self::ReadResponseFut;
6064    type WriteResponseFut: std::future::Future<Output = Result<WaitableDataChannelWriteResult, fidl::Error>>
6065        + Send;
6066    fn r#write(&self, payload: &WaitableDataChannelWriteRequest) -> Self::WriteResponseFut;
6067}
6068#[derive(Debug)]
6069#[cfg(target_os = "fuchsia")]
6070pub struct WaitableDataChannelSynchronousProxy {
6071    client: fidl::client::sync::Client,
6072}
6073
6074#[cfg(target_os = "fuchsia")]
6075impl fidl::endpoints::SynchronousProxy for WaitableDataChannelSynchronousProxy {
6076    type Proxy = WaitableDataChannelProxy;
6077    type Protocol = WaitableDataChannelMarker;
6078
6079    fn from_channel(inner: fidl::Channel) -> Self {
6080        Self::new(inner)
6081    }
6082
6083    fn into_channel(self) -> fidl::Channel {
6084        self.client.into_channel()
6085    }
6086
6087    fn as_channel(&self) -> &fidl::Channel {
6088        self.client.as_channel()
6089    }
6090}
6091
6092#[cfg(target_os = "fuchsia")]
6093impl WaitableDataChannelSynchronousProxy {
6094    pub fn new(channel: fidl::Channel) -> Self {
6095        Self { client: fidl::client::sync::Client::new(channel) }
6096    }
6097
6098    pub fn into_channel(self) -> fidl::Channel {
6099        self.client.into_channel()
6100    }
6101
6102    /// Waits until an event arrives and returns it. It is safe for other
6103    /// threads to make concurrent requests while waiting for an event.
6104    pub fn wait_for_event(
6105        &self,
6106        deadline: zx::MonotonicInstant,
6107    ) -> Result<WaitableDataChannelEvent, fidl::Error> {
6108        WaitableDataChannelEvent::decode(
6109            self.client.wait_for_event::<WaitableDataChannelMarker>(deadline)?,
6110        )
6111    }
6112
6113    /// The call will return the next datagram to be read from the channel.
6114    /// If there is more data to be read, SIGNAL_READABLE will remain asserted
6115    /// after this call returns.
6116    /// If there is no data to be read, this call will return ZX_ERR_SHOULD_WAIT
6117    pub fn r#read(
6118        &self,
6119        ___deadline: zx::MonotonicInstant,
6120    ) -> Result<WaitableDataChannelReadResult, fidl::Error> {
6121        let _response = self.client.send_query::<
6122            fidl::encoding::EmptyPayload,
6123            fidl::encoding::FlexibleResultType<WaitableDataChannelReadResponse, i32>,
6124            WaitableDataChannelMarker,
6125        >(
6126            (),
6127            0x48f55df455309245,
6128            fidl::encoding::DynamicFlags::FLEXIBLE,
6129            ___deadline,
6130        )?
6131        .into_result::<WaitableDataChannelMarker>("read")?;
6132        Ok(_response.map(|x| x))
6133    }
6134
6135    /// The call will return once the data is fully committed.
6136    ///
6137    /// If the driver is not ready for a write, it will return
6138    /// ZX_ERR_NO_RESOURCES and the caller should await SIGNAL_WRITABLE to be
6139    /// asserted.
6140    pub fn r#write(
6141        &self,
6142        mut payload: &WaitableDataChannelWriteRequest,
6143        ___deadline: zx::MonotonicInstant,
6144    ) -> Result<WaitableDataChannelWriteResult, fidl::Error> {
6145        let _response = self.client.send_query::<
6146            WaitableDataChannelWriteRequest,
6147            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
6148            WaitableDataChannelMarker,
6149        >(
6150            payload,
6151            0x6d9b754b0e3122f2,
6152            fidl::encoding::DynamicFlags::FLEXIBLE,
6153            ___deadline,
6154        )?
6155        .into_result::<WaitableDataChannelMarker>("write")?;
6156        Ok(_response.map(|x| x))
6157    }
6158}
6159
6160#[cfg(target_os = "fuchsia")]
6161impl From<WaitableDataChannelSynchronousProxy> for zx::NullableHandle {
6162    fn from(value: WaitableDataChannelSynchronousProxy) -> Self {
6163        value.into_channel().into()
6164    }
6165}
6166
6167#[cfg(target_os = "fuchsia")]
6168impl From<fidl::Channel> for WaitableDataChannelSynchronousProxy {
6169    fn from(value: fidl::Channel) -> Self {
6170        Self::new(value)
6171    }
6172}
6173
6174#[cfg(target_os = "fuchsia")]
6175impl fidl::endpoints::FromClient for WaitableDataChannelSynchronousProxy {
6176    type Protocol = WaitableDataChannelMarker;
6177
6178    fn from_client(value: fidl::endpoints::ClientEnd<WaitableDataChannelMarker>) -> Self {
6179        Self::new(value.into_channel())
6180    }
6181}
6182
6183#[derive(Debug, Clone)]
6184pub struct WaitableDataChannelProxy {
6185    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6186}
6187
6188impl fidl::endpoints::Proxy for WaitableDataChannelProxy {
6189    type Protocol = WaitableDataChannelMarker;
6190
6191    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6192        Self::new(inner)
6193    }
6194
6195    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6196        self.client.into_channel().map_err(|client| Self { client })
6197    }
6198
6199    fn as_channel(&self) -> &::fidl::AsyncChannel {
6200        self.client.as_channel()
6201    }
6202}
6203
6204impl WaitableDataChannelProxy {
6205    /// Create a new Proxy for fuchsia.hardware.google.nanohub/WaitableDataChannel.
6206    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6207        let protocol_name =
6208            <WaitableDataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6209        Self { client: fidl::client::Client::new(channel, protocol_name) }
6210    }
6211
6212    /// Get a Stream of events from the remote end of the protocol.
6213    ///
6214    /// # Panics
6215    ///
6216    /// Panics if the event stream was already taken.
6217    pub fn take_event_stream(&self) -> WaitableDataChannelEventStream {
6218        WaitableDataChannelEventStream { event_receiver: self.client.take_event_receiver() }
6219    }
6220
6221    /// The call will return the next datagram to be read from the channel.
6222    /// If there is more data to be read, SIGNAL_READABLE will remain asserted
6223    /// after this call returns.
6224    /// If there is no data to be read, this call will return ZX_ERR_SHOULD_WAIT
6225    pub fn r#read(
6226        &self,
6227    ) -> fidl::client::QueryResponseFut<
6228        WaitableDataChannelReadResult,
6229        fidl::encoding::DefaultFuchsiaResourceDialect,
6230    > {
6231        WaitableDataChannelProxyInterface::r#read(self)
6232    }
6233
6234    /// The call will return once the data is fully committed.
6235    ///
6236    /// If the driver is not ready for a write, it will return
6237    /// ZX_ERR_NO_RESOURCES and the caller should await SIGNAL_WRITABLE to be
6238    /// asserted.
6239    pub fn r#write(
6240        &self,
6241        mut payload: &WaitableDataChannelWriteRequest,
6242    ) -> fidl::client::QueryResponseFut<
6243        WaitableDataChannelWriteResult,
6244        fidl::encoding::DefaultFuchsiaResourceDialect,
6245    > {
6246        WaitableDataChannelProxyInterface::r#write(self, payload)
6247    }
6248}
6249
6250impl WaitableDataChannelProxyInterface for WaitableDataChannelProxy {
6251    type ReadResponseFut = fidl::client::QueryResponseFut<
6252        WaitableDataChannelReadResult,
6253        fidl::encoding::DefaultFuchsiaResourceDialect,
6254    >;
6255    fn r#read(&self) -> Self::ReadResponseFut {
6256        fn _decode(
6257            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6258        ) -> Result<WaitableDataChannelReadResult, fidl::Error> {
6259            let _response = fidl::client::decode_transaction_body::<
6260                fidl::encoding::FlexibleResultType<WaitableDataChannelReadResponse, i32>,
6261                fidl::encoding::DefaultFuchsiaResourceDialect,
6262                0x48f55df455309245,
6263            >(_buf?)?
6264            .into_result::<WaitableDataChannelMarker>("read")?;
6265            Ok(_response.map(|x| x))
6266        }
6267        self.client
6268            .send_query_and_decode::<fidl::encoding::EmptyPayload, WaitableDataChannelReadResult>(
6269                (),
6270                0x48f55df455309245,
6271                fidl::encoding::DynamicFlags::FLEXIBLE,
6272                _decode,
6273            )
6274    }
6275
6276    type WriteResponseFut = fidl::client::QueryResponseFut<
6277        WaitableDataChannelWriteResult,
6278        fidl::encoding::DefaultFuchsiaResourceDialect,
6279    >;
6280    fn r#write(&self, mut payload: &WaitableDataChannelWriteRequest) -> Self::WriteResponseFut {
6281        fn _decode(
6282            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6283        ) -> Result<WaitableDataChannelWriteResult, fidl::Error> {
6284            let _response = fidl::client::decode_transaction_body::<
6285                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
6286                fidl::encoding::DefaultFuchsiaResourceDialect,
6287                0x6d9b754b0e3122f2,
6288            >(_buf?)?
6289            .into_result::<WaitableDataChannelMarker>("write")?;
6290            Ok(_response.map(|x| x))
6291        }
6292        self.client.send_query_and_decode::<
6293            WaitableDataChannelWriteRequest,
6294            WaitableDataChannelWriteResult,
6295        >(
6296            payload,
6297            0x6d9b754b0e3122f2,
6298            fidl::encoding::DynamicFlags::FLEXIBLE,
6299            _decode,
6300        )
6301    }
6302}
6303
6304pub struct WaitableDataChannelEventStream {
6305    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6306}
6307
6308impl std::marker::Unpin for WaitableDataChannelEventStream {}
6309
6310impl futures::stream::FusedStream for WaitableDataChannelEventStream {
6311    fn is_terminated(&self) -> bool {
6312        self.event_receiver.is_terminated()
6313    }
6314}
6315
6316impl futures::Stream for WaitableDataChannelEventStream {
6317    type Item = Result<WaitableDataChannelEvent, fidl::Error>;
6318
6319    fn poll_next(
6320        mut self: std::pin::Pin<&mut Self>,
6321        cx: &mut std::task::Context<'_>,
6322    ) -> std::task::Poll<Option<Self::Item>> {
6323        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6324            &mut self.event_receiver,
6325            cx
6326        )?) {
6327            Some(buf) => std::task::Poll::Ready(Some(WaitableDataChannelEvent::decode(buf))),
6328            None => std::task::Poll::Ready(None),
6329        }
6330    }
6331}
6332
6333#[derive(Debug)]
6334pub enum WaitableDataChannelEvent {
6335    #[non_exhaustive]
6336    _UnknownEvent {
6337        /// Ordinal of the event that was sent.
6338        ordinal: u64,
6339    },
6340}
6341
6342impl WaitableDataChannelEvent {
6343    /// Decodes a message buffer as a [`WaitableDataChannelEvent`].
6344    fn decode(
6345        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6346    ) -> Result<WaitableDataChannelEvent, fidl::Error> {
6347        let (bytes, _handles) = buf.split_mut();
6348        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6349        debug_assert_eq!(tx_header.tx_id, 0);
6350        match tx_header.ordinal {
6351            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6352                Ok(WaitableDataChannelEvent::_UnknownEvent { ordinal: tx_header.ordinal })
6353            }
6354            _ => Err(fidl::Error::UnknownOrdinal {
6355                ordinal: tx_header.ordinal,
6356                protocol_name:
6357                    <WaitableDataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6358            }),
6359        }
6360    }
6361}
6362
6363/// A Stream of incoming requests for fuchsia.hardware.google.nanohub/WaitableDataChannel.
6364pub struct WaitableDataChannelRequestStream {
6365    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6366    is_terminated: bool,
6367}
6368
6369impl std::marker::Unpin for WaitableDataChannelRequestStream {}
6370
6371impl futures::stream::FusedStream for WaitableDataChannelRequestStream {
6372    fn is_terminated(&self) -> bool {
6373        self.is_terminated
6374    }
6375}
6376
6377impl fidl::endpoints::RequestStream for WaitableDataChannelRequestStream {
6378    type Protocol = WaitableDataChannelMarker;
6379    type ControlHandle = WaitableDataChannelControlHandle;
6380
6381    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6382        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6383    }
6384
6385    fn control_handle(&self) -> Self::ControlHandle {
6386        WaitableDataChannelControlHandle { inner: self.inner.clone() }
6387    }
6388
6389    fn into_inner(
6390        self,
6391    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6392    {
6393        (self.inner, self.is_terminated)
6394    }
6395
6396    fn from_inner(
6397        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6398        is_terminated: bool,
6399    ) -> Self {
6400        Self { inner, is_terminated }
6401    }
6402}
6403
6404impl futures::Stream for WaitableDataChannelRequestStream {
6405    type Item = Result<WaitableDataChannelRequest, fidl::Error>;
6406
6407    fn poll_next(
6408        mut self: std::pin::Pin<&mut Self>,
6409        cx: &mut std::task::Context<'_>,
6410    ) -> std::task::Poll<Option<Self::Item>> {
6411        let this = &mut *self;
6412        if this.inner.check_shutdown(cx) {
6413            this.is_terminated = true;
6414            return std::task::Poll::Ready(None);
6415        }
6416        if this.is_terminated {
6417            panic!("polled WaitableDataChannelRequestStream after completion");
6418        }
6419        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6420            |bytes, handles| {
6421                match this.inner.channel().read_etc(cx, bytes, handles) {
6422                    std::task::Poll::Ready(Ok(())) => {}
6423                    std::task::Poll::Pending => return std::task::Poll::Pending,
6424                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6425                        this.is_terminated = true;
6426                        return std::task::Poll::Ready(None);
6427                    }
6428                    std::task::Poll::Ready(Err(e)) => {
6429                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6430                            e.into(),
6431                        ))));
6432                    }
6433                }
6434
6435                // A message has been received from the channel
6436                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6437
6438                std::task::Poll::Ready(Some(match header.ordinal {
6439                0x48f55df455309245 => {
6440                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6441                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
6442                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6443                    let control_handle = WaitableDataChannelControlHandle {
6444                        inner: this.inner.clone(),
6445                    };
6446                    Ok(WaitableDataChannelRequest::Read {
6447                        responder: WaitableDataChannelReadResponder {
6448                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6449                            tx_id: header.tx_id,
6450                        },
6451                    })
6452                }
6453                0x6d9b754b0e3122f2 => {
6454                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6455                    let mut req = fidl::new_empty!(WaitableDataChannelWriteRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
6456                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WaitableDataChannelWriteRequest>(&header, _body_bytes, handles, &mut req)?;
6457                    let control_handle = WaitableDataChannelControlHandle {
6458                        inner: this.inner.clone(),
6459                    };
6460                    Ok(WaitableDataChannelRequest::Write {payload: req,
6461                        responder: WaitableDataChannelWriteResponder {
6462                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6463                            tx_id: header.tx_id,
6464                        },
6465                    })
6466                }
6467                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6468                    Ok(WaitableDataChannelRequest::_UnknownMethod {
6469                        ordinal: header.ordinal,
6470                        control_handle: WaitableDataChannelControlHandle { inner: this.inner.clone() },
6471                        method_type: fidl::MethodType::OneWay,
6472                    })
6473                }
6474                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6475                    this.inner.send_framework_err(
6476                        fidl::encoding::FrameworkErr::UnknownMethod,
6477                        header.tx_id,
6478                        header.ordinal,
6479                        header.dynamic_flags(),
6480                        (bytes, handles),
6481                    )?;
6482                    Ok(WaitableDataChannelRequest::_UnknownMethod {
6483                        ordinal: header.ordinal,
6484                        control_handle: WaitableDataChannelControlHandle { inner: this.inner.clone() },
6485                        method_type: fidl::MethodType::TwoWay,
6486                    })
6487                }
6488                _ => Err(fidl::Error::UnknownOrdinal {
6489                    ordinal: header.ordinal,
6490                    protocol_name: <WaitableDataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6491                }),
6492            }))
6493            },
6494        )
6495    }
6496}
6497
6498/// Provides a bound / connected session to a particular DataChannel. New connections should use the
6499/// UnboundWaitableDataChannel to open a session of this procotol.
6500/// Calls to Read() on a WaitableDataChannel will operate as a non-blocking operation. Callers
6501/// will need to use the event exchanged in the Bind() call to flag when data is available to read
6502#[derive(Debug)]
6503pub enum WaitableDataChannelRequest {
6504    /// The call will return the next datagram to be read from the channel.
6505    /// If there is more data to be read, SIGNAL_READABLE will remain asserted
6506    /// after this call returns.
6507    /// If there is no data to be read, this call will return ZX_ERR_SHOULD_WAIT
6508    Read { responder: WaitableDataChannelReadResponder },
6509    /// The call will return once the data is fully committed.
6510    ///
6511    /// If the driver is not ready for a write, it will return
6512    /// ZX_ERR_NO_RESOURCES and the caller should await SIGNAL_WRITABLE to be
6513    /// asserted.
6514    Write { payload: WaitableDataChannelWriteRequest, responder: WaitableDataChannelWriteResponder },
6515    /// An interaction was received which does not match any known method.
6516    #[non_exhaustive]
6517    _UnknownMethod {
6518        /// Ordinal of the method that was called.
6519        ordinal: u64,
6520        control_handle: WaitableDataChannelControlHandle,
6521        method_type: fidl::MethodType,
6522    },
6523}
6524
6525impl WaitableDataChannelRequest {
6526    #[allow(irrefutable_let_patterns)]
6527    pub fn into_read(self) -> Option<(WaitableDataChannelReadResponder)> {
6528        if let WaitableDataChannelRequest::Read { responder } = self {
6529            Some((responder))
6530        } else {
6531            None
6532        }
6533    }
6534
6535    #[allow(irrefutable_let_patterns)]
6536    pub fn into_write(
6537        self,
6538    ) -> Option<(WaitableDataChannelWriteRequest, WaitableDataChannelWriteResponder)> {
6539        if let WaitableDataChannelRequest::Write { payload, responder } = self {
6540            Some((payload, responder))
6541        } else {
6542            None
6543        }
6544    }
6545
6546    /// Name of the method defined in FIDL
6547    pub fn method_name(&self) -> &'static str {
6548        match *self {
6549            WaitableDataChannelRequest::Read { .. } => "read",
6550            WaitableDataChannelRequest::Write { .. } => "write",
6551            WaitableDataChannelRequest::_UnknownMethod {
6552                method_type: fidl::MethodType::OneWay,
6553                ..
6554            } => "unknown one-way method",
6555            WaitableDataChannelRequest::_UnknownMethod {
6556                method_type: fidl::MethodType::TwoWay,
6557                ..
6558            } => "unknown two-way method",
6559        }
6560    }
6561}
6562
6563#[derive(Debug, Clone)]
6564pub struct WaitableDataChannelControlHandle {
6565    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6566}
6567
6568impl WaitableDataChannelControlHandle {
6569    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6570        self.inner.shutdown_with_epitaph(status.into())
6571    }
6572}
6573
6574impl fidl::endpoints::ControlHandle for WaitableDataChannelControlHandle {
6575    fn shutdown(&self) {
6576        self.inner.shutdown()
6577    }
6578
6579    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6580        self.inner.shutdown_with_epitaph(status)
6581    }
6582
6583    fn is_closed(&self) -> bool {
6584        self.inner.channel().is_closed()
6585    }
6586    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6587        self.inner.channel().on_closed()
6588    }
6589
6590    #[cfg(target_os = "fuchsia")]
6591    fn signal_peer(
6592        &self,
6593        clear_mask: zx::Signals,
6594        set_mask: zx::Signals,
6595    ) -> Result<(), zx_status::Status> {
6596        use fidl::Peered;
6597        self.inner.channel().signal_peer(clear_mask, set_mask)
6598    }
6599}
6600
6601impl WaitableDataChannelControlHandle {}
6602
6603#[must_use = "FIDL methods require a response to be sent"]
6604#[derive(Debug)]
6605pub struct WaitableDataChannelReadResponder {
6606    control_handle: std::mem::ManuallyDrop<WaitableDataChannelControlHandle>,
6607    tx_id: u32,
6608}
6609
6610/// Set the the channel to be shutdown (see [`WaitableDataChannelControlHandle::shutdown`])
6611/// if the responder is dropped without sending a response, so that the client
6612/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6613impl std::ops::Drop for WaitableDataChannelReadResponder {
6614    fn drop(&mut self) {
6615        self.control_handle.shutdown();
6616        // Safety: drops once, never accessed again
6617        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6618    }
6619}
6620
6621impl fidl::endpoints::Responder for WaitableDataChannelReadResponder {
6622    type ControlHandle = WaitableDataChannelControlHandle;
6623
6624    fn control_handle(&self) -> &WaitableDataChannelControlHandle {
6625        &self.control_handle
6626    }
6627
6628    fn drop_without_shutdown(mut self) {
6629        // Safety: drops once, never accessed again due to mem::forget
6630        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6631        // Prevent Drop from running (which would shut down the channel)
6632        std::mem::forget(self);
6633    }
6634}
6635
6636impl WaitableDataChannelReadResponder {
6637    /// Sends a response to the FIDL transaction.
6638    ///
6639    /// Sets the channel to shutdown if an error occurs.
6640    pub fn send(
6641        self,
6642        mut result: Result<WaitableDataChannelReadResponse, i32>,
6643    ) -> Result<(), fidl::Error> {
6644        let _result = self.send_raw(result);
6645        if _result.is_err() {
6646            self.control_handle.shutdown();
6647        }
6648        self.drop_without_shutdown();
6649        _result
6650    }
6651
6652    /// Similar to "send" but does not shutdown the channel if an error occurs.
6653    pub fn send_no_shutdown_on_err(
6654        self,
6655        mut result: Result<WaitableDataChannelReadResponse, i32>,
6656    ) -> Result<(), fidl::Error> {
6657        let _result = self.send_raw(result);
6658        self.drop_without_shutdown();
6659        _result
6660    }
6661
6662    fn send_raw(
6663        &self,
6664        mut result: Result<WaitableDataChannelReadResponse, i32>,
6665    ) -> Result<(), fidl::Error> {
6666        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6667            WaitableDataChannelReadResponse,
6668            i32,
6669        >>(
6670            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
6671            self.tx_id,
6672            0x48f55df455309245,
6673            fidl::encoding::DynamicFlags::FLEXIBLE,
6674        )
6675    }
6676}
6677
6678#[must_use = "FIDL methods require a response to be sent"]
6679#[derive(Debug)]
6680pub struct WaitableDataChannelWriteResponder {
6681    control_handle: std::mem::ManuallyDrop<WaitableDataChannelControlHandle>,
6682    tx_id: u32,
6683}
6684
6685/// Set the the channel to be shutdown (see [`WaitableDataChannelControlHandle::shutdown`])
6686/// if the responder is dropped without sending a response, so that the client
6687/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6688impl std::ops::Drop for WaitableDataChannelWriteResponder {
6689    fn drop(&mut self) {
6690        self.control_handle.shutdown();
6691        // Safety: drops once, never accessed again
6692        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6693    }
6694}
6695
6696impl fidl::endpoints::Responder for WaitableDataChannelWriteResponder {
6697    type ControlHandle = WaitableDataChannelControlHandle;
6698
6699    fn control_handle(&self) -> &WaitableDataChannelControlHandle {
6700        &self.control_handle
6701    }
6702
6703    fn drop_without_shutdown(mut self) {
6704        // Safety: drops once, never accessed again due to mem::forget
6705        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6706        // Prevent Drop from running (which would shut down the channel)
6707        std::mem::forget(self);
6708    }
6709}
6710
6711impl WaitableDataChannelWriteResponder {
6712    /// Sends a response to the FIDL transaction.
6713    ///
6714    /// Sets the channel to shutdown if an error occurs.
6715    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6716        let _result = self.send_raw(result);
6717        if _result.is_err() {
6718            self.control_handle.shutdown();
6719        }
6720        self.drop_without_shutdown();
6721        _result
6722    }
6723
6724    /// Similar to "send" but does not shutdown the channel if an error occurs.
6725    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6726        let _result = self.send_raw(result);
6727        self.drop_without_shutdown();
6728        _result
6729    }
6730
6731    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6732        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6733            fidl::encoding::EmptyStruct,
6734            i32,
6735        >>(
6736            fidl::encoding::FlexibleResult::new(result),
6737            self.tx_id,
6738            0x6d9b754b0e3122f2,
6739            fidl::encoding::DynamicFlags::FLEXIBLE,
6740        )
6741    }
6742}
6743
6744#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6745pub struct DataChannelServiceMarker;
6746
6747#[cfg(target_os = "fuchsia")]
6748impl fidl::endpoints::ServiceMarker for DataChannelServiceMarker {
6749    type Proxy = DataChannelServiceProxy;
6750    type Request = DataChannelServiceRequest;
6751    const SERVICE_NAME: &'static str = "fuchsia.hardware.google.nanohub.DataChannelService";
6752}
6753
6754/// A request for one of the member protocols of DataChannelService.
6755///
6756/// Service for clients.
6757///
6758/// The data channel is pre-bound to a particular identifier as per bind rules.
6759#[cfg(target_os = "fuchsia")]
6760pub enum DataChannelServiceRequest {
6761    Device(DataChannelRequestStream),
6762    Lifecycle(LifecycleObserverRequestStream),
6763}
6764
6765#[cfg(target_os = "fuchsia")]
6766impl fidl::endpoints::ServiceRequest for DataChannelServiceRequest {
6767    type Service = DataChannelServiceMarker;
6768
6769    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
6770        match name {
6771            "device" => Self::Device(
6772                <DataChannelRequestStream as fidl::endpoints::RequestStream>::from_channel(
6773                    _channel,
6774                ),
6775            ),
6776            "lifecycle" => Self::Lifecycle(
6777                <LifecycleObserverRequestStream as fidl::endpoints::RequestStream>::from_channel(
6778                    _channel,
6779                ),
6780            ),
6781            _ => panic!("no such member protocol name for service DataChannelService"),
6782        }
6783    }
6784
6785    fn member_names() -> &'static [&'static str] {
6786        &["device", "lifecycle"]
6787    }
6788}
6789/// Service for clients.
6790///
6791/// The data channel is pre-bound to a particular identifier as per bind rules.
6792#[cfg(target_os = "fuchsia")]
6793pub struct DataChannelServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
6794
6795#[cfg(target_os = "fuchsia")]
6796impl fidl::endpoints::ServiceProxy for DataChannelServiceProxy {
6797    type Service = DataChannelServiceMarker;
6798
6799    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
6800        Self(opener)
6801    }
6802}
6803
6804#[cfg(target_os = "fuchsia")]
6805impl DataChannelServiceProxy {
6806    pub fn connect_to_device(&self) -> Result<DataChannelProxy, fidl::Error> {
6807        let (proxy, server_end) = fidl::endpoints::create_proxy::<DataChannelMarker>();
6808        self.connect_channel_to_device(server_end)?;
6809        Ok(proxy)
6810    }
6811
6812    /// Like `connect_to_device`, but returns a sync proxy.
6813    /// See [`Self::connect_to_device`] for more details.
6814    pub fn connect_to_device_sync(&self) -> Result<DataChannelSynchronousProxy, fidl::Error> {
6815        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DataChannelMarker>();
6816        self.connect_channel_to_device(server_end)?;
6817        Ok(proxy)
6818    }
6819
6820    /// Like `connect_to_device`, but accepts a server end.
6821    /// See [`Self::connect_to_device`] for more details.
6822    pub fn connect_channel_to_device(
6823        &self,
6824        server_end: fidl::endpoints::ServerEnd<DataChannelMarker>,
6825    ) -> Result<(), fidl::Error> {
6826        self.0.open_member("device", server_end.into_channel())
6827    }
6828    pub fn connect_to_lifecycle(&self) -> Result<LifecycleObserverProxy, fidl::Error> {
6829        let (proxy, server_end) = fidl::endpoints::create_proxy::<LifecycleObserverMarker>();
6830        self.connect_channel_to_lifecycle(server_end)?;
6831        Ok(proxy)
6832    }
6833
6834    /// Like `connect_to_lifecycle`, but returns a sync proxy.
6835    /// See [`Self::connect_to_lifecycle`] for more details.
6836    pub fn connect_to_lifecycle_sync(
6837        &self,
6838    ) -> Result<LifecycleObserverSynchronousProxy, fidl::Error> {
6839        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<LifecycleObserverMarker>();
6840        self.connect_channel_to_lifecycle(server_end)?;
6841        Ok(proxy)
6842    }
6843
6844    /// Like `connect_to_lifecycle`, but accepts a server end.
6845    /// See [`Self::connect_to_lifecycle`] for more details.
6846    pub fn connect_channel_to_lifecycle(
6847        &self,
6848        server_end: fidl::endpoints::ServerEnd<LifecycleObserverMarker>,
6849    ) -> Result<(), fidl::Error> {
6850        self.0.open_member("lifecycle", server_end.into_channel())
6851    }
6852
6853    pub fn instance_name(&self) -> &str {
6854        self.0.instance_name()
6855    }
6856}
6857
6858#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6859pub struct DisplayServiceMarker;
6860
6861#[cfg(target_os = "fuchsia")]
6862impl fidl::endpoints::ServiceMarker for DisplayServiceMarker {
6863    type Proxy = DisplayServiceProxy;
6864    type Request = DisplayServiceRequest;
6865    const SERVICE_NAME: &'static str = "fuchsia.hardware.google.nanohub.DisplayService";
6866}
6867
6868/// A request for one of the member protocols of DisplayService.
6869///
6870/// The service that provides access to the display device.
6871#[cfg(target_os = "fuchsia")]
6872pub enum DisplayServiceRequest {
6873    /// The display device.
6874    Mcudisplay(DisplayDeviceRequestStream),
6875}
6876
6877#[cfg(target_os = "fuchsia")]
6878impl fidl::endpoints::ServiceRequest for DisplayServiceRequest {
6879    type Service = DisplayServiceMarker;
6880
6881    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
6882        match name {
6883            "mcudisplay" => Self::Mcudisplay(
6884                <DisplayDeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(
6885                    _channel,
6886                ),
6887            ),
6888            _ => panic!("no such member protocol name for service DisplayService"),
6889        }
6890    }
6891
6892    fn member_names() -> &'static [&'static str] {
6893        &["mcudisplay"]
6894    }
6895}
6896/// The service that provides access to the display device.
6897#[cfg(target_os = "fuchsia")]
6898pub struct DisplayServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
6899
6900#[cfg(target_os = "fuchsia")]
6901impl fidl::endpoints::ServiceProxy for DisplayServiceProxy {
6902    type Service = DisplayServiceMarker;
6903
6904    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
6905        Self(opener)
6906    }
6907}
6908
6909#[cfg(target_os = "fuchsia")]
6910impl DisplayServiceProxy {
6911    /// The display device.
6912    pub fn connect_to_mcudisplay(&self) -> Result<DisplayDeviceProxy, fidl::Error> {
6913        let (proxy, server_end) = fidl::endpoints::create_proxy::<DisplayDeviceMarker>();
6914        self.connect_channel_to_mcudisplay(server_end)?;
6915        Ok(proxy)
6916    }
6917
6918    /// Like `connect_to_mcudisplay`, but returns a sync proxy.
6919    /// See [`Self::connect_to_mcudisplay`] for more details.
6920    pub fn connect_to_mcudisplay_sync(&self) -> Result<DisplayDeviceSynchronousProxy, fidl::Error> {
6921        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DisplayDeviceMarker>();
6922        self.connect_channel_to_mcudisplay(server_end)?;
6923        Ok(proxy)
6924    }
6925
6926    /// Like `connect_to_mcudisplay`, but accepts a server end.
6927    /// See [`Self::connect_to_mcudisplay`] for more details.
6928    pub fn connect_channel_to_mcudisplay(
6929        &self,
6930        server_end: fidl::endpoints::ServerEnd<DisplayDeviceMarker>,
6931    ) -> Result<(), fidl::Error> {
6932        self.0.open_member("mcudisplay", server_end.into_channel())
6933    }
6934
6935    pub fn instance_name(&self) -> &str {
6936        self.0.instance_name()
6937    }
6938}
6939
6940#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6941pub struct DriverDataChannelServiceMarker;
6942
6943#[cfg(target_os = "fuchsia")]
6944impl fidl::endpoints::ServiceMarker for DriverDataChannelServiceMarker {
6945    type Proxy = DriverDataChannelServiceProxy;
6946    type Request = DriverDataChannelServiceRequest;
6947    const SERVICE_NAME: &'static str = "fuchsia.hardware.google.nanohub.DriverDataChannelService";
6948}
6949
6950/// A request for one of the member protocols of DriverDataChannelService.
6951///
6952/// Service for driver clients.
6953#[cfg(target_os = "fuchsia")]
6954pub enum DriverDataChannelServiceRequest {
6955    Hanging(UnboundHangingDataChannelRequestStream),
6956    Waitable(UnboundWaitableDataChannelRequestStream),
6957    Lifecycle(LifecycleObserverRequestStream),
6958}
6959
6960#[cfg(target_os = "fuchsia")]
6961impl fidl::endpoints::ServiceRequest for DriverDataChannelServiceRequest {
6962    type Service = DriverDataChannelServiceMarker;
6963
6964    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
6965        match name {
6966            "hanging" => Self::Hanging(
6967                <UnboundHangingDataChannelRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
6968            ),
6969            "waitable" => Self::Waitable(
6970                <UnboundWaitableDataChannelRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
6971            ),
6972            "lifecycle" => Self::Lifecycle(
6973                <LifecycleObserverRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
6974            ),
6975            _ => panic!("no such member protocol name for service DriverDataChannelService"),
6976        }
6977    }
6978
6979    fn member_names() -> &'static [&'static str] {
6980        &["hanging", "waitable", "lifecycle"]
6981    }
6982}
6983/// Service for driver clients.
6984#[cfg(target_os = "fuchsia")]
6985pub struct DriverDataChannelServiceProxy(
6986    #[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>,
6987);
6988
6989#[cfg(target_os = "fuchsia")]
6990impl fidl::endpoints::ServiceProxy for DriverDataChannelServiceProxy {
6991    type Service = DriverDataChannelServiceMarker;
6992
6993    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
6994        Self(opener)
6995    }
6996}
6997
6998#[cfg(target_os = "fuchsia")]
6999impl DriverDataChannelServiceProxy {
7000    pub fn connect_to_hanging(&self) -> Result<UnboundHangingDataChannelProxy, fidl::Error> {
7001        let (proxy, server_end) =
7002            fidl::endpoints::create_proxy::<UnboundHangingDataChannelMarker>();
7003        self.connect_channel_to_hanging(server_end)?;
7004        Ok(proxy)
7005    }
7006
7007    /// Like `connect_to_hanging`, but returns a sync proxy.
7008    /// See [`Self::connect_to_hanging`] for more details.
7009    pub fn connect_to_hanging_sync(
7010        &self,
7011    ) -> Result<UnboundHangingDataChannelSynchronousProxy, fidl::Error> {
7012        let (proxy, server_end) =
7013            fidl::endpoints::create_sync_proxy::<UnboundHangingDataChannelMarker>();
7014        self.connect_channel_to_hanging(server_end)?;
7015        Ok(proxy)
7016    }
7017
7018    /// Like `connect_to_hanging`, but accepts a server end.
7019    /// See [`Self::connect_to_hanging`] for more details.
7020    pub fn connect_channel_to_hanging(
7021        &self,
7022        server_end: fidl::endpoints::ServerEnd<UnboundHangingDataChannelMarker>,
7023    ) -> Result<(), fidl::Error> {
7024        self.0.open_member("hanging", server_end.into_channel())
7025    }
7026    pub fn connect_to_waitable(&self) -> Result<UnboundWaitableDataChannelProxy, fidl::Error> {
7027        let (proxy, server_end) =
7028            fidl::endpoints::create_proxy::<UnboundWaitableDataChannelMarker>();
7029        self.connect_channel_to_waitable(server_end)?;
7030        Ok(proxy)
7031    }
7032
7033    /// Like `connect_to_waitable`, but returns a sync proxy.
7034    /// See [`Self::connect_to_waitable`] for more details.
7035    pub fn connect_to_waitable_sync(
7036        &self,
7037    ) -> Result<UnboundWaitableDataChannelSynchronousProxy, fidl::Error> {
7038        let (proxy, server_end) =
7039            fidl::endpoints::create_sync_proxy::<UnboundWaitableDataChannelMarker>();
7040        self.connect_channel_to_waitable(server_end)?;
7041        Ok(proxy)
7042    }
7043
7044    /// Like `connect_to_waitable`, but accepts a server end.
7045    /// See [`Self::connect_to_waitable`] for more details.
7046    pub fn connect_channel_to_waitable(
7047        &self,
7048        server_end: fidl::endpoints::ServerEnd<UnboundWaitableDataChannelMarker>,
7049    ) -> Result<(), fidl::Error> {
7050        self.0.open_member("waitable", server_end.into_channel())
7051    }
7052    pub fn connect_to_lifecycle(&self) -> Result<LifecycleObserverProxy, fidl::Error> {
7053        let (proxy, server_end) = fidl::endpoints::create_proxy::<LifecycleObserverMarker>();
7054        self.connect_channel_to_lifecycle(server_end)?;
7055        Ok(proxy)
7056    }
7057
7058    /// Like `connect_to_lifecycle`, but returns a sync proxy.
7059    /// See [`Self::connect_to_lifecycle`] for more details.
7060    pub fn connect_to_lifecycle_sync(
7061        &self,
7062    ) -> Result<LifecycleObserverSynchronousProxy, fidl::Error> {
7063        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<LifecycleObserverMarker>();
7064        self.connect_channel_to_lifecycle(server_end)?;
7065        Ok(proxy)
7066    }
7067
7068    /// Like `connect_to_lifecycle`, but accepts a server end.
7069    /// See [`Self::connect_to_lifecycle`] for more details.
7070    pub fn connect_channel_to_lifecycle(
7071        &self,
7072        server_end: fidl::endpoints::ServerEnd<LifecycleObserverMarker>,
7073    ) -> Result<(), fidl::Error> {
7074        self.0.open_member("lifecycle", server_end.into_channel())
7075    }
7076
7077    pub fn instance_name(&self) -> &str {
7078        self.0.instance_name()
7079    }
7080}
7081
7082#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7083pub struct ServiceMarker;
7084
7085#[cfg(target_os = "fuchsia")]
7086impl fidl::endpoints::ServiceMarker for ServiceMarker {
7087    type Proxy = ServiceProxy;
7088    type Request = ServiceRequest;
7089    const SERVICE_NAME: &'static str = "fuchsia.hardware.google.nanohub.Service";
7090}
7091
7092/// A request for one of the member protocols of Service.
7093///
7094#[cfg(target_os = "fuchsia")]
7095pub enum ServiceRequest {
7096    Nanohub(DeviceRequestStream),
7097}
7098
7099#[cfg(target_os = "fuchsia")]
7100impl fidl::endpoints::ServiceRequest for ServiceRequest {
7101    type Service = ServiceMarker;
7102
7103    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
7104        match name {
7105            "nanohub" => Self::Nanohub(
7106                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
7107            ),
7108            _ => panic!("no such member protocol name for service Service"),
7109        }
7110    }
7111
7112    fn member_names() -> &'static [&'static str] {
7113        &["nanohub"]
7114    }
7115}
7116#[cfg(target_os = "fuchsia")]
7117pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
7118
7119#[cfg(target_os = "fuchsia")]
7120impl fidl::endpoints::ServiceProxy for ServiceProxy {
7121    type Service = ServiceMarker;
7122
7123    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
7124        Self(opener)
7125    }
7126}
7127
7128#[cfg(target_os = "fuchsia")]
7129impl ServiceProxy {
7130    pub fn connect_to_nanohub(&self) -> Result<DeviceProxy, fidl::Error> {
7131        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
7132        self.connect_channel_to_nanohub(server_end)?;
7133        Ok(proxy)
7134    }
7135
7136    /// Like `connect_to_nanohub`, but returns a sync proxy.
7137    /// See [`Self::connect_to_nanohub`] for more details.
7138    pub fn connect_to_nanohub_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
7139        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
7140        self.connect_channel_to_nanohub(server_end)?;
7141        Ok(proxy)
7142    }
7143
7144    /// Like `connect_to_nanohub`, but accepts a server end.
7145    /// See [`Self::connect_to_nanohub`] for more details.
7146    pub fn connect_channel_to_nanohub(
7147        &self,
7148        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
7149    ) -> Result<(), fidl::Error> {
7150        self.0.open_member("nanohub", server_end.into_channel())
7151    }
7152
7153    pub fn instance_name(&self) -> &str {
7154        self.0.instance_name()
7155    }
7156}
7157
7158#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7159pub struct StarnixDataChannelServiceMarker;
7160
7161#[cfg(target_os = "fuchsia")]
7162impl fidl::endpoints::ServiceMarker for StarnixDataChannelServiceMarker {
7163    type Proxy = StarnixDataChannelServiceProxy;
7164    type Request = StarnixDataChannelServiceRequest;
7165    const SERVICE_NAME: &'static str = "fuchsia.hardware.google.nanohub.StarnixDataChannelService";
7166}
7167
7168/// A request for one of the member protocols of StarnixDataChannelService.
7169///
7170/// Service for Non-driver clients
7171/// Separated from Driver Service to allow for selectively exposing endpoints
7172#[cfg(target_os = "fuchsia")]
7173pub enum StarnixDataChannelServiceRequest {
7174    Hanging(UnboundHangingDataChannelRequestStream),
7175    Waitable(UnboundWaitableDataChannelRequestStream),
7176    Lifecycle(LifecycleObserverRequestStream),
7177}
7178
7179#[cfg(target_os = "fuchsia")]
7180impl fidl::endpoints::ServiceRequest for StarnixDataChannelServiceRequest {
7181    type Service = StarnixDataChannelServiceMarker;
7182
7183    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
7184        match name {
7185            "hanging" => Self::Hanging(
7186                <UnboundHangingDataChannelRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
7187            ),
7188            "waitable" => Self::Waitable(
7189                <UnboundWaitableDataChannelRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
7190            ),
7191            "lifecycle" => Self::Lifecycle(
7192                <LifecycleObserverRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
7193            ),
7194            _ => panic!("no such member protocol name for service StarnixDataChannelService"),
7195        }
7196    }
7197
7198    fn member_names() -> &'static [&'static str] {
7199        &["hanging", "waitable", "lifecycle"]
7200    }
7201}
7202/// Service for Non-driver clients
7203/// Separated from Driver Service to allow for selectively exposing endpoints
7204#[cfg(target_os = "fuchsia")]
7205pub struct StarnixDataChannelServiceProxy(
7206    #[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>,
7207);
7208
7209#[cfg(target_os = "fuchsia")]
7210impl fidl::endpoints::ServiceProxy for StarnixDataChannelServiceProxy {
7211    type Service = StarnixDataChannelServiceMarker;
7212
7213    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
7214        Self(opener)
7215    }
7216}
7217
7218#[cfg(target_os = "fuchsia")]
7219impl StarnixDataChannelServiceProxy {
7220    pub fn connect_to_hanging(&self) -> Result<UnboundHangingDataChannelProxy, fidl::Error> {
7221        let (proxy, server_end) =
7222            fidl::endpoints::create_proxy::<UnboundHangingDataChannelMarker>();
7223        self.connect_channel_to_hanging(server_end)?;
7224        Ok(proxy)
7225    }
7226
7227    /// Like `connect_to_hanging`, but returns a sync proxy.
7228    /// See [`Self::connect_to_hanging`] for more details.
7229    pub fn connect_to_hanging_sync(
7230        &self,
7231    ) -> Result<UnboundHangingDataChannelSynchronousProxy, fidl::Error> {
7232        let (proxy, server_end) =
7233            fidl::endpoints::create_sync_proxy::<UnboundHangingDataChannelMarker>();
7234        self.connect_channel_to_hanging(server_end)?;
7235        Ok(proxy)
7236    }
7237
7238    /// Like `connect_to_hanging`, but accepts a server end.
7239    /// See [`Self::connect_to_hanging`] for more details.
7240    pub fn connect_channel_to_hanging(
7241        &self,
7242        server_end: fidl::endpoints::ServerEnd<UnboundHangingDataChannelMarker>,
7243    ) -> Result<(), fidl::Error> {
7244        self.0.open_member("hanging", server_end.into_channel())
7245    }
7246    pub fn connect_to_waitable(&self) -> Result<UnboundWaitableDataChannelProxy, fidl::Error> {
7247        let (proxy, server_end) =
7248            fidl::endpoints::create_proxy::<UnboundWaitableDataChannelMarker>();
7249        self.connect_channel_to_waitable(server_end)?;
7250        Ok(proxy)
7251    }
7252
7253    /// Like `connect_to_waitable`, but returns a sync proxy.
7254    /// See [`Self::connect_to_waitable`] for more details.
7255    pub fn connect_to_waitable_sync(
7256        &self,
7257    ) -> Result<UnboundWaitableDataChannelSynchronousProxy, fidl::Error> {
7258        let (proxy, server_end) =
7259            fidl::endpoints::create_sync_proxy::<UnboundWaitableDataChannelMarker>();
7260        self.connect_channel_to_waitable(server_end)?;
7261        Ok(proxy)
7262    }
7263
7264    /// Like `connect_to_waitable`, but accepts a server end.
7265    /// See [`Self::connect_to_waitable`] for more details.
7266    pub fn connect_channel_to_waitable(
7267        &self,
7268        server_end: fidl::endpoints::ServerEnd<UnboundWaitableDataChannelMarker>,
7269    ) -> Result<(), fidl::Error> {
7270        self.0.open_member("waitable", server_end.into_channel())
7271    }
7272    pub fn connect_to_lifecycle(&self) -> Result<LifecycleObserverProxy, fidl::Error> {
7273        let (proxy, server_end) = fidl::endpoints::create_proxy::<LifecycleObserverMarker>();
7274        self.connect_channel_to_lifecycle(server_end)?;
7275        Ok(proxy)
7276    }
7277
7278    /// Like `connect_to_lifecycle`, but returns a sync proxy.
7279    /// See [`Self::connect_to_lifecycle`] for more details.
7280    pub fn connect_to_lifecycle_sync(
7281        &self,
7282    ) -> Result<LifecycleObserverSynchronousProxy, fidl::Error> {
7283        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<LifecycleObserverMarker>();
7284        self.connect_channel_to_lifecycle(server_end)?;
7285        Ok(proxy)
7286    }
7287
7288    /// Like `connect_to_lifecycle`, but accepts a server end.
7289    /// See [`Self::connect_to_lifecycle`] for more details.
7290    pub fn connect_channel_to_lifecycle(
7291        &self,
7292        server_end: fidl::endpoints::ServerEnd<LifecycleObserverMarker>,
7293    ) -> Result<(), fidl::Error> {
7294        self.0.open_member("lifecycle", server_end.into_channel())
7295    }
7296
7297    pub fn instance_name(&self) -> &str {
7298        self.0.instance_name()
7299    }
7300}
7301
7302mod internal {
7303    use super::*;
7304
7305    impl fidl::encoding::ResourceTypeMarker for DataChannelRegisterRequest {
7306        type Borrowed<'a> = &'a mut Self;
7307        fn take_or_borrow<'a>(
7308            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7309        ) -> Self::Borrowed<'a> {
7310            value
7311        }
7312    }
7313
7314    unsafe impl fidl::encoding::TypeMarker for DataChannelRegisterRequest {
7315        type Owned = Self;
7316
7317        #[inline(always)]
7318        fn inline_align(_context: fidl::encoding::Context) -> usize {
7319            4
7320        }
7321
7322        #[inline(always)]
7323        fn inline_size(_context: fidl::encoding::Context) -> usize {
7324            4
7325        }
7326    }
7327
7328    unsafe impl
7329        fidl::encoding::Encode<
7330            DataChannelRegisterRequest,
7331            fidl::encoding::DefaultFuchsiaResourceDialect,
7332        > for &mut DataChannelRegisterRequest
7333    {
7334        #[inline]
7335        unsafe fn encode(
7336            self,
7337            encoder: &mut fidl::encoding::Encoder<
7338                '_,
7339                fidl::encoding::DefaultFuchsiaResourceDialect,
7340            >,
7341            offset: usize,
7342            _depth: fidl::encoding::Depth,
7343        ) -> fidl::Result<()> {
7344            encoder.debug_check_bounds::<DataChannelRegisterRequest>(offset);
7345            // Delegate to tuple encoding.
7346            fidl::encoding::Encode::<
7347                DataChannelRegisterRequest,
7348                fidl::encoding::DefaultFuchsiaResourceDialect,
7349            >::encode(
7350                (<fidl::encoding::HandleType<
7351                    fidl::Event,
7352                    { fidl::ObjectType::EVENT.into_raw() },
7353                    2147483648,
7354                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7355                    &mut self.event
7356                ),),
7357                encoder,
7358                offset,
7359                _depth,
7360            )
7361        }
7362    }
7363    unsafe impl<
7364        T0: fidl::encoding::Encode<
7365                fidl::encoding::HandleType<
7366                    fidl::Event,
7367                    { fidl::ObjectType::EVENT.into_raw() },
7368                    2147483648,
7369                >,
7370                fidl::encoding::DefaultFuchsiaResourceDialect,
7371            >,
7372    >
7373        fidl::encoding::Encode<
7374            DataChannelRegisterRequest,
7375            fidl::encoding::DefaultFuchsiaResourceDialect,
7376        > for (T0,)
7377    {
7378        #[inline]
7379        unsafe fn encode(
7380            self,
7381            encoder: &mut fidl::encoding::Encoder<
7382                '_,
7383                fidl::encoding::DefaultFuchsiaResourceDialect,
7384            >,
7385            offset: usize,
7386            depth: fidl::encoding::Depth,
7387        ) -> fidl::Result<()> {
7388            encoder.debug_check_bounds::<DataChannelRegisterRequest>(offset);
7389            // Zero out padding regions. There's no need to apply masks
7390            // because the unmasked parts will be overwritten by fields.
7391            // Write the fields.
7392            self.0.encode(encoder, offset + 0, depth)?;
7393            Ok(())
7394        }
7395    }
7396
7397    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7398        for DataChannelRegisterRequest
7399    {
7400        #[inline(always)]
7401        fn new_empty() -> Self {
7402            Self {
7403                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
7404            }
7405        }
7406
7407        #[inline]
7408        unsafe fn decode(
7409            &mut self,
7410            decoder: &mut fidl::encoding::Decoder<
7411                '_,
7412                fidl::encoding::DefaultFuchsiaResourceDialect,
7413            >,
7414            offset: usize,
7415            _depth: fidl::encoding::Depth,
7416        ) -> fidl::Result<()> {
7417            decoder.debug_check_bounds::<Self>(offset);
7418            // Verify that padding bytes are zero.
7419            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
7420            Ok(())
7421        }
7422    }
7423
7424    impl fidl::encoding::ResourceTypeMarker for DeviceDownloadFirmwareRequest {
7425        type Borrowed<'a> = &'a mut Self;
7426        fn take_or_borrow<'a>(
7427            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7428        ) -> Self::Borrowed<'a> {
7429            value
7430        }
7431    }
7432
7433    unsafe impl fidl::encoding::TypeMarker for DeviceDownloadFirmwareRequest {
7434        type Owned = Self;
7435
7436        #[inline(always)]
7437        fn inline_align(_context: fidl::encoding::Context) -> usize {
7438            8
7439        }
7440
7441        #[inline(always)]
7442        fn inline_size(_context: fidl::encoding::Context) -> usize {
7443            16
7444        }
7445    }
7446
7447    unsafe impl
7448        fidl::encoding::Encode<
7449            DeviceDownloadFirmwareRequest,
7450            fidl::encoding::DefaultFuchsiaResourceDialect,
7451        > for &mut DeviceDownloadFirmwareRequest
7452    {
7453        #[inline]
7454        unsafe fn encode(
7455            self,
7456            encoder: &mut fidl::encoding::Encoder<
7457                '_,
7458                fidl::encoding::DefaultFuchsiaResourceDialect,
7459            >,
7460            offset: usize,
7461            _depth: fidl::encoding::Depth,
7462        ) -> fidl::Result<()> {
7463            encoder.debug_check_bounds::<DeviceDownloadFirmwareRequest>(offset);
7464            // Delegate to tuple encoding.
7465            fidl::encoding::Encode::<
7466                DeviceDownloadFirmwareRequest,
7467                fidl::encoding::DefaultFuchsiaResourceDialect,
7468            >::encode(
7469                (
7470                    <fidl::encoding::HandleType<
7471                        fidl::Vmo,
7472                        { fidl::ObjectType::VMO.into_raw() },
7473                        49271,
7474                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7475                        &mut self.firmware
7476                    ),
7477                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.offset),
7478                ),
7479                encoder,
7480                offset,
7481                _depth,
7482            )
7483        }
7484    }
7485    unsafe impl<
7486        T0: fidl::encoding::Encode<
7487                fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49271>,
7488                fidl::encoding::DefaultFuchsiaResourceDialect,
7489            >,
7490        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
7491    >
7492        fidl::encoding::Encode<
7493            DeviceDownloadFirmwareRequest,
7494            fidl::encoding::DefaultFuchsiaResourceDialect,
7495        > for (T0, T1)
7496    {
7497        #[inline]
7498        unsafe fn encode(
7499            self,
7500            encoder: &mut fidl::encoding::Encoder<
7501                '_,
7502                fidl::encoding::DefaultFuchsiaResourceDialect,
7503            >,
7504            offset: usize,
7505            depth: fidl::encoding::Depth,
7506        ) -> fidl::Result<()> {
7507            encoder.debug_check_bounds::<DeviceDownloadFirmwareRequest>(offset);
7508            // Zero out padding regions. There's no need to apply masks
7509            // because the unmasked parts will be overwritten by fields.
7510            unsafe {
7511                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
7512                (ptr as *mut u64).write_unaligned(0);
7513            }
7514            // Write the fields.
7515            self.0.encode(encoder, offset + 0, depth)?;
7516            self.1.encode(encoder, offset + 8, depth)?;
7517            Ok(())
7518        }
7519    }
7520
7521    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7522        for DeviceDownloadFirmwareRequest
7523    {
7524        #[inline(always)]
7525        fn new_empty() -> Self {
7526            Self {
7527                firmware: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49271>, fidl::encoding::DefaultFuchsiaResourceDialect),
7528                offset: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
7529            }
7530        }
7531
7532        #[inline]
7533        unsafe fn decode(
7534            &mut self,
7535            decoder: &mut fidl::encoding::Decoder<
7536                '_,
7537                fidl::encoding::DefaultFuchsiaResourceDialect,
7538            >,
7539            offset: usize,
7540            _depth: fidl::encoding::Depth,
7541        ) -> fidl::Result<()> {
7542            decoder.debug_check_bounds::<Self>(offset);
7543            // Verify that padding bytes are zero.
7544            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
7545            let padval = unsafe { (ptr as *const u64).read_unaligned() };
7546            let mask = 0xffffffff00000000u64;
7547            let maskedval = padval & mask;
7548            if maskedval != 0 {
7549                return Err(fidl::Error::NonZeroPadding {
7550                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
7551                });
7552            }
7553            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49271>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.firmware, decoder, offset + 0, _depth)?;
7554            fidl::decode!(
7555                u64,
7556                fidl::encoding::DefaultFuchsiaResourceDialect,
7557                &mut self.offset,
7558                decoder,
7559                offset + 8,
7560                _depth
7561            )?;
7562            Ok(())
7563        }
7564    }
7565
7566    impl DataChannelReadResponse {
7567        #[inline(always)]
7568        fn max_ordinal_present(&self) -> u64 {
7569            if let Some(_) = self.wake_lease {
7570                return 2;
7571            }
7572            if let Some(_) = self.data {
7573                return 1;
7574            }
7575            0
7576        }
7577    }
7578
7579    impl fidl::encoding::ResourceTypeMarker for DataChannelReadResponse {
7580        type Borrowed<'a> = &'a mut Self;
7581        fn take_or_borrow<'a>(
7582            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7583        ) -> Self::Borrowed<'a> {
7584            value
7585        }
7586    }
7587
7588    unsafe impl fidl::encoding::TypeMarker for DataChannelReadResponse {
7589        type Owned = Self;
7590
7591        #[inline(always)]
7592        fn inline_align(_context: fidl::encoding::Context) -> usize {
7593            8
7594        }
7595
7596        #[inline(always)]
7597        fn inline_size(_context: fidl::encoding::Context) -> usize {
7598            16
7599        }
7600    }
7601
7602    unsafe impl
7603        fidl::encoding::Encode<
7604            DataChannelReadResponse,
7605            fidl::encoding::DefaultFuchsiaResourceDialect,
7606        > for &mut DataChannelReadResponse
7607    {
7608        unsafe fn encode(
7609            self,
7610            encoder: &mut fidl::encoding::Encoder<
7611                '_,
7612                fidl::encoding::DefaultFuchsiaResourceDialect,
7613            >,
7614            offset: usize,
7615            mut depth: fidl::encoding::Depth,
7616        ) -> fidl::Result<()> {
7617            encoder.debug_check_bounds::<DataChannelReadResponse>(offset);
7618            // Vector header
7619            let max_ordinal: u64 = self.max_ordinal_present();
7620            encoder.write_num(max_ordinal, offset);
7621            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7622            // Calling encoder.out_of_line_offset(0) is not allowed.
7623            if max_ordinal == 0 {
7624                return Ok(());
7625            }
7626            depth.increment()?;
7627            let envelope_size = 8;
7628            let bytes_len = max_ordinal as usize * envelope_size;
7629            #[allow(unused_variables)]
7630            let offset = encoder.out_of_line_offset(bytes_len);
7631            let mut _prev_end_offset: usize = 0;
7632            if 1 > max_ordinal {
7633                return Ok(());
7634            }
7635
7636            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7637            // are envelope_size bytes.
7638            let cur_offset: usize = (1 - 1) * envelope_size;
7639
7640            // Zero reserved fields.
7641            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7642
7643            // Safety:
7644            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7645            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7646            //   envelope_size bytes, there is always sufficient room.
7647            fidl::encoding::encode_in_envelope_optional::<
7648                fidl::encoding::Vector<u8, 255>,
7649                fidl::encoding::DefaultFuchsiaResourceDialect,
7650            >(
7651                self.data.as_ref().map(
7652                    <fidl::encoding::Vector<u8, 255> as fidl::encoding::ValueTypeMarker>::borrow,
7653                ),
7654                encoder,
7655                offset + cur_offset,
7656                depth,
7657            )?;
7658
7659            _prev_end_offset = cur_offset + envelope_size;
7660            if 2 > max_ordinal {
7661                return Ok(());
7662            }
7663
7664            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7665            // are envelope_size bytes.
7666            let cur_offset: usize = (2 - 1) * envelope_size;
7667
7668            // Zero reserved fields.
7669            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7670
7671            // Safety:
7672            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7673            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7674            //   envelope_size bytes, there is always sufficient room.
7675            fidl::encoding::encode_in_envelope_optional::<
7676                fidl::encoding::HandleType<
7677                    fidl::EventPair,
7678                    { fidl::ObjectType::EVENTPAIR.into_raw() },
7679                    2147483648,
7680                >,
7681                fidl::encoding::DefaultFuchsiaResourceDialect,
7682            >(
7683                self.wake_lease.as_mut().map(
7684                    <fidl::encoding::HandleType<
7685                        fidl::EventPair,
7686                        { fidl::ObjectType::EVENTPAIR.into_raw() },
7687                        2147483648,
7688                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7689                ),
7690                encoder,
7691                offset + cur_offset,
7692                depth,
7693            )?;
7694
7695            _prev_end_offset = cur_offset + envelope_size;
7696
7697            Ok(())
7698        }
7699    }
7700
7701    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7702        for DataChannelReadResponse
7703    {
7704        #[inline(always)]
7705        fn new_empty() -> Self {
7706            Self::default()
7707        }
7708
7709        unsafe fn decode(
7710            &mut self,
7711            decoder: &mut fidl::encoding::Decoder<
7712                '_,
7713                fidl::encoding::DefaultFuchsiaResourceDialect,
7714            >,
7715            offset: usize,
7716            mut depth: fidl::encoding::Depth,
7717        ) -> fidl::Result<()> {
7718            decoder.debug_check_bounds::<Self>(offset);
7719            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7720                None => return Err(fidl::Error::NotNullable),
7721                Some(len) => len,
7722            };
7723            // Calling decoder.out_of_line_offset(0) is not allowed.
7724            if len == 0 {
7725                return Ok(());
7726            };
7727            depth.increment()?;
7728            let envelope_size = 8;
7729            let bytes_len = len * envelope_size;
7730            let offset = decoder.out_of_line_offset(bytes_len)?;
7731            // Decode the envelope for each type.
7732            let mut _next_ordinal_to_read = 0;
7733            let mut next_offset = offset;
7734            let end_offset = offset + bytes_len;
7735            _next_ordinal_to_read += 1;
7736            if next_offset >= end_offset {
7737                return Ok(());
7738            }
7739
7740            // Decode unknown envelopes for gaps in ordinals.
7741            while _next_ordinal_to_read < 1 {
7742                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7743                _next_ordinal_to_read += 1;
7744                next_offset += envelope_size;
7745            }
7746
7747            let next_out_of_line = decoder.next_out_of_line();
7748            let handles_before = decoder.remaining_handles();
7749            if let Some((inlined, num_bytes, num_handles)) =
7750                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7751            {
7752                let member_inline_size =
7753                    <fidl::encoding::Vector<u8, 255> as fidl::encoding::TypeMarker>::inline_size(
7754                        decoder.context,
7755                    );
7756                if inlined != (member_inline_size <= 4) {
7757                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7758                }
7759                let inner_offset;
7760                let mut inner_depth = depth.clone();
7761                if inlined {
7762                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7763                    inner_offset = next_offset;
7764                } else {
7765                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7766                    inner_depth.increment()?;
7767                }
7768                let val_ref =
7769                self.data.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 255>, fidl::encoding::DefaultFuchsiaResourceDialect));
7770                fidl::decode!(fidl::encoding::Vector<u8, 255>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
7771                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7772                {
7773                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7774                }
7775                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7776                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7777                }
7778            }
7779
7780            next_offset += envelope_size;
7781            _next_ordinal_to_read += 1;
7782            if next_offset >= end_offset {
7783                return Ok(());
7784            }
7785
7786            // Decode unknown envelopes for gaps in ordinals.
7787            while _next_ordinal_to_read < 2 {
7788                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7789                _next_ordinal_to_read += 1;
7790                next_offset += envelope_size;
7791            }
7792
7793            let next_out_of_line = decoder.next_out_of_line();
7794            let handles_before = decoder.remaining_handles();
7795            if let Some((inlined, num_bytes, num_handles)) =
7796                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7797            {
7798                let member_inline_size = <fidl::encoding::HandleType<
7799                    fidl::EventPair,
7800                    { fidl::ObjectType::EVENTPAIR.into_raw() },
7801                    2147483648,
7802                > as fidl::encoding::TypeMarker>::inline_size(
7803                    decoder.context
7804                );
7805                if inlined != (member_inline_size <= 4) {
7806                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7807                }
7808                let inner_offset;
7809                let mut inner_depth = depth.clone();
7810                if inlined {
7811                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7812                    inner_offset = next_offset;
7813                } else {
7814                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7815                    inner_depth.increment()?;
7816                }
7817                let val_ref =
7818                self.wake_lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
7819                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
7820                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7821                {
7822                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7823                }
7824                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7825                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7826                }
7827            }
7828
7829            next_offset += envelope_size;
7830
7831            // Decode the remaining unknown envelopes.
7832            while next_offset < end_offset {
7833                _next_ordinal_to_read += 1;
7834                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7835                next_offset += envelope_size;
7836            }
7837
7838            Ok(())
7839        }
7840    }
7841
7842    impl HangingDataChannelReadResponse {
7843        #[inline(always)]
7844        fn max_ordinal_present(&self) -> u64 {
7845            if let Some(_) = self.wake_lease {
7846                return 2;
7847            }
7848            if let Some(_) = self.data {
7849                return 1;
7850            }
7851            0
7852        }
7853    }
7854
7855    impl fidl::encoding::ResourceTypeMarker for HangingDataChannelReadResponse {
7856        type Borrowed<'a> = &'a mut Self;
7857        fn take_or_borrow<'a>(
7858            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7859        ) -> Self::Borrowed<'a> {
7860            value
7861        }
7862    }
7863
7864    unsafe impl fidl::encoding::TypeMarker for HangingDataChannelReadResponse {
7865        type Owned = Self;
7866
7867        #[inline(always)]
7868        fn inline_align(_context: fidl::encoding::Context) -> usize {
7869            8
7870        }
7871
7872        #[inline(always)]
7873        fn inline_size(_context: fidl::encoding::Context) -> usize {
7874            16
7875        }
7876    }
7877
7878    unsafe impl
7879        fidl::encoding::Encode<
7880            HangingDataChannelReadResponse,
7881            fidl::encoding::DefaultFuchsiaResourceDialect,
7882        > for &mut HangingDataChannelReadResponse
7883    {
7884        unsafe fn encode(
7885            self,
7886            encoder: &mut fidl::encoding::Encoder<
7887                '_,
7888                fidl::encoding::DefaultFuchsiaResourceDialect,
7889            >,
7890            offset: usize,
7891            mut depth: fidl::encoding::Depth,
7892        ) -> fidl::Result<()> {
7893            encoder.debug_check_bounds::<HangingDataChannelReadResponse>(offset);
7894            // Vector header
7895            let max_ordinal: u64 = self.max_ordinal_present();
7896            encoder.write_num(max_ordinal, offset);
7897            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7898            // Calling encoder.out_of_line_offset(0) is not allowed.
7899            if max_ordinal == 0 {
7900                return Ok(());
7901            }
7902            depth.increment()?;
7903            let envelope_size = 8;
7904            let bytes_len = max_ordinal as usize * envelope_size;
7905            #[allow(unused_variables)]
7906            let offset = encoder.out_of_line_offset(bytes_len);
7907            let mut _prev_end_offset: usize = 0;
7908            if 1 > max_ordinal {
7909                return Ok(());
7910            }
7911
7912            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7913            // are envelope_size bytes.
7914            let cur_offset: usize = (1 - 1) * envelope_size;
7915
7916            // Zero reserved fields.
7917            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7918
7919            // Safety:
7920            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7921            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7922            //   envelope_size bytes, there is always sufficient room.
7923            fidl::encoding::encode_in_envelope_optional::<
7924                fidl::encoding::Vector<u8, 255>,
7925                fidl::encoding::DefaultFuchsiaResourceDialect,
7926            >(
7927                self.data.as_ref().map(
7928                    <fidl::encoding::Vector<u8, 255> as fidl::encoding::ValueTypeMarker>::borrow,
7929                ),
7930                encoder,
7931                offset + cur_offset,
7932                depth,
7933            )?;
7934
7935            _prev_end_offset = cur_offset + envelope_size;
7936            if 2 > max_ordinal {
7937                return Ok(());
7938            }
7939
7940            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7941            // are envelope_size bytes.
7942            let cur_offset: usize = (2 - 1) * envelope_size;
7943
7944            // Zero reserved fields.
7945            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7946
7947            // Safety:
7948            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7949            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7950            //   envelope_size bytes, there is always sufficient room.
7951            fidl::encoding::encode_in_envelope_optional::<
7952                fidl::encoding::HandleType<
7953                    fidl::EventPair,
7954                    { fidl::ObjectType::EVENTPAIR.into_raw() },
7955                    2147483648,
7956                >,
7957                fidl::encoding::DefaultFuchsiaResourceDialect,
7958            >(
7959                self.wake_lease.as_mut().map(
7960                    <fidl::encoding::HandleType<
7961                        fidl::EventPair,
7962                        { fidl::ObjectType::EVENTPAIR.into_raw() },
7963                        2147483648,
7964                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7965                ),
7966                encoder,
7967                offset + cur_offset,
7968                depth,
7969            )?;
7970
7971            _prev_end_offset = cur_offset + envelope_size;
7972
7973            Ok(())
7974        }
7975    }
7976
7977    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7978        for HangingDataChannelReadResponse
7979    {
7980        #[inline(always)]
7981        fn new_empty() -> Self {
7982            Self::default()
7983        }
7984
7985        unsafe fn decode(
7986            &mut self,
7987            decoder: &mut fidl::encoding::Decoder<
7988                '_,
7989                fidl::encoding::DefaultFuchsiaResourceDialect,
7990            >,
7991            offset: usize,
7992            mut depth: fidl::encoding::Depth,
7993        ) -> fidl::Result<()> {
7994            decoder.debug_check_bounds::<Self>(offset);
7995            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7996                None => return Err(fidl::Error::NotNullable),
7997                Some(len) => len,
7998            };
7999            // Calling decoder.out_of_line_offset(0) is not allowed.
8000            if len == 0 {
8001                return Ok(());
8002            };
8003            depth.increment()?;
8004            let envelope_size = 8;
8005            let bytes_len = len * envelope_size;
8006            let offset = decoder.out_of_line_offset(bytes_len)?;
8007            // Decode the envelope for each type.
8008            let mut _next_ordinal_to_read = 0;
8009            let mut next_offset = offset;
8010            let end_offset = offset + bytes_len;
8011            _next_ordinal_to_read += 1;
8012            if next_offset >= end_offset {
8013                return Ok(());
8014            }
8015
8016            // Decode unknown envelopes for gaps in ordinals.
8017            while _next_ordinal_to_read < 1 {
8018                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8019                _next_ordinal_to_read += 1;
8020                next_offset += envelope_size;
8021            }
8022
8023            let next_out_of_line = decoder.next_out_of_line();
8024            let handles_before = decoder.remaining_handles();
8025            if let Some((inlined, num_bytes, num_handles)) =
8026                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8027            {
8028                let member_inline_size =
8029                    <fidl::encoding::Vector<u8, 255> as fidl::encoding::TypeMarker>::inline_size(
8030                        decoder.context,
8031                    );
8032                if inlined != (member_inline_size <= 4) {
8033                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8034                }
8035                let inner_offset;
8036                let mut inner_depth = depth.clone();
8037                if inlined {
8038                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8039                    inner_offset = next_offset;
8040                } else {
8041                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8042                    inner_depth.increment()?;
8043                }
8044                let val_ref =
8045                self.data.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 255>, fidl::encoding::DefaultFuchsiaResourceDialect));
8046                fidl::decode!(fidl::encoding::Vector<u8, 255>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
8047                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8048                {
8049                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8050                }
8051                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8052                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8053                }
8054            }
8055
8056            next_offset += envelope_size;
8057            _next_ordinal_to_read += 1;
8058            if next_offset >= end_offset {
8059                return Ok(());
8060            }
8061
8062            // Decode unknown envelopes for gaps in ordinals.
8063            while _next_ordinal_to_read < 2 {
8064                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8065                _next_ordinal_to_read += 1;
8066                next_offset += envelope_size;
8067            }
8068
8069            let next_out_of_line = decoder.next_out_of_line();
8070            let handles_before = decoder.remaining_handles();
8071            if let Some((inlined, num_bytes, num_handles)) =
8072                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8073            {
8074                let member_inline_size = <fidl::encoding::HandleType<
8075                    fidl::EventPair,
8076                    { fidl::ObjectType::EVENTPAIR.into_raw() },
8077                    2147483648,
8078                > as fidl::encoding::TypeMarker>::inline_size(
8079                    decoder.context
8080                );
8081                if inlined != (member_inline_size <= 4) {
8082                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8083                }
8084                let inner_offset;
8085                let mut inner_depth = depth.clone();
8086                if inlined {
8087                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8088                    inner_offset = next_offset;
8089                } else {
8090                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8091                    inner_depth.increment()?;
8092                }
8093                let val_ref =
8094                self.wake_lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
8095                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
8096                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8097                {
8098                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8099                }
8100                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8101                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8102                }
8103            }
8104
8105            next_offset += envelope_size;
8106
8107            // Decode the remaining unknown envelopes.
8108            while next_offset < end_offset {
8109                _next_ordinal_to_read += 1;
8110                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8111                next_offset += envelope_size;
8112            }
8113
8114            Ok(())
8115        }
8116    }
8117
8118    impl UnboundHangingDataChannelBindRequest {
8119        #[inline(always)]
8120        fn max_ordinal_present(&self) -> u64 {
8121            if let Some(_) = self.server {
8122                return 1;
8123            }
8124            0
8125        }
8126    }
8127
8128    impl fidl::encoding::ResourceTypeMarker for UnboundHangingDataChannelBindRequest {
8129        type Borrowed<'a> = &'a mut Self;
8130        fn take_or_borrow<'a>(
8131            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8132        ) -> Self::Borrowed<'a> {
8133            value
8134        }
8135    }
8136
8137    unsafe impl fidl::encoding::TypeMarker for UnboundHangingDataChannelBindRequest {
8138        type Owned = Self;
8139
8140        #[inline(always)]
8141        fn inline_align(_context: fidl::encoding::Context) -> usize {
8142            8
8143        }
8144
8145        #[inline(always)]
8146        fn inline_size(_context: fidl::encoding::Context) -> usize {
8147            16
8148        }
8149    }
8150
8151    unsafe impl
8152        fidl::encoding::Encode<
8153            UnboundHangingDataChannelBindRequest,
8154            fidl::encoding::DefaultFuchsiaResourceDialect,
8155        > for &mut UnboundHangingDataChannelBindRequest
8156    {
8157        unsafe fn encode(
8158            self,
8159            encoder: &mut fidl::encoding::Encoder<
8160                '_,
8161                fidl::encoding::DefaultFuchsiaResourceDialect,
8162            >,
8163            offset: usize,
8164            mut depth: fidl::encoding::Depth,
8165        ) -> fidl::Result<()> {
8166            encoder.debug_check_bounds::<UnboundHangingDataChannelBindRequest>(offset);
8167            // Vector header
8168            let max_ordinal: u64 = self.max_ordinal_present();
8169            encoder.write_num(max_ordinal, offset);
8170            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8171            // Calling encoder.out_of_line_offset(0) is not allowed.
8172            if max_ordinal == 0 {
8173                return Ok(());
8174            }
8175            depth.increment()?;
8176            let envelope_size = 8;
8177            let bytes_len = max_ordinal as usize * envelope_size;
8178            #[allow(unused_variables)]
8179            let offset = encoder.out_of_line_offset(bytes_len);
8180            let mut _prev_end_offset: usize = 0;
8181            if 1 > max_ordinal {
8182                return Ok(());
8183            }
8184
8185            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8186            // are envelope_size bytes.
8187            let cur_offset: usize = (1 - 1) * envelope_size;
8188
8189            // Zero reserved fields.
8190            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8191
8192            // Safety:
8193            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8194            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8195            //   envelope_size bytes, there is always sufficient room.
8196            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HangingDataChannelMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
8197            self.server.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HangingDataChannelMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
8198            encoder, offset + cur_offset, depth
8199        )?;
8200
8201            _prev_end_offset = cur_offset + envelope_size;
8202
8203            Ok(())
8204        }
8205    }
8206
8207    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8208        for UnboundHangingDataChannelBindRequest
8209    {
8210        #[inline(always)]
8211        fn new_empty() -> Self {
8212            Self::default()
8213        }
8214
8215        unsafe fn decode(
8216            &mut self,
8217            decoder: &mut fidl::encoding::Decoder<
8218                '_,
8219                fidl::encoding::DefaultFuchsiaResourceDialect,
8220            >,
8221            offset: usize,
8222            mut depth: fidl::encoding::Depth,
8223        ) -> fidl::Result<()> {
8224            decoder.debug_check_bounds::<Self>(offset);
8225            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8226                None => return Err(fidl::Error::NotNullable),
8227                Some(len) => len,
8228            };
8229            // Calling decoder.out_of_line_offset(0) is not allowed.
8230            if len == 0 {
8231                return Ok(());
8232            };
8233            depth.increment()?;
8234            let envelope_size = 8;
8235            let bytes_len = len * envelope_size;
8236            let offset = decoder.out_of_line_offset(bytes_len)?;
8237            // Decode the envelope for each type.
8238            let mut _next_ordinal_to_read = 0;
8239            let mut next_offset = offset;
8240            let end_offset = offset + bytes_len;
8241            _next_ordinal_to_read += 1;
8242            if next_offset >= end_offset {
8243                return Ok(());
8244            }
8245
8246            // Decode unknown envelopes for gaps in ordinals.
8247            while _next_ordinal_to_read < 1 {
8248                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8249                _next_ordinal_to_read += 1;
8250                next_offset += envelope_size;
8251            }
8252
8253            let next_out_of_line = decoder.next_out_of_line();
8254            let handles_before = decoder.remaining_handles();
8255            if let Some((inlined, num_bytes, num_handles)) =
8256                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8257            {
8258                let member_inline_size = <fidl::encoding::Endpoint<
8259                    fidl::endpoints::ServerEnd<HangingDataChannelMarker>,
8260                > as fidl::encoding::TypeMarker>::inline_size(
8261                    decoder.context
8262                );
8263                if inlined != (member_inline_size <= 4) {
8264                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8265                }
8266                let inner_offset;
8267                let mut inner_depth = depth.clone();
8268                if inlined {
8269                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8270                    inner_offset = next_offset;
8271                } else {
8272                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8273                    inner_depth.increment()?;
8274                }
8275                let val_ref = self.server.get_or_insert_with(|| {
8276                    fidl::new_empty!(
8277                        fidl::encoding::Endpoint<
8278                            fidl::endpoints::ServerEnd<HangingDataChannelMarker>,
8279                        >,
8280                        fidl::encoding::DefaultFuchsiaResourceDialect
8281                    )
8282                });
8283                fidl::decode!(
8284                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<HangingDataChannelMarker>>,
8285                    fidl::encoding::DefaultFuchsiaResourceDialect,
8286                    val_ref,
8287                    decoder,
8288                    inner_offset,
8289                    inner_depth
8290                )?;
8291                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8292                {
8293                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8294                }
8295                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8296                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8297                }
8298            }
8299
8300            next_offset += envelope_size;
8301
8302            // Decode the remaining unknown envelopes.
8303            while next_offset < end_offset {
8304                _next_ordinal_to_read += 1;
8305                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8306                next_offset += envelope_size;
8307            }
8308
8309            Ok(())
8310        }
8311    }
8312
8313    impl UnboundWaitableDataChannelBindRequest {
8314        #[inline(always)]
8315        fn max_ordinal_present(&self) -> u64 {
8316            if let Some(_) = self.server {
8317                return 2;
8318            }
8319            if let Some(_) = self.event {
8320                return 1;
8321            }
8322            0
8323        }
8324    }
8325
8326    impl fidl::encoding::ResourceTypeMarker for UnboundWaitableDataChannelBindRequest {
8327        type Borrowed<'a> = &'a mut Self;
8328        fn take_or_borrow<'a>(
8329            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8330        ) -> Self::Borrowed<'a> {
8331            value
8332        }
8333    }
8334
8335    unsafe impl fidl::encoding::TypeMarker for UnboundWaitableDataChannelBindRequest {
8336        type Owned = Self;
8337
8338        #[inline(always)]
8339        fn inline_align(_context: fidl::encoding::Context) -> usize {
8340            8
8341        }
8342
8343        #[inline(always)]
8344        fn inline_size(_context: fidl::encoding::Context) -> usize {
8345            16
8346        }
8347    }
8348
8349    unsafe impl
8350        fidl::encoding::Encode<
8351            UnboundWaitableDataChannelBindRequest,
8352            fidl::encoding::DefaultFuchsiaResourceDialect,
8353        > for &mut UnboundWaitableDataChannelBindRequest
8354    {
8355        unsafe fn encode(
8356            self,
8357            encoder: &mut fidl::encoding::Encoder<
8358                '_,
8359                fidl::encoding::DefaultFuchsiaResourceDialect,
8360            >,
8361            offset: usize,
8362            mut depth: fidl::encoding::Depth,
8363        ) -> fidl::Result<()> {
8364            encoder.debug_check_bounds::<UnboundWaitableDataChannelBindRequest>(offset);
8365            // Vector header
8366            let max_ordinal: u64 = self.max_ordinal_present();
8367            encoder.write_num(max_ordinal, offset);
8368            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8369            // Calling encoder.out_of_line_offset(0) is not allowed.
8370            if max_ordinal == 0 {
8371                return Ok(());
8372            }
8373            depth.increment()?;
8374            let envelope_size = 8;
8375            let bytes_len = max_ordinal as usize * envelope_size;
8376            #[allow(unused_variables)]
8377            let offset = encoder.out_of_line_offset(bytes_len);
8378            let mut _prev_end_offset: usize = 0;
8379            if 1 > max_ordinal {
8380                return Ok(());
8381            }
8382
8383            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8384            // are envelope_size bytes.
8385            let cur_offset: usize = (1 - 1) * envelope_size;
8386
8387            // Zero reserved fields.
8388            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8389
8390            // Safety:
8391            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8392            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8393            //   envelope_size bytes, there is always sufficient room.
8394            fidl::encoding::encode_in_envelope_optional::<
8395                fidl::encoding::HandleType<
8396                    fidl::Event,
8397                    { fidl::ObjectType::EVENT.into_raw() },
8398                    2147483648,
8399                >,
8400                fidl::encoding::DefaultFuchsiaResourceDialect,
8401            >(
8402                self.event.as_mut().map(
8403                    <fidl::encoding::HandleType<
8404                        fidl::Event,
8405                        { fidl::ObjectType::EVENT.into_raw() },
8406                        2147483648,
8407                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
8408                ),
8409                encoder,
8410                offset + cur_offset,
8411                depth,
8412            )?;
8413
8414            _prev_end_offset = cur_offset + envelope_size;
8415            if 2 > max_ordinal {
8416                return Ok(());
8417            }
8418
8419            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8420            // are envelope_size bytes.
8421            let cur_offset: usize = (2 - 1) * envelope_size;
8422
8423            // Zero reserved fields.
8424            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8425
8426            // Safety:
8427            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8428            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8429            //   envelope_size bytes, there is always sufficient room.
8430            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WaitableDataChannelMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
8431            self.server.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WaitableDataChannelMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
8432            encoder, offset + cur_offset, depth
8433        )?;
8434
8435            _prev_end_offset = cur_offset + envelope_size;
8436
8437            Ok(())
8438        }
8439    }
8440
8441    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8442        for UnboundWaitableDataChannelBindRequest
8443    {
8444        #[inline(always)]
8445        fn new_empty() -> Self {
8446            Self::default()
8447        }
8448
8449        unsafe fn decode(
8450            &mut self,
8451            decoder: &mut fidl::encoding::Decoder<
8452                '_,
8453                fidl::encoding::DefaultFuchsiaResourceDialect,
8454            >,
8455            offset: usize,
8456            mut depth: fidl::encoding::Depth,
8457        ) -> fidl::Result<()> {
8458            decoder.debug_check_bounds::<Self>(offset);
8459            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8460                None => return Err(fidl::Error::NotNullable),
8461                Some(len) => len,
8462            };
8463            // Calling decoder.out_of_line_offset(0) is not allowed.
8464            if len == 0 {
8465                return Ok(());
8466            };
8467            depth.increment()?;
8468            let envelope_size = 8;
8469            let bytes_len = len * envelope_size;
8470            let offset = decoder.out_of_line_offset(bytes_len)?;
8471            // Decode the envelope for each type.
8472            let mut _next_ordinal_to_read = 0;
8473            let mut next_offset = offset;
8474            let end_offset = offset + bytes_len;
8475            _next_ordinal_to_read += 1;
8476            if next_offset >= end_offset {
8477                return Ok(());
8478            }
8479
8480            // Decode unknown envelopes for gaps in ordinals.
8481            while _next_ordinal_to_read < 1 {
8482                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8483                _next_ordinal_to_read += 1;
8484                next_offset += envelope_size;
8485            }
8486
8487            let next_out_of_line = decoder.next_out_of_line();
8488            let handles_before = decoder.remaining_handles();
8489            if let Some((inlined, num_bytes, num_handles)) =
8490                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8491            {
8492                let member_inline_size = <fidl::encoding::HandleType<
8493                    fidl::Event,
8494                    { fidl::ObjectType::EVENT.into_raw() },
8495                    2147483648,
8496                > as fidl::encoding::TypeMarker>::inline_size(
8497                    decoder.context
8498                );
8499                if inlined != (member_inline_size <= 4) {
8500                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8501                }
8502                let inner_offset;
8503                let mut inner_depth = depth.clone();
8504                if inlined {
8505                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8506                    inner_offset = next_offset;
8507                } else {
8508                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8509                    inner_depth.increment()?;
8510                }
8511                let val_ref =
8512                self.event.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
8513                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
8514                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8515                {
8516                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8517                }
8518                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8519                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8520                }
8521            }
8522
8523            next_offset += envelope_size;
8524            _next_ordinal_to_read += 1;
8525            if next_offset >= end_offset {
8526                return Ok(());
8527            }
8528
8529            // Decode unknown envelopes for gaps in ordinals.
8530            while _next_ordinal_to_read < 2 {
8531                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8532                _next_ordinal_to_read += 1;
8533                next_offset += envelope_size;
8534            }
8535
8536            let next_out_of_line = decoder.next_out_of_line();
8537            let handles_before = decoder.remaining_handles();
8538            if let Some((inlined, num_bytes, num_handles)) =
8539                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8540            {
8541                let member_inline_size = <fidl::encoding::Endpoint<
8542                    fidl::endpoints::ServerEnd<WaitableDataChannelMarker>,
8543                > as fidl::encoding::TypeMarker>::inline_size(
8544                    decoder.context
8545                );
8546                if inlined != (member_inline_size <= 4) {
8547                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8548                }
8549                let inner_offset;
8550                let mut inner_depth = depth.clone();
8551                if inlined {
8552                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8553                    inner_offset = next_offset;
8554                } else {
8555                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8556                    inner_depth.increment()?;
8557                }
8558                let val_ref = self.server.get_or_insert_with(|| {
8559                    fidl::new_empty!(
8560                        fidl::encoding::Endpoint<
8561                            fidl::endpoints::ServerEnd<WaitableDataChannelMarker>,
8562                        >,
8563                        fidl::encoding::DefaultFuchsiaResourceDialect
8564                    )
8565                });
8566                fidl::decode!(
8567                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WaitableDataChannelMarker>>,
8568                    fidl::encoding::DefaultFuchsiaResourceDialect,
8569                    val_ref,
8570                    decoder,
8571                    inner_offset,
8572                    inner_depth
8573                )?;
8574                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8575                {
8576                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8577                }
8578                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8579                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8580                }
8581            }
8582
8583            next_offset += envelope_size;
8584
8585            // Decode the remaining unknown envelopes.
8586            while next_offset < end_offset {
8587                _next_ordinal_to_read += 1;
8588                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8589                next_offset += envelope_size;
8590            }
8591
8592            Ok(())
8593        }
8594    }
8595
8596    impl WaitableDataChannelReadResponse {
8597        #[inline(always)]
8598        fn max_ordinal_present(&self) -> u64 {
8599            if let Some(_) = self.data {
8600                return 1;
8601            }
8602            0
8603        }
8604    }
8605
8606    impl fidl::encoding::ResourceTypeMarker for WaitableDataChannelReadResponse {
8607        type Borrowed<'a> = &'a mut Self;
8608        fn take_or_borrow<'a>(
8609            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8610        ) -> Self::Borrowed<'a> {
8611            value
8612        }
8613    }
8614
8615    unsafe impl fidl::encoding::TypeMarker for WaitableDataChannelReadResponse {
8616        type Owned = Self;
8617
8618        #[inline(always)]
8619        fn inline_align(_context: fidl::encoding::Context) -> usize {
8620            8
8621        }
8622
8623        #[inline(always)]
8624        fn inline_size(_context: fidl::encoding::Context) -> usize {
8625            16
8626        }
8627    }
8628
8629    unsafe impl
8630        fidl::encoding::Encode<
8631            WaitableDataChannelReadResponse,
8632            fidl::encoding::DefaultFuchsiaResourceDialect,
8633        > for &mut WaitableDataChannelReadResponse
8634    {
8635        unsafe fn encode(
8636            self,
8637            encoder: &mut fidl::encoding::Encoder<
8638                '_,
8639                fidl::encoding::DefaultFuchsiaResourceDialect,
8640            >,
8641            offset: usize,
8642            mut depth: fidl::encoding::Depth,
8643        ) -> fidl::Result<()> {
8644            encoder.debug_check_bounds::<WaitableDataChannelReadResponse>(offset);
8645            // Vector header
8646            let max_ordinal: u64 = self.max_ordinal_present();
8647            encoder.write_num(max_ordinal, offset);
8648            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8649            // Calling encoder.out_of_line_offset(0) is not allowed.
8650            if max_ordinal == 0 {
8651                return Ok(());
8652            }
8653            depth.increment()?;
8654            let envelope_size = 8;
8655            let bytes_len = max_ordinal as usize * envelope_size;
8656            #[allow(unused_variables)]
8657            let offset = encoder.out_of_line_offset(bytes_len);
8658            let mut _prev_end_offset: usize = 0;
8659            if 1 > max_ordinal {
8660                return Ok(());
8661            }
8662
8663            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8664            // are envelope_size bytes.
8665            let cur_offset: usize = (1 - 1) * envelope_size;
8666
8667            // Zero reserved fields.
8668            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8669
8670            // Safety:
8671            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8672            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8673            //   envelope_size bytes, there is always sufficient room.
8674            fidl::encoding::encode_in_envelope_optional::<
8675                fidl::encoding::Vector<u8, 255>,
8676                fidl::encoding::DefaultFuchsiaResourceDialect,
8677            >(
8678                self.data.as_ref().map(
8679                    <fidl::encoding::Vector<u8, 255> as fidl::encoding::ValueTypeMarker>::borrow,
8680                ),
8681                encoder,
8682                offset + cur_offset,
8683                depth,
8684            )?;
8685
8686            _prev_end_offset = cur_offset + envelope_size;
8687
8688            Ok(())
8689        }
8690    }
8691
8692    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8693        for WaitableDataChannelReadResponse
8694    {
8695        #[inline(always)]
8696        fn new_empty() -> Self {
8697            Self::default()
8698        }
8699
8700        unsafe fn decode(
8701            &mut self,
8702            decoder: &mut fidl::encoding::Decoder<
8703                '_,
8704                fidl::encoding::DefaultFuchsiaResourceDialect,
8705            >,
8706            offset: usize,
8707            mut depth: fidl::encoding::Depth,
8708        ) -> fidl::Result<()> {
8709            decoder.debug_check_bounds::<Self>(offset);
8710            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8711                None => return Err(fidl::Error::NotNullable),
8712                Some(len) => len,
8713            };
8714            // Calling decoder.out_of_line_offset(0) is not allowed.
8715            if len == 0 {
8716                return Ok(());
8717            };
8718            depth.increment()?;
8719            let envelope_size = 8;
8720            let bytes_len = len * envelope_size;
8721            let offset = decoder.out_of_line_offset(bytes_len)?;
8722            // Decode the envelope for each type.
8723            let mut _next_ordinal_to_read = 0;
8724            let mut next_offset = offset;
8725            let end_offset = offset + bytes_len;
8726            _next_ordinal_to_read += 1;
8727            if next_offset >= end_offset {
8728                return Ok(());
8729            }
8730
8731            // Decode unknown envelopes for gaps in ordinals.
8732            while _next_ordinal_to_read < 1 {
8733                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8734                _next_ordinal_to_read += 1;
8735                next_offset += envelope_size;
8736            }
8737
8738            let next_out_of_line = decoder.next_out_of_line();
8739            let handles_before = decoder.remaining_handles();
8740            if let Some((inlined, num_bytes, num_handles)) =
8741                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8742            {
8743                let member_inline_size =
8744                    <fidl::encoding::Vector<u8, 255> as fidl::encoding::TypeMarker>::inline_size(
8745                        decoder.context,
8746                    );
8747                if inlined != (member_inline_size <= 4) {
8748                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8749                }
8750                let inner_offset;
8751                let mut inner_depth = depth.clone();
8752                if inlined {
8753                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8754                    inner_offset = next_offset;
8755                } else {
8756                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8757                    inner_depth.increment()?;
8758                }
8759                let val_ref =
8760                self.data.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 255>, fidl::encoding::DefaultFuchsiaResourceDialect));
8761                fidl::decode!(fidl::encoding::Vector<u8, 255>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
8762                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8763                {
8764                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8765                }
8766                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8767                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8768                }
8769            }
8770
8771            next_offset += envelope_size;
8772
8773            // Decode the remaining unknown envelopes.
8774            while next_offset < end_offset {
8775                _next_ordinal_to_read += 1;
8776                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8777                next_offset += envelope_size;
8778            }
8779
8780            Ok(())
8781        }
8782    }
8783}