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