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