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, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
46pub struct DataChannelMarker;
47
48impl fidl::endpoints::ProtocolMarker for DataChannelMarker {
49    type Proxy = DataChannelProxy;
50    type RequestStream = DataChannelRequestStream;
51    #[cfg(target_os = "fuchsia")]
52    type SynchronousProxy = DataChannelSynchronousProxy;
53
54    const DEBUG_NAME: &'static str = "(anonymous) DataChannel";
55}
56pub type DataChannelRegisterResult = Result<(), i32>;
57pub type DataChannelReadResult = Result<DataChannelReadResponse, i32>;
58pub type DataChannelWriteResult = Result<(), i32>;
59
60pub trait DataChannelProxyInterface: Send + Sync {
61    type RegisterResponseFut: std::future::Future<Output = Result<DataChannelRegisterResult, fidl::Error>>
62        + Send;
63    fn r#register(&self, event: fidl::Event) -> Self::RegisterResponseFut;
64    type GetIdentifierResponseFut: std::future::Future<Output = Result<DataChannelGetIdentifierResponse, fidl::Error>>
65        + Send;
66    fn r#get_identifier(&self) -> Self::GetIdentifierResponseFut;
67    type ReadResponseFut: std::future::Future<Output = Result<DataChannelReadResult, fidl::Error>>
68        + Send;
69    fn r#read(&self, payload: &DataChannelReadRequest) -> Self::ReadResponseFut;
70    type WriteResponseFut: std::future::Future<Output = Result<DataChannelWriteResult, fidl::Error>>
71        + Send;
72    fn r#write(&self, payload: &DataChannelWriteRequest) -> Self::WriteResponseFut;
73}
74#[derive(Debug)]
75#[cfg(target_os = "fuchsia")]
76pub struct DataChannelSynchronousProxy {
77    client: fidl::client::sync::Client,
78}
79
80#[cfg(target_os = "fuchsia")]
81impl fidl::endpoints::SynchronousProxy for DataChannelSynchronousProxy {
82    type Proxy = DataChannelProxy;
83    type Protocol = DataChannelMarker;
84
85    fn from_channel(inner: fidl::Channel) -> Self {
86        Self::new(inner)
87    }
88
89    fn into_channel(self) -> fidl::Channel {
90        self.client.into_channel()
91    }
92
93    fn as_channel(&self) -> &fidl::Channel {
94        self.client.as_channel()
95    }
96}
97
98#[cfg(target_os = "fuchsia")]
99impl DataChannelSynchronousProxy {
100    pub fn new(channel: fidl::Channel) -> Self {
101        let protocol_name = <DataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
102        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
103    }
104
105    pub fn into_channel(self) -> fidl::Channel {
106        self.client.into_channel()
107    }
108
109    /// Waits until an event arrives and returns it. It is safe for other
110    /// threads to make concurrent requests while waiting for an event.
111    pub fn wait_for_event(
112        &self,
113        deadline: zx::MonotonicInstant,
114    ) -> Result<DataChannelEvent, fidl::Error> {
115        DataChannelEvent::decode(self.client.wait_for_event(deadline)?)
116    }
117
118    /// Set event used to signal device state. Discards existing event
119    /// after having transferred device state to the new event.
120    /// This must be called before invoking Read or Write, and can fail with
121    /// ZX_ERR_NO_RESOURCES if the underlying channel is busy.
122    pub fn r#register(
123        &self,
124        mut event: fidl::Event,
125        ___deadline: zx::MonotonicInstant,
126    ) -> Result<DataChannelRegisterResult, fidl::Error> {
127        let _response = self.client.send_query::<
128            DataChannelRegisterRequest,
129            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
130        >(
131            (event,),
132            0x1778251ad75157b6,
133            fidl::encoding::DynamicFlags::FLEXIBLE,
134            ___deadline,
135        )?
136        .into_result::<DataChannelMarker>("register")?;
137        Ok(_response.map(|x| x))
138    }
139
140    /// Returns the identifier associated with this connection.
141    pub fn r#get_identifier(
142        &self,
143        ___deadline: zx::MonotonicInstant,
144    ) -> Result<DataChannelGetIdentifierResponse, fidl::Error> {
145        let _response = self.client.send_query::<
146            fidl::encoding::EmptyPayload,
147            fidl::encoding::FlexibleType<DataChannelGetIdentifierResponse>,
148        >(
149            (),
150            0x4bf148d0ddbd4f69,
151            fidl::encoding::DynamicFlags::FLEXIBLE,
152            ___deadline,
153        )?
154        .into_result::<DataChannelMarker>("get_identifier")?;
155        Ok(_response)
156    }
157
158    /// The call will return the next datagram to be read from the channel.
159    /// If there is more data to be read, SIGNAL_READABLE will remain asserted
160    /// after this call returns.
161    pub fn r#read(
162        &self,
163        mut payload: &DataChannelReadRequest,
164        ___deadline: zx::MonotonicInstant,
165    ) -> Result<DataChannelReadResult, fidl::Error> {
166        let _response = self.client.send_query::<
167            DataChannelReadRequest,
168            fidl::encoding::FlexibleResultType<DataChannelReadResponse, i32>,
169        >(
170            payload,
171            0x12ab08cf21533d26,
172            fidl::encoding::DynamicFlags::FLEXIBLE,
173            ___deadline,
174        )?
175        .into_result::<DataChannelMarker>("read")?;
176        Ok(_response.map(|x| x))
177    }
178
179    /// The call will return once the data is fully committed.
180    ///
181    /// If the driver is not ready for a write, it will return
182    /// ZX_ERR_NO_RESOURCES and the caller should await SIGNAL_WRITABLE to be
183    /// asserted.
184    pub fn r#write(
185        &self,
186        mut payload: &DataChannelWriteRequest,
187        ___deadline: zx::MonotonicInstant,
188    ) -> Result<DataChannelWriteResult, fidl::Error> {
189        let _response = self.client.send_query::<
190            DataChannelWriteRequest,
191            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
192        >(
193            payload,
194            0xf2e12121698789b,
195            fidl::encoding::DynamicFlags::FLEXIBLE,
196            ___deadline,
197        )?
198        .into_result::<DataChannelMarker>("write")?;
199        Ok(_response.map(|x| x))
200    }
201}
202
203#[cfg(target_os = "fuchsia")]
204impl From<DataChannelSynchronousProxy> for zx::Handle {
205    fn from(value: DataChannelSynchronousProxy) -> Self {
206        value.into_channel().into()
207    }
208}
209
210#[cfg(target_os = "fuchsia")]
211impl From<fidl::Channel> for DataChannelSynchronousProxy {
212    fn from(value: fidl::Channel) -> Self {
213        Self::new(value)
214    }
215}
216
217#[cfg(target_os = "fuchsia")]
218impl fidl::endpoints::FromClient for DataChannelSynchronousProxy {
219    type Protocol = DataChannelMarker;
220
221    fn from_client(value: fidl::endpoints::ClientEnd<DataChannelMarker>) -> Self {
222        Self::new(value.into_channel())
223    }
224}
225
226#[derive(Debug, Clone)]
227pub struct DataChannelProxy {
228    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
229}
230
231impl fidl::endpoints::Proxy for DataChannelProxy {
232    type Protocol = DataChannelMarker;
233
234    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
235        Self::new(inner)
236    }
237
238    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
239        self.client.into_channel().map_err(|client| Self { client })
240    }
241
242    fn as_channel(&self) -> &::fidl::AsyncChannel {
243        self.client.as_channel()
244    }
245}
246
247impl DataChannelProxy {
248    /// Create a new Proxy for fuchsia.hardware.google.nanohub/DataChannel.
249    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
250        let protocol_name = <DataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
251        Self { client: fidl::client::Client::new(channel, protocol_name) }
252    }
253
254    /// Get a Stream of events from the remote end of the protocol.
255    ///
256    /// # Panics
257    ///
258    /// Panics if the event stream was already taken.
259    pub fn take_event_stream(&self) -> DataChannelEventStream {
260        DataChannelEventStream { event_receiver: self.client.take_event_receiver() }
261    }
262
263    /// Set event used to signal device state. Discards existing event
264    /// after having transferred device state to the new event.
265    /// This must be called before invoking Read or Write, and can fail with
266    /// ZX_ERR_NO_RESOURCES if the underlying channel is busy.
267    pub fn r#register(
268        &self,
269        mut event: fidl::Event,
270    ) -> fidl::client::QueryResponseFut<
271        DataChannelRegisterResult,
272        fidl::encoding::DefaultFuchsiaResourceDialect,
273    > {
274        DataChannelProxyInterface::r#register(self, event)
275    }
276
277    /// Returns the identifier associated with this connection.
278    pub fn r#get_identifier(
279        &self,
280    ) -> fidl::client::QueryResponseFut<
281        DataChannelGetIdentifierResponse,
282        fidl::encoding::DefaultFuchsiaResourceDialect,
283    > {
284        DataChannelProxyInterface::r#get_identifier(self)
285    }
286
287    /// The call will return the next datagram to be read from the channel.
288    /// If there is more data to be read, SIGNAL_READABLE will remain asserted
289    /// after this call returns.
290    pub fn r#read(
291        &self,
292        mut payload: &DataChannelReadRequest,
293    ) -> fidl::client::QueryResponseFut<
294        DataChannelReadResult,
295        fidl::encoding::DefaultFuchsiaResourceDialect,
296    > {
297        DataChannelProxyInterface::r#read(self, payload)
298    }
299
300    /// The call will return once the data is fully committed.
301    ///
302    /// If the driver is not ready for a write, it will return
303    /// ZX_ERR_NO_RESOURCES and the caller should await SIGNAL_WRITABLE to be
304    /// asserted.
305    pub fn r#write(
306        &self,
307        mut payload: &DataChannelWriteRequest,
308    ) -> fidl::client::QueryResponseFut<
309        DataChannelWriteResult,
310        fidl::encoding::DefaultFuchsiaResourceDialect,
311    > {
312        DataChannelProxyInterface::r#write(self, payload)
313    }
314}
315
316impl DataChannelProxyInterface for DataChannelProxy {
317    type RegisterResponseFut = fidl::client::QueryResponseFut<
318        DataChannelRegisterResult,
319        fidl::encoding::DefaultFuchsiaResourceDialect,
320    >;
321    fn r#register(&self, mut event: fidl::Event) -> Self::RegisterResponseFut {
322        fn _decode(
323            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
324        ) -> Result<DataChannelRegisterResult, fidl::Error> {
325            let _response = fidl::client::decode_transaction_body::<
326                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
327                fidl::encoding::DefaultFuchsiaResourceDialect,
328                0x1778251ad75157b6,
329            >(_buf?)?
330            .into_result::<DataChannelMarker>("register")?;
331            Ok(_response.map(|x| x))
332        }
333        self.client.send_query_and_decode::<DataChannelRegisterRequest, DataChannelRegisterResult>(
334            (event,),
335            0x1778251ad75157b6,
336            fidl::encoding::DynamicFlags::FLEXIBLE,
337            _decode,
338        )
339    }
340
341    type GetIdentifierResponseFut = fidl::client::QueryResponseFut<
342        DataChannelGetIdentifierResponse,
343        fidl::encoding::DefaultFuchsiaResourceDialect,
344    >;
345    fn r#get_identifier(&self) -> Self::GetIdentifierResponseFut {
346        fn _decode(
347            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
348        ) -> Result<DataChannelGetIdentifierResponse, fidl::Error> {
349            let _response = fidl::client::decode_transaction_body::<
350                fidl::encoding::FlexibleType<DataChannelGetIdentifierResponse>,
351                fidl::encoding::DefaultFuchsiaResourceDialect,
352                0x4bf148d0ddbd4f69,
353            >(_buf?)?
354            .into_result::<DataChannelMarker>("get_identifier")?;
355            Ok(_response)
356        }
357        self.client.send_query_and_decode::<
358            fidl::encoding::EmptyPayload,
359            DataChannelGetIdentifierResponse,
360        >(
361            (),
362            0x4bf148d0ddbd4f69,
363            fidl::encoding::DynamicFlags::FLEXIBLE,
364            _decode,
365        )
366    }
367
368    type ReadResponseFut = fidl::client::QueryResponseFut<
369        DataChannelReadResult,
370        fidl::encoding::DefaultFuchsiaResourceDialect,
371    >;
372    fn r#read(&self, mut payload: &DataChannelReadRequest) -> Self::ReadResponseFut {
373        fn _decode(
374            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
375        ) -> Result<DataChannelReadResult, fidl::Error> {
376            let _response = fidl::client::decode_transaction_body::<
377                fidl::encoding::FlexibleResultType<DataChannelReadResponse, i32>,
378                fidl::encoding::DefaultFuchsiaResourceDialect,
379                0x12ab08cf21533d26,
380            >(_buf?)?
381            .into_result::<DataChannelMarker>("read")?;
382            Ok(_response.map(|x| x))
383        }
384        self.client.send_query_and_decode::<DataChannelReadRequest, DataChannelReadResult>(
385            payload,
386            0x12ab08cf21533d26,
387            fidl::encoding::DynamicFlags::FLEXIBLE,
388            _decode,
389        )
390    }
391
392    type WriteResponseFut = fidl::client::QueryResponseFut<
393        DataChannelWriteResult,
394        fidl::encoding::DefaultFuchsiaResourceDialect,
395    >;
396    fn r#write(&self, mut payload: &DataChannelWriteRequest) -> Self::WriteResponseFut {
397        fn _decode(
398            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
399        ) -> Result<DataChannelWriteResult, fidl::Error> {
400            let _response = fidl::client::decode_transaction_body::<
401                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
402                fidl::encoding::DefaultFuchsiaResourceDialect,
403                0xf2e12121698789b,
404            >(_buf?)?
405            .into_result::<DataChannelMarker>("write")?;
406            Ok(_response.map(|x| x))
407        }
408        self.client.send_query_and_decode::<DataChannelWriteRequest, DataChannelWriteResult>(
409            payload,
410            0xf2e12121698789b,
411            fidl::encoding::DynamicFlags::FLEXIBLE,
412            _decode,
413        )
414    }
415}
416
417pub struct DataChannelEventStream {
418    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
419}
420
421impl std::marker::Unpin for DataChannelEventStream {}
422
423impl futures::stream::FusedStream for DataChannelEventStream {
424    fn is_terminated(&self) -> bool {
425        self.event_receiver.is_terminated()
426    }
427}
428
429impl futures::Stream for DataChannelEventStream {
430    type Item = Result<DataChannelEvent, fidl::Error>;
431
432    fn poll_next(
433        mut self: std::pin::Pin<&mut Self>,
434        cx: &mut std::task::Context<'_>,
435    ) -> std::task::Poll<Option<Self::Item>> {
436        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
437            &mut self.event_receiver,
438            cx
439        )?) {
440            Some(buf) => std::task::Poll::Ready(Some(DataChannelEvent::decode(buf))),
441            None => std::task::Poll::Ready(None),
442        }
443    }
444}
445
446#[derive(Debug)]
447pub enum DataChannelEvent {
448    #[non_exhaustive]
449    _UnknownEvent {
450        /// Ordinal of the event that was sent.
451        ordinal: u64,
452    },
453}
454
455impl DataChannelEvent {
456    /// Decodes a message buffer as a [`DataChannelEvent`].
457    fn decode(
458        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
459    ) -> Result<DataChannelEvent, fidl::Error> {
460        let (bytes, _handles) = buf.split_mut();
461        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
462        debug_assert_eq!(tx_header.tx_id, 0);
463        match tx_header.ordinal {
464            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
465                Ok(DataChannelEvent::_UnknownEvent { ordinal: tx_header.ordinal })
466            }
467            _ => Err(fidl::Error::UnknownOrdinal {
468                ordinal: tx_header.ordinal,
469                protocol_name: <DataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
470            }),
471        }
472    }
473}
474
475/// A Stream of incoming requests for fuchsia.hardware.google.nanohub/DataChannel.
476pub struct DataChannelRequestStream {
477    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
478    is_terminated: bool,
479}
480
481impl std::marker::Unpin for DataChannelRequestStream {}
482
483impl futures::stream::FusedStream for DataChannelRequestStream {
484    fn is_terminated(&self) -> bool {
485        self.is_terminated
486    }
487}
488
489impl fidl::endpoints::RequestStream for DataChannelRequestStream {
490    type Protocol = DataChannelMarker;
491    type ControlHandle = DataChannelControlHandle;
492
493    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
494        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
495    }
496
497    fn control_handle(&self) -> Self::ControlHandle {
498        DataChannelControlHandle { inner: self.inner.clone() }
499    }
500
501    fn into_inner(
502        self,
503    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
504    {
505        (self.inner, self.is_terminated)
506    }
507
508    fn from_inner(
509        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
510        is_terminated: bool,
511    ) -> Self {
512        Self { inner, is_terminated }
513    }
514}
515
516impl futures::Stream for DataChannelRequestStream {
517    type Item = Result<DataChannelRequest, fidl::Error>;
518
519    fn poll_next(
520        mut self: std::pin::Pin<&mut Self>,
521        cx: &mut std::task::Context<'_>,
522    ) -> std::task::Poll<Option<Self::Item>> {
523        let this = &mut *self;
524        if this.inner.check_shutdown(cx) {
525            this.is_terminated = true;
526            return std::task::Poll::Ready(None);
527        }
528        if this.is_terminated {
529            panic!("polled DataChannelRequestStream after completion");
530        }
531        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
532            |bytes, handles| {
533                match this.inner.channel().read_etc(cx, bytes, handles) {
534                    std::task::Poll::Ready(Ok(())) => {}
535                    std::task::Poll::Pending => return std::task::Poll::Pending,
536                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
537                        this.is_terminated = true;
538                        return std::task::Poll::Ready(None);
539                    }
540                    std::task::Poll::Ready(Err(e)) => {
541                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
542                            e.into(),
543                        ))));
544                    }
545                }
546
547                // A message has been received from the channel
548                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
549
550                std::task::Poll::Ready(Some(match header.ordinal {
551                    0x1778251ad75157b6 => {
552                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
553                        let mut req = fidl::new_empty!(
554                            DataChannelRegisterRequest,
555                            fidl::encoding::DefaultFuchsiaResourceDialect
556                        );
557                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DataChannelRegisterRequest>(&header, _body_bytes, handles, &mut req)?;
558                        let control_handle = DataChannelControlHandle { inner: this.inner.clone() };
559                        Ok(DataChannelRequest::Register {
560                            event: req.event,
561
562                            responder: DataChannelRegisterResponder {
563                                control_handle: std::mem::ManuallyDrop::new(control_handle),
564                                tx_id: header.tx_id,
565                            },
566                        })
567                    }
568                    0x4bf148d0ddbd4f69 => {
569                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
570                        let mut req = fidl::new_empty!(
571                            fidl::encoding::EmptyPayload,
572                            fidl::encoding::DefaultFuchsiaResourceDialect
573                        );
574                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
575                        let control_handle = DataChannelControlHandle { inner: this.inner.clone() };
576                        Ok(DataChannelRequest::GetIdentifier {
577                            responder: DataChannelGetIdentifierResponder {
578                                control_handle: std::mem::ManuallyDrop::new(control_handle),
579                                tx_id: header.tx_id,
580                            },
581                        })
582                    }
583                    0x12ab08cf21533d26 => {
584                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
585                        let mut req = fidl::new_empty!(
586                            DataChannelReadRequest,
587                            fidl::encoding::DefaultFuchsiaResourceDialect
588                        );
589                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DataChannelReadRequest>(&header, _body_bytes, handles, &mut req)?;
590                        let control_handle = DataChannelControlHandle { inner: this.inner.clone() };
591                        Ok(DataChannelRequest::Read {
592                            payload: req,
593                            responder: DataChannelReadResponder {
594                                control_handle: std::mem::ManuallyDrop::new(control_handle),
595                                tx_id: header.tx_id,
596                            },
597                        })
598                    }
599                    0xf2e12121698789b => {
600                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
601                        let mut req = fidl::new_empty!(
602                            DataChannelWriteRequest,
603                            fidl::encoding::DefaultFuchsiaResourceDialect
604                        );
605                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DataChannelWriteRequest>(&header, _body_bytes, handles, &mut req)?;
606                        let control_handle = DataChannelControlHandle { inner: this.inner.clone() };
607                        Ok(DataChannelRequest::Write {
608                            payload: req,
609                            responder: DataChannelWriteResponder {
610                                control_handle: std::mem::ManuallyDrop::new(control_handle),
611                                tx_id: header.tx_id,
612                            },
613                        })
614                    }
615                    _ if header.tx_id == 0
616                        && header
617                            .dynamic_flags()
618                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
619                    {
620                        Ok(DataChannelRequest::_UnknownMethod {
621                            ordinal: header.ordinal,
622                            control_handle: DataChannelControlHandle { inner: this.inner.clone() },
623                            method_type: fidl::MethodType::OneWay,
624                        })
625                    }
626                    _ if header
627                        .dynamic_flags()
628                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
629                    {
630                        this.inner.send_framework_err(
631                            fidl::encoding::FrameworkErr::UnknownMethod,
632                            header.tx_id,
633                            header.ordinal,
634                            header.dynamic_flags(),
635                            (bytes, handles),
636                        )?;
637                        Ok(DataChannelRequest::_UnknownMethod {
638                            ordinal: header.ordinal,
639                            control_handle: DataChannelControlHandle { inner: this.inner.clone() },
640                            method_type: fidl::MethodType::TwoWay,
641                        })
642                    }
643                    _ => Err(fidl::Error::UnknownOrdinal {
644                        ordinal: header.ordinal,
645                        protocol_name:
646                            <DataChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
647                    }),
648                }))
649            },
650        )
651    }
652}
653
654#[derive(Debug)]
655pub enum DataChannelRequest {
656    /// Set event used to signal device state. Discards existing event
657    /// after having transferred device state to the new event.
658    /// This must be called before invoking Read or Write, and can fail with
659    /// ZX_ERR_NO_RESOURCES if the underlying channel is busy.
660    Register { event: fidl::Event, responder: DataChannelRegisterResponder },
661    /// Returns the identifier associated with this connection.
662    GetIdentifier { responder: DataChannelGetIdentifierResponder },
663    /// The call will return the next datagram to be read from the channel.
664    /// If there is more data to be read, SIGNAL_READABLE will remain asserted
665    /// after this call returns.
666    Read { payload: DataChannelReadRequest, responder: DataChannelReadResponder },
667    /// The call will return once the data is fully committed.
668    ///
669    /// If the driver is not ready for a write, it will return
670    /// ZX_ERR_NO_RESOURCES and the caller should await SIGNAL_WRITABLE to be
671    /// asserted.
672    Write { payload: DataChannelWriteRequest, responder: DataChannelWriteResponder },
673    /// An interaction was received which does not match any known method.
674    #[non_exhaustive]
675    _UnknownMethod {
676        /// Ordinal of the method that was called.
677        ordinal: u64,
678        control_handle: DataChannelControlHandle,
679        method_type: fidl::MethodType,
680    },
681}
682
683impl DataChannelRequest {
684    #[allow(irrefutable_let_patterns)]
685    pub fn into_register(self) -> Option<(fidl::Event, DataChannelRegisterResponder)> {
686        if let DataChannelRequest::Register { event, responder } = self {
687            Some((event, responder))
688        } else {
689            None
690        }
691    }
692
693    #[allow(irrefutable_let_patterns)]
694    pub fn into_get_identifier(self) -> Option<(DataChannelGetIdentifierResponder)> {
695        if let DataChannelRequest::GetIdentifier { responder } = self {
696            Some((responder))
697        } else {
698            None
699        }
700    }
701
702    #[allow(irrefutable_let_patterns)]
703    pub fn into_read(self) -> Option<(DataChannelReadRequest, DataChannelReadResponder)> {
704        if let DataChannelRequest::Read { payload, responder } = self {
705            Some((payload, responder))
706        } else {
707            None
708        }
709    }
710
711    #[allow(irrefutable_let_patterns)]
712    pub fn into_write(self) -> Option<(DataChannelWriteRequest, DataChannelWriteResponder)> {
713        if let DataChannelRequest::Write { payload, responder } = self {
714            Some((payload, responder))
715        } else {
716            None
717        }
718    }
719
720    /// Name of the method defined in FIDL
721    pub fn method_name(&self) -> &'static str {
722        match *self {
723            DataChannelRequest::Register { .. } => "register",
724            DataChannelRequest::GetIdentifier { .. } => "get_identifier",
725            DataChannelRequest::Read { .. } => "read",
726            DataChannelRequest::Write { .. } => "write",
727            DataChannelRequest::_UnknownMethod {
728                method_type: fidl::MethodType::OneWay, ..
729            } => "unknown one-way method",
730            DataChannelRequest::_UnknownMethod {
731                method_type: fidl::MethodType::TwoWay, ..
732            } => "unknown two-way method",
733        }
734    }
735}
736
737#[derive(Debug, Clone)]
738pub struct DataChannelControlHandle {
739    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
740}
741
742impl fidl::endpoints::ControlHandle for DataChannelControlHandle {
743    fn shutdown(&self) {
744        self.inner.shutdown()
745    }
746    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
747        self.inner.shutdown_with_epitaph(status)
748    }
749
750    fn is_closed(&self) -> bool {
751        self.inner.channel().is_closed()
752    }
753    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
754        self.inner.channel().on_closed()
755    }
756
757    #[cfg(target_os = "fuchsia")]
758    fn signal_peer(
759        &self,
760        clear_mask: zx::Signals,
761        set_mask: zx::Signals,
762    ) -> Result<(), zx_status::Status> {
763        use fidl::Peered;
764        self.inner.channel().signal_peer(clear_mask, set_mask)
765    }
766}
767
768impl DataChannelControlHandle {}
769
770#[must_use = "FIDL methods require a response to be sent"]
771#[derive(Debug)]
772pub struct DataChannelRegisterResponder {
773    control_handle: std::mem::ManuallyDrop<DataChannelControlHandle>,
774    tx_id: u32,
775}
776
777/// Set the the channel to be shutdown (see [`DataChannelControlHandle::shutdown`])
778/// if the responder is dropped without sending a response, so that the client
779/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
780impl std::ops::Drop for DataChannelRegisterResponder {
781    fn drop(&mut self) {
782        self.control_handle.shutdown();
783        // Safety: drops once, never accessed again
784        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
785    }
786}
787
788impl fidl::endpoints::Responder for DataChannelRegisterResponder {
789    type ControlHandle = DataChannelControlHandle;
790
791    fn control_handle(&self) -> &DataChannelControlHandle {
792        &self.control_handle
793    }
794
795    fn drop_without_shutdown(mut self) {
796        // Safety: drops once, never accessed again due to mem::forget
797        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
798        // Prevent Drop from running (which would shut down the channel)
799        std::mem::forget(self);
800    }
801}
802
803impl DataChannelRegisterResponder {
804    /// Sends a response to the FIDL transaction.
805    ///
806    /// Sets the channel to shutdown if an error occurs.
807    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
808        let _result = self.send_raw(result);
809        if _result.is_err() {
810            self.control_handle.shutdown();
811        }
812        self.drop_without_shutdown();
813        _result
814    }
815
816    /// Similar to "send" but does not shutdown the channel if an error occurs.
817    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
818        let _result = self.send_raw(result);
819        self.drop_without_shutdown();
820        _result
821    }
822
823    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
824        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
825            fidl::encoding::EmptyStruct,
826            i32,
827        >>(
828            fidl::encoding::FlexibleResult::new(result),
829            self.tx_id,
830            0x1778251ad75157b6,
831            fidl::encoding::DynamicFlags::FLEXIBLE,
832        )
833    }
834}
835
836#[must_use = "FIDL methods require a response to be sent"]
837#[derive(Debug)]
838pub struct DataChannelGetIdentifierResponder {
839    control_handle: std::mem::ManuallyDrop<DataChannelControlHandle>,
840    tx_id: u32,
841}
842
843/// Set the the channel to be shutdown (see [`DataChannelControlHandle::shutdown`])
844/// if the responder is dropped without sending a response, so that the client
845/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
846impl std::ops::Drop for DataChannelGetIdentifierResponder {
847    fn drop(&mut self) {
848        self.control_handle.shutdown();
849        // Safety: drops once, never accessed again
850        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
851    }
852}
853
854impl fidl::endpoints::Responder for DataChannelGetIdentifierResponder {
855    type ControlHandle = DataChannelControlHandle;
856
857    fn control_handle(&self) -> &DataChannelControlHandle {
858        &self.control_handle
859    }
860
861    fn drop_without_shutdown(mut self) {
862        // Safety: drops once, never accessed again due to mem::forget
863        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
864        // Prevent Drop from running (which would shut down the channel)
865        std::mem::forget(self);
866    }
867}
868
869impl DataChannelGetIdentifierResponder {
870    /// Sends a response to the FIDL transaction.
871    ///
872    /// Sets the channel to shutdown if an error occurs.
873    pub fn send(self, mut payload: &DataChannelGetIdentifierResponse) -> Result<(), fidl::Error> {
874        let _result = self.send_raw(payload);
875        if _result.is_err() {
876            self.control_handle.shutdown();
877        }
878        self.drop_without_shutdown();
879        _result
880    }
881
882    /// Similar to "send" but does not shutdown the channel if an error occurs.
883    pub fn send_no_shutdown_on_err(
884        self,
885        mut payload: &DataChannelGetIdentifierResponse,
886    ) -> Result<(), fidl::Error> {
887        let _result = self.send_raw(payload);
888        self.drop_without_shutdown();
889        _result
890    }
891
892    fn send_raw(&self, mut payload: &DataChannelGetIdentifierResponse) -> Result<(), fidl::Error> {
893        self.control_handle
894            .inner
895            .send::<fidl::encoding::FlexibleType<DataChannelGetIdentifierResponse>>(
896                fidl::encoding::Flexible::new(payload),
897                self.tx_id,
898                0x4bf148d0ddbd4f69,
899                fidl::encoding::DynamicFlags::FLEXIBLE,
900            )
901    }
902}
903
904#[must_use = "FIDL methods require a response to be sent"]
905#[derive(Debug)]
906pub struct DataChannelReadResponder {
907    control_handle: std::mem::ManuallyDrop<DataChannelControlHandle>,
908    tx_id: u32,
909}
910
911/// Set the the channel to be shutdown (see [`DataChannelControlHandle::shutdown`])
912/// if the responder is dropped without sending a response, so that the client
913/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
914impl std::ops::Drop for DataChannelReadResponder {
915    fn drop(&mut self) {
916        self.control_handle.shutdown();
917        // Safety: drops once, never accessed again
918        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
919    }
920}
921
922impl fidl::endpoints::Responder for DataChannelReadResponder {
923    type ControlHandle = DataChannelControlHandle;
924
925    fn control_handle(&self) -> &DataChannelControlHandle {
926        &self.control_handle
927    }
928
929    fn drop_without_shutdown(mut self) {
930        // Safety: drops once, never accessed again due to mem::forget
931        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
932        // Prevent Drop from running (which would shut down the channel)
933        std::mem::forget(self);
934    }
935}
936
937impl DataChannelReadResponder {
938    /// Sends a response to the FIDL transaction.
939    ///
940    /// Sets the channel to shutdown if an error occurs.
941    pub fn send(self, mut result: Result<DataChannelReadResponse, i32>) -> Result<(), fidl::Error> {
942        let _result = self.send_raw(result);
943        if _result.is_err() {
944            self.control_handle.shutdown();
945        }
946        self.drop_without_shutdown();
947        _result
948    }
949
950    /// Similar to "send" but does not shutdown the channel if an error occurs.
951    pub fn send_no_shutdown_on_err(
952        self,
953        mut result: Result<DataChannelReadResponse, i32>,
954    ) -> Result<(), fidl::Error> {
955        let _result = self.send_raw(result);
956        self.drop_without_shutdown();
957        _result
958    }
959
960    fn send_raw(
961        &self,
962        mut result: Result<DataChannelReadResponse, i32>,
963    ) -> Result<(), fidl::Error> {
964        self.control_handle
965            .inner
966            .send::<fidl::encoding::FlexibleResultType<DataChannelReadResponse, i32>>(
967                fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
968                self.tx_id,
969                0x12ab08cf21533d26,
970                fidl::encoding::DynamicFlags::FLEXIBLE,
971            )
972    }
973}
974
975#[must_use = "FIDL methods require a response to be sent"]
976#[derive(Debug)]
977pub struct DataChannelWriteResponder {
978    control_handle: std::mem::ManuallyDrop<DataChannelControlHandle>,
979    tx_id: u32,
980}
981
982/// Set the the channel to be shutdown (see [`DataChannelControlHandle::shutdown`])
983/// if the responder is dropped without sending a response, so that the client
984/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
985impl std::ops::Drop for DataChannelWriteResponder {
986    fn drop(&mut self) {
987        self.control_handle.shutdown();
988        // Safety: drops once, never accessed again
989        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
990    }
991}
992
993impl fidl::endpoints::Responder for DataChannelWriteResponder {
994    type ControlHandle = DataChannelControlHandle;
995
996    fn control_handle(&self) -> &DataChannelControlHandle {
997        &self.control_handle
998    }
999
1000    fn drop_without_shutdown(mut self) {
1001        // Safety: drops once, never accessed again due to mem::forget
1002        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1003        // Prevent Drop from running (which would shut down the channel)
1004        std::mem::forget(self);
1005    }
1006}
1007
1008impl DataChannelWriteResponder {
1009    /// Sends a response to the FIDL transaction.
1010    ///
1011    /// Sets the channel to shutdown if an error occurs.
1012    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1013        let _result = self.send_raw(result);
1014        if _result.is_err() {
1015            self.control_handle.shutdown();
1016        }
1017        self.drop_without_shutdown();
1018        _result
1019    }
1020
1021    /// Similar to "send" but does not shutdown the channel if an error occurs.
1022    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1023        let _result = self.send_raw(result);
1024        self.drop_without_shutdown();
1025        _result
1026    }
1027
1028    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1029        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1030            fidl::encoding::EmptyStruct,
1031            i32,
1032        >>(
1033            fidl::encoding::FlexibleResult::new(result),
1034            self.tx_id,
1035            0xf2e12121698789b,
1036            fidl::encoding::DynamicFlags::FLEXIBLE,
1037        )
1038    }
1039}
1040
1041#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1042pub struct DeviceMarker;
1043
1044impl fidl::endpoints::ProtocolMarker for DeviceMarker {
1045    type Proxy = DeviceProxy;
1046    type RequestStream = DeviceRequestStream;
1047    #[cfg(target_os = "fuchsia")]
1048    type SynchronousProxy = DeviceSynchronousProxy;
1049
1050    const DEBUG_NAME: &'static str = "fuchsia.hardware.google.nanohub.Device";
1051}
1052impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
1053pub type DeviceDownloadFirmwareResult = Result<(), i32>;
1054pub type DeviceGetTimeSyncResult = Result<McuTimeSyncInfo, i32>;
1055pub type DeviceSetWakeLockResult = Result<(), i32>;
1056pub type DeviceGetWakeUpEventDurationResult = Result<i64, i32>;
1057pub type DeviceSetWakeUpEventDurationResult = Result<(), i32>;
1058pub type DeviceHardwareResetResult = Result<(), i32>;
1059
1060pub trait DeviceProxyInterface: Send + Sync {
1061    type DownloadFirmwareResponseFut: std::future::Future<Output = Result<DeviceDownloadFirmwareResult, fidl::Error>>
1062        + Send;
1063    fn r#download_firmware(
1064        &self,
1065        firmware: fidl::Vmo,
1066        offset: u64,
1067    ) -> Self::DownloadFirmwareResponseFut;
1068    type GetFirmwareNameResponseFut: std::future::Future<Output = Result<String, fidl::Error>>
1069        + Send;
1070    fn r#get_firmware_name(&self) -> Self::GetFirmwareNameResponseFut;
1071    type GetFirmwareVersionResponseFut: std::future::Future<Output = Result<McuVersionInfo, fidl::Error>>
1072        + Send;
1073    fn r#get_firmware_version(&self) -> Self::GetFirmwareVersionResponseFut;
1074    type GetTimeSyncResponseFut: std::future::Future<Output = Result<DeviceGetTimeSyncResult, fidl::Error>>
1075        + Send;
1076    fn r#get_time_sync(&self) -> Self::GetTimeSyncResponseFut;
1077    type SetWakeLockResponseFut: std::future::Future<Output = Result<DeviceSetWakeLockResult, fidl::Error>>
1078        + Send;
1079    fn r#set_wake_lock(&self, value: McuWakeLockValue) -> Self::SetWakeLockResponseFut;
1080    type GetWakeUpEventDurationResponseFut: std::future::Future<Output = Result<DeviceGetWakeUpEventDurationResult, fidl::Error>>
1081        + Send;
1082    fn r#get_wake_up_event_duration(&self) -> Self::GetWakeUpEventDurationResponseFut;
1083    type SetWakeUpEventDurationResponseFut: std::future::Future<Output = Result<DeviceSetWakeUpEventDurationResult, fidl::Error>>
1084        + Send;
1085    fn r#set_wake_up_event_duration(
1086        &self,
1087        duration: i64,
1088    ) -> Self::SetWakeUpEventDurationResponseFut;
1089    type HardwareResetResponseFut: std::future::Future<Output = Result<DeviceHardwareResetResult, fidl::Error>>
1090        + Send;
1091    fn r#hardware_reset(
1092        &self,
1093        isp_pin_0: PinState,
1094        isp_pin_1: PinState,
1095        isp_pin_2: PinState,
1096    ) -> Self::HardwareResetResponseFut;
1097}
1098#[derive(Debug)]
1099#[cfg(target_os = "fuchsia")]
1100pub struct DeviceSynchronousProxy {
1101    client: fidl::client::sync::Client,
1102}
1103
1104#[cfg(target_os = "fuchsia")]
1105impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
1106    type Proxy = DeviceProxy;
1107    type Protocol = DeviceMarker;
1108
1109    fn from_channel(inner: fidl::Channel) -> Self {
1110        Self::new(inner)
1111    }
1112
1113    fn into_channel(self) -> fidl::Channel {
1114        self.client.into_channel()
1115    }
1116
1117    fn as_channel(&self) -> &fidl::Channel {
1118        self.client.as_channel()
1119    }
1120}
1121
1122#[cfg(target_os = "fuchsia")]
1123impl DeviceSynchronousProxy {
1124    pub fn new(channel: fidl::Channel) -> Self {
1125        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1126        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1127    }
1128
1129    pub fn into_channel(self) -> fidl::Channel {
1130        self.client.into_channel()
1131    }
1132
1133    /// Waits until an event arrives and returns it. It is safe for other
1134    /// threads to make concurrent requests while waiting for an event.
1135    pub fn wait_for_event(
1136        &self,
1137        deadline: zx::MonotonicInstant,
1138    ) -> Result<DeviceEvent, fidl::Error> {
1139        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
1140    }
1141
1142    /// Request to sent to nanohub to load the firmware.
1143    pub fn r#download_firmware(
1144        &self,
1145        mut firmware: fidl::Vmo,
1146        mut offset: u64,
1147        ___deadline: zx::MonotonicInstant,
1148    ) -> Result<DeviceDownloadFirmwareResult, fidl::Error> {
1149        let _response = self.client.send_query::<
1150            DeviceDownloadFirmwareRequest,
1151            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1152        >(
1153            (firmware, offset,),
1154            0x7bba8137e24661e5,
1155            fidl::encoding::DynamicFlags::empty(),
1156            ___deadline,
1157        )?;
1158        Ok(_response.map(|x| x))
1159    }
1160
1161    /// The name of the firmware binary running on the MCU.
1162    pub fn r#get_firmware_name(
1163        &self,
1164        ___deadline: zx::MonotonicInstant,
1165    ) -> Result<String, fidl::Error> {
1166        let _response =
1167            self.client.send_query::<fidl::encoding::EmptyPayload, DeviceGetFirmwareNameResponse>(
1168                (),
1169                0x1649434b5e5bcb8d,
1170                fidl::encoding::DynamicFlags::empty(),
1171                ___deadline,
1172            )?;
1173        Ok(_response.firmware_name)
1174    }
1175
1176    /// The version of the firmware binary running on the MCU.
1177    pub fn r#get_firmware_version(
1178        &self,
1179        ___deadline: zx::MonotonicInstant,
1180    ) -> Result<McuVersionInfo, fidl::Error> {
1181        let _response = self
1182            .client
1183            .send_query::<fidl::encoding::EmptyPayload, DeviceGetFirmwareVersionResponse>(
1184                (),
1185                0x4f0599abcc95736b,
1186                fidl::encoding::DynamicFlags::empty(),
1187                ___deadline,
1188            )?;
1189        Ok(_response.version_info)
1190    }
1191
1192    /// The time since boot recorded by the AP and the MCU.
1193    pub fn r#get_time_sync(
1194        &self,
1195        ___deadline: zx::MonotonicInstant,
1196    ) -> Result<DeviceGetTimeSyncResult, fidl::Error> {
1197        let _response = self.client.send_query::<
1198            fidl::encoding::EmptyPayload,
1199            fidl::encoding::ResultType<McuTimeSyncInfo, i32>,
1200        >(
1201            (),
1202            0x4406991222e3975d,
1203            fidl::encoding::DynamicFlags::empty(),
1204            ___deadline,
1205        )?;
1206        Ok(_response.map(|x| x))
1207    }
1208
1209    /// Set an MCU wake lock request to prevent the MCU from entering a low-power state.
1210    pub fn r#set_wake_lock(
1211        &self,
1212        mut value: McuWakeLockValue,
1213        ___deadline: zx::MonotonicInstant,
1214    ) -> Result<DeviceSetWakeLockResult, fidl::Error> {
1215        let _response = self.client.send_query::<
1216            DeviceSetWakeLockRequest,
1217            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1218        >(
1219            (value,),
1220            0x9f83f614affa1dc,
1221            fidl::encoding::DynamicFlags::empty(),
1222            ___deadline,
1223        )?;
1224        Ok(_response.map(|x| x))
1225    }
1226
1227    /// Get the current duration of time the MCU will remain awake.
1228    pub fn r#get_wake_up_event_duration(
1229        &self,
1230        ___deadline: zx::MonotonicInstant,
1231    ) -> Result<DeviceGetWakeUpEventDurationResult, fidl::Error> {
1232        let _response = self.client.send_query::<
1233            fidl::encoding::EmptyPayload,
1234            fidl::encoding::ResultType<DeviceGetWakeUpEventDurationResponse, i32>,
1235        >(
1236            (),
1237            0x45c79749f65e7176,
1238            fidl::encoding::DynamicFlags::empty(),
1239            ___deadline,
1240        )?;
1241        Ok(_response.map(|x| x.duration))
1242    }
1243
1244    /// Set a duration of time for the MCU to remain awake.
1245    pub fn r#set_wake_up_event_duration(
1246        &self,
1247        mut duration: i64,
1248        ___deadline: zx::MonotonicInstant,
1249    ) -> Result<DeviceSetWakeUpEventDurationResult, fidl::Error> {
1250        let _response = self.client.send_query::<
1251            DeviceSetWakeUpEventDurationRequest,
1252            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1253        >(
1254            (duration,),
1255            0x1fa1771ffa5f570,
1256            fidl::encoding::DynamicFlags::empty(),
1257            ___deadline,
1258        )?;
1259        Ok(_response.map(|x| x))
1260    }
1261
1262    /// Initiates a hardware reset.
1263    pub fn r#hardware_reset(
1264        &self,
1265        mut isp_pin_0: PinState,
1266        mut isp_pin_1: PinState,
1267        mut isp_pin_2: PinState,
1268        ___deadline: zx::MonotonicInstant,
1269    ) -> Result<DeviceHardwareResetResult, fidl::Error> {
1270        let _response = self.client.send_query::<
1271            HardwareResetPinStates,
1272            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1273        >(
1274            (isp_pin_0, isp_pin_1, isp_pin_2,),
1275            0x78e3d2ded2f929f,
1276            fidl::encoding::DynamicFlags::empty(),
1277            ___deadline,
1278        )?;
1279        Ok(_response.map(|x| x))
1280    }
1281}
1282
1283#[cfg(target_os = "fuchsia")]
1284impl From<DeviceSynchronousProxy> for zx::Handle {
1285    fn from(value: DeviceSynchronousProxy) -> Self {
1286        value.into_channel().into()
1287    }
1288}
1289
1290#[cfg(target_os = "fuchsia")]
1291impl From<fidl::Channel> for DeviceSynchronousProxy {
1292    fn from(value: fidl::Channel) -> Self {
1293        Self::new(value)
1294    }
1295}
1296
1297#[cfg(target_os = "fuchsia")]
1298impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
1299    type Protocol = DeviceMarker;
1300
1301    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
1302        Self::new(value.into_channel())
1303    }
1304}
1305
1306#[derive(Debug, Clone)]
1307pub struct DeviceProxy {
1308    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1309}
1310
1311impl fidl::endpoints::Proxy for DeviceProxy {
1312    type Protocol = DeviceMarker;
1313
1314    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1315        Self::new(inner)
1316    }
1317
1318    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1319        self.client.into_channel().map_err(|client| Self { client })
1320    }
1321
1322    fn as_channel(&self) -> &::fidl::AsyncChannel {
1323        self.client.as_channel()
1324    }
1325}
1326
1327impl DeviceProxy {
1328    /// Create a new Proxy for fuchsia.hardware.google.nanohub/Device.
1329    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1330        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1331        Self { client: fidl::client::Client::new(channel, protocol_name) }
1332    }
1333
1334    /// Get a Stream of events from the remote end of the protocol.
1335    ///
1336    /// # Panics
1337    ///
1338    /// Panics if the event stream was already taken.
1339    pub fn take_event_stream(&self) -> DeviceEventStream {
1340        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
1341    }
1342
1343    /// Request to sent to nanohub to load the firmware.
1344    pub fn r#download_firmware(
1345        &self,
1346        mut firmware: fidl::Vmo,
1347        mut offset: u64,
1348    ) -> fidl::client::QueryResponseFut<
1349        DeviceDownloadFirmwareResult,
1350        fidl::encoding::DefaultFuchsiaResourceDialect,
1351    > {
1352        DeviceProxyInterface::r#download_firmware(self, firmware, offset)
1353    }
1354
1355    /// The name of the firmware binary running on the MCU.
1356    pub fn r#get_firmware_name(
1357        &self,
1358    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
1359        DeviceProxyInterface::r#get_firmware_name(self)
1360    }
1361
1362    /// The version of the firmware binary running on the MCU.
1363    pub fn r#get_firmware_version(
1364        &self,
1365    ) -> fidl::client::QueryResponseFut<McuVersionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
1366    {
1367        DeviceProxyInterface::r#get_firmware_version(self)
1368    }
1369
1370    /// The time since boot recorded by the AP and the MCU.
1371    pub fn r#get_time_sync(
1372        &self,
1373    ) -> fidl::client::QueryResponseFut<
1374        DeviceGetTimeSyncResult,
1375        fidl::encoding::DefaultFuchsiaResourceDialect,
1376    > {
1377        DeviceProxyInterface::r#get_time_sync(self)
1378    }
1379
1380    /// Set an MCU wake lock request to prevent the MCU from entering a low-power state.
1381    pub fn r#set_wake_lock(
1382        &self,
1383        mut value: McuWakeLockValue,
1384    ) -> fidl::client::QueryResponseFut<
1385        DeviceSetWakeLockResult,
1386        fidl::encoding::DefaultFuchsiaResourceDialect,
1387    > {
1388        DeviceProxyInterface::r#set_wake_lock(self, value)
1389    }
1390
1391    /// Get the current duration of time the MCU will remain awake.
1392    pub fn r#get_wake_up_event_duration(
1393        &self,
1394    ) -> fidl::client::QueryResponseFut<
1395        DeviceGetWakeUpEventDurationResult,
1396        fidl::encoding::DefaultFuchsiaResourceDialect,
1397    > {
1398        DeviceProxyInterface::r#get_wake_up_event_duration(self)
1399    }
1400
1401    /// Set a duration of time for the MCU to remain awake.
1402    pub fn r#set_wake_up_event_duration(
1403        &self,
1404        mut duration: i64,
1405    ) -> fidl::client::QueryResponseFut<
1406        DeviceSetWakeUpEventDurationResult,
1407        fidl::encoding::DefaultFuchsiaResourceDialect,
1408    > {
1409        DeviceProxyInterface::r#set_wake_up_event_duration(self, duration)
1410    }
1411
1412    /// Initiates a hardware reset.
1413    pub fn r#hardware_reset(
1414        &self,
1415        mut isp_pin_0: PinState,
1416        mut isp_pin_1: PinState,
1417        mut isp_pin_2: PinState,
1418    ) -> fidl::client::QueryResponseFut<
1419        DeviceHardwareResetResult,
1420        fidl::encoding::DefaultFuchsiaResourceDialect,
1421    > {
1422        DeviceProxyInterface::r#hardware_reset(self, isp_pin_0, isp_pin_1, isp_pin_2)
1423    }
1424}
1425
1426impl DeviceProxyInterface for DeviceProxy {
1427    type DownloadFirmwareResponseFut = fidl::client::QueryResponseFut<
1428        DeviceDownloadFirmwareResult,
1429        fidl::encoding::DefaultFuchsiaResourceDialect,
1430    >;
1431    fn r#download_firmware(
1432        &self,
1433        mut firmware: fidl::Vmo,
1434        mut offset: u64,
1435    ) -> Self::DownloadFirmwareResponseFut {
1436        fn _decode(
1437            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1438        ) -> Result<DeviceDownloadFirmwareResult, fidl::Error> {
1439            let _response = fidl::client::decode_transaction_body::<
1440                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1441                fidl::encoding::DefaultFuchsiaResourceDialect,
1442                0x7bba8137e24661e5,
1443            >(_buf?)?;
1444            Ok(_response.map(|x| x))
1445        }
1446        self.client
1447            .send_query_and_decode::<DeviceDownloadFirmwareRequest, DeviceDownloadFirmwareResult>(
1448                (firmware, offset),
1449                0x7bba8137e24661e5,
1450                fidl::encoding::DynamicFlags::empty(),
1451                _decode,
1452            )
1453    }
1454
1455    type GetFirmwareNameResponseFut =
1456        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
1457    fn r#get_firmware_name(&self) -> Self::GetFirmwareNameResponseFut {
1458        fn _decode(
1459            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1460        ) -> Result<String, fidl::Error> {
1461            let _response = fidl::client::decode_transaction_body::<
1462                DeviceGetFirmwareNameResponse,
1463                fidl::encoding::DefaultFuchsiaResourceDialect,
1464                0x1649434b5e5bcb8d,
1465            >(_buf?)?;
1466            Ok(_response.firmware_name)
1467        }
1468        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
1469            (),
1470            0x1649434b5e5bcb8d,
1471            fidl::encoding::DynamicFlags::empty(),
1472            _decode,
1473        )
1474    }
1475
1476    type GetFirmwareVersionResponseFut = fidl::client::QueryResponseFut<
1477        McuVersionInfo,
1478        fidl::encoding::DefaultFuchsiaResourceDialect,
1479    >;
1480    fn r#get_firmware_version(&self) -> Self::GetFirmwareVersionResponseFut {
1481        fn _decode(
1482            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1483        ) -> Result<McuVersionInfo, fidl::Error> {
1484            let _response = fidl::client::decode_transaction_body::<
1485                DeviceGetFirmwareVersionResponse,
1486                fidl::encoding::DefaultFuchsiaResourceDialect,
1487                0x4f0599abcc95736b,
1488            >(_buf?)?;
1489            Ok(_response.version_info)
1490        }
1491        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, McuVersionInfo>(
1492            (),
1493            0x4f0599abcc95736b,
1494            fidl::encoding::DynamicFlags::empty(),
1495            _decode,
1496        )
1497    }
1498
1499    type GetTimeSyncResponseFut = fidl::client::QueryResponseFut<
1500        DeviceGetTimeSyncResult,
1501        fidl::encoding::DefaultFuchsiaResourceDialect,
1502    >;
1503    fn r#get_time_sync(&self) -> Self::GetTimeSyncResponseFut {
1504        fn _decode(
1505            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1506        ) -> Result<DeviceGetTimeSyncResult, fidl::Error> {
1507            let _response = fidl::client::decode_transaction_body::<
1508                fidl::encoding::ResultType<McuTimeSyncInfo, i32>,
1509                fidl::encoding::DefaultFuchsiaResourceDialect,
1510                0x4406991222e3975d,
1511            >(_buf?)?;
1512            Ok(_response.map(|x| x))
1513        }
1514        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetTimeSyncResult>(
1515            (),
1516            0x4406991222e3975d,
1517            fidl::encoding::DynamicFlags::empty(),
1518            _decode,
1519        )
1520    }
1521
1522    type SetWakeLockResponseFut = fidl::client::QueryResponseFut<
1523        DeviceSetWakeLockResult,
1524        fidl::encoding::DefaultFuchsiaResourceDialect,
1525    >;
1526    fn r#set_wake_lock(&self, mut value: McuWakeLockValue) -> Self::SetWakeLockResponseFut {
1527        fn _decode(
1528            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1529        ) -> Result<DeviceSetWakeLockResult, fidl::Error> {
1530            let _response = fidl::client::decode_transaction_body::<
1531                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1532                fidl::encoding::DefaultFuchsiaResourceDialect,
1533                0x9f83f614affa1dc,
1534            >(_buf?)?;
1535            Ok(_response.map(|x| x))
1536        }
1537        self.client.send_query_and_decode::<DeviceSetWakeLockRequest, DeviceSetWakeLockResult>(
1538            (value,),
1539            0x9f83f614affa1dc,
1540            fidl::encoding::DynamicFlags::empty(),
1541            _decode,
1542        )
1543    }
1544
1545    type GetWakeUpEventDurationResponseFut = fidl::client::QueryResponseFut<
1546        DeviceGetWakeUpEventDurationResult,
1547        fidl::encoding::DefaultFuchsiaResourceDialect,
1548    >;
1549    fn r#get_wake_up_event_duration(&self) -> Self::GetWakeUpEventDurationResponseFut {
1550        fn _decode(
1551            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1552        ) -> Result<DeviceGetWakeUpEventDurationResult, fidl::Error> {
1553            let _response = fidl::client::decode_transaction_body::<
1554                fidl::encoding::ResultType<DeviceGetWakeUpEventDurationResponse, i32>,
1555                fidl::encoding::DefaultFuchsiaResourceDialect,
1556                0x45c79749f65e7176,
1557            >(_buf?)?;
1558            Ok(_response.map(|x| x.duration))
1559        }
1560        self.client.send_query_and_decode::<
1561            fidl::encoding::EmptyPayload,
1562            DeviceGetWakeUpEventDurationResult,
1563        >(
1564            (),
1565            0x45c79749f65e7176,
1566            fidl::encoding::DynamicFlags::empty(),
1567            _decode,
1568        )
1569    }
1570
1571    type SetWakeUpEventDurationResponseFut = fidl::client::QueryResponseFut<
1572        DeviceSetWakeUpEventDurationResult,
1573        fidl::encoding::DefaultFuchsiaResourceDialect,
1574    >;
1575    fn r#set_wake_up_event_duration(
1576        &self,
1577        mut duration: i64,
1578    ) -> Self::SetWakeUpEventDurationResponseFut {
1579        fn _decode(
1580            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1581        ) -> Result<DeviceSetWakeUpEventDurationResult, fidl::Error> {
1582            let _response = fidl::client::decode_transaction_body::<
1583                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1584                fidl::encoding::DefaultFuchsiaResourceDialect,
1585                0x1fa1771ffa5f570,
1586            >(_buf?)?;
1587            Ok(_response.map(|x| x))
1588        }
1589        self.client.send_query_and_decode::<
1590            DeviceSetWakeUpEventDurationRequest,
1591            DeviceSetWakeUpEventDurationResult,
1592        >(
1593            (duration,),
1594            0x1fa1771ffa5f570,
1595            fidl::encoding::DynamicFlags::empty(),
1596            _decode,
1597        )
1598    }
1599
1600    type HardwareResetResponseFut = fidl::client::QueryResponseFut<
1601        DeviceHardwareResetResult,
1602        fidl::encoding::DefaultFuchsiaResourceDialect,
1603    >;
1604    fn r#hardware_reset(
1605        &self,
1606        mut isp_pin_0: PinState,
1607        mut isp_pin_1: PinState,
1608        mut isp_pin_2: PinState,
1609    ) -> Self::HardwareResetResponseFut {
1610        fn _decode(
1611            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1612        ) -> Result<DeviceHardwareResetResult, fidl::Error> {
1613            let _response = fidl::client::decode_transaction_body::<
1614                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1615                fidl::encoding::DefaultFuchsiaResourceDialect,
1616                0x78e3d2ded2f929f,
1617            >(_buf?)?;
1618            Ok(_response.map(|x| x))
1619        }
1620        self.client.send_query_and_decode::<HardwareResetPinStates, DeviceHardwareResetResult>(
1621            (isp_pin_0, isp_pin_1, isp_pin_2),
1622            0x78e3d2ded2f929f,
1623            fidl::encoding::DynamicFlags::empty(),
1624            _decode,
1625        )
1626    }
1627}
1628
1629pub struct DeviceEventStream {
1630    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1631}
1632
1633impl std::marker::Unpin for DeviceEventStream {}
1634
1635impl futures::stream::FusedStream for DeviceEventStream {
1636    fn is_terminated(&self) -> bool {
1637        self.event_receiver.is_terminated()
1638    }
1639}
1640
1641impl futures::Stream for DeviceEventStream {
1642    type Item = Result<DeviceEvent, fidl::Error>;
1643
1644    fn poll_next(
1645        mut self: std::pin::Pin<&mut Self>,
1646        cx: &mut std::task::Context<'_>,
1647    ) -> std::task::Poll<Option<Self::Item>> {
1648        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1649            &mut self.event_receiver,
1650            cx
1651        )?) {
1652            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
1653            None => std::task::Poll::Ready(None),
1654        }
1655    }
1656}
1657
1658#[derive(Debug)]
1659pub enum DeviceEvent {
1660    #[non_exhaustive]
1661    _UnknownEvent {
1662        /// Ordinal of the event that was sent.
1663        ordinal: u64,
1664    },
1665}
1666
1667impl DeviceEvent {
1668    /// Decodes a message buffer as a [`DeviceEvent`].
1669    fn decode(
1670        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1671    ) -> Result<DeviceEvent, fidl::Error> {
1672        let (bytes, _handles) = buf.split_mut();
1673        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1674        debug_assert_eq!(tx_header.tx_id, 0);
1675        match tx_header.ordinal {
1676            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1677                Ok(DeviceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1678            }
1679            _ => Err(fidl::Error::UnknownOrdinal {
1680                ordinal: tx_header.ordinal,
1681                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1682            }),
1683        }
1684    }
1685}
1686
1687/// A Stream of incoming requests for fuchsia.hardware.google.nanohub/Device.
1688pub struct DeviceRequestStream {
1689    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1690    is_terminated: bool,
1691}
1692
1693impl std::marker::Unpin for DeviceRequestStream {}
1694
1695impl futures::stream::FusedStream for DeviceRequestStream {
1696    fn is_terminated(&self) -> bool {
1697        self.is_terminated
1698    }
1699}
1700
1701impl fidl::endpoints::RequestStream for DeviceRequestStream {
1702    type Protocol = DeviceMarker;
1703    type ControlHandle = DeviceControlHandle;
1704
1705    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1706        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1707    }
1708
1709    fn control_handle(&self) -> Self::ControlHandle {
1710        DeviceControlHandle { inner: self.inner.clone() }
1711    }
1712
1713    fn into_inner(
1714        self,
1715    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1716    {
1717        (self.inner, self.is_terminated)
1718    }
1719
1720    fn from_inner(
1721        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1722        is_terminated: bool,
1723    ) -> Self {
1724        Self { inner, is_terminated }
1725    }
1726}
1727
1728impl futures::Stream for DeviceRequestStream {
1729    type Item = Result<DeviceRequest, fidl::Error>;
1730
1731    fn poll_next(
1732        mut self: std::pin::Pin<&mut Self>,
1733        cx: &mut std::task::Context<'_>,
1734    ) -> std::task::Poll<Option<Self::Item>> {
1735        let this = &mut *self;
1736        if this.inner.check_shutdown(cx) {
1737            this.is_terminated = true;
1738            return std::task::Poll::Ready(None);
1739        }
1740        if this.is_terminated {
1741            panic!("polled DeviceRequestStream after completion");
1742        }
1743        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1744            |bytes, handles| {
1745                match this.inner.channel().read_etc(cx, bytes, handles) {
1746                    std::task::Poll::Ready(Ok(())) => {}
1747                    std::task::Poll::Pending => return std::task::Poll::Pending,
1748                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1749                        this.is_terminated = true;
1750                        return std::task::Poll::Ready(None);
1751                    }
1752                    std::task::Poll::Ready(Err(e)) => {
1753                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1754                            e.into(),
1755                        ))));
1756                    }
1757                }
1758
1759                // A message has been received from the channel
1760                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1761
1762                std::task::Poll::Ready(Some(match header.ordinal {
1763                    0x7bba8137e24661e5 => {
1764                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1765                        let mut req = fidl::new_empty!(
1766                            DeviceDownloadFirmwareRequest,
1767                            fidl::encoding::DefaultFuchsiaResourceDialect
1768                        );
1769                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceDownloadFirmwareRequest>(&header, _body_bytes, handles, &mut req)?;
1770                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1771                        Ok(DeviceRequest::DownloadFirmware {
1772                            firmware: req.firmware,
1773                            offset: req.offset,
1774
1775                            responder: DeviceDownloadFirmwareResponder {
1776                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1777                                tx_id: header.tx_id,
1778                            },
1779                        })
1780                    }
1781                    0x1649434b5e5bcb8d => {
1782                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1783                        let mut req = fidl::new_empty!(
1784                            fidl::encoding::EmptyPayload,
1785                            fidl::encoding::DefaultFuchsiaResourceDialect
1786                        );
1787                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1788                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1789                        Ok(DeviceRequest::GetFirmwareName {
1790                            responder: DeviceGetFirmwareNameResponder {
1791                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1792                                tx_id: header.tx_id,
1793                            },
1794                        })
1795                    }
1796                    0x4f0599abcc95736b => {
1797                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1798                        let mut req = fidl::new_empty!(
1799                            fidl::encoding::EmptyPayload,
1800                            fidl::encoding::DefaultFuchsiaResourceDialect
1801                        );
1802                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1803                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1804                        Ok(DeviceRequest::GetFirmwareVersion {
1805                            responder: DeviceGetFirmwareVersionResponder {
1806                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1807                                tx_id: header.tx_id,
1808                            },
1809                        })
1810                    }
1811                    0x4406991222e3975d => {
1812                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1813                        let mut req = fidl::new_empty!(
1814                            fidl::encoding::EmptyPayload,
1815                            fidl::encoding::DefaultFuchsiaResourceDialect
1816                        );
1817                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1818                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1819                        Ok(DeviceRequest::GetTimeSync {
1820                            responder: DeviceGetTimeSyncResponder {
1821                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1822                                tx_id: header.tx_id,
1823                            },
1824                        })
1825                    }
1826                    0x9f83f614affa1dc => {
1827                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1828                        let mut req = fidl::new_empty!(
1829                            DeviceSetWakeLockRequest,
1830                            fidl::encoding::DefaultFuchsiaResourceDialect
1831                        );
1832                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetWakeLockRequest>(&header, _body_bytes, handles, &mut req)?;
1833                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1834                        Ok(DeviceRequest::SetWakeLock {
1835                            value: req.value,
1836
1837                            responder: DeviceSetWakeLockResponder {
1838                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1839                                tx_id: header.tx_id,
1840                            },
1841                        })
1842                    }
1843                    0x45c79749f65e7176 => {
1844                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1845                        let mut req = fidl::new_empty!(
1846                            fidl::encoding::EmptyPayload,
1847                            fidl::encoding::DefaultFuchsiaResourceDialect
1848                        );
1849                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1850                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1851                        Ok(DeviceRequest::GetWakeUpEventDuration {
1852                            responder: DeviceGetWakeUpEventDurationResponder {
1853                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1854                                tx_id: header.tx_id,
1855                            },
1856                        })
1857                    }
1858                    0x1fa1771ffa5f570 => {
1859                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1860                        let mut req = fidl::new_empty!(
1861                            DeviceSetWakeUpEventDurationRequest,
1862                            fidl::encoding::DefaultFuchsiaResourceDialect
1863                        );
1864                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetWakeUpEventDurationRequest>(&header, _body_bytes, handles, &mut req)?;
1865                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1866                        Ok(DeviceRequest::SetWakeUpEventDuration {
1867                            duration: req.duration,
1868
1869                            responder: DeviceSetWakeUpEventDurationResponder {
1870                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1871                                tx_id: header.tx_id,
1872                            },
1873                        })
1874                    }
1875                    0x78e3d2ded2f929f => {
1876                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1877                        let mut req = fidl::new_empty!(
1878                            HardwareResetPinStates,
1879                            fidl::encoding::DefaultFuchsiaResourceDialect
1880                        );
1881                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HardwareResetPinStates>(&header, _body_bytes, handles, &mut req)?;
1882                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1883                        Ok(DeviceRequest::HardwareReset {
1884                            isp_pin_0: req.isp_pin_0,
1885                            isp_pin_1: req.isp_pin_1,
1886                            isp_pin_2: req.isp_pin_2,
1887
1888                            responder: DeviceHardwareResetResponder {
1889                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1890                                tx_id: header.tx_id,
1891                            },
1892                        })
1893                    }
1894                    _ if header.tx_id == 0
1895                        && header
1896                            .dynamic_flags()
1897                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1898                    {
1899                        Ok(DeviceRequest::_UnknownMethod {
1900                            ordinal: header.ordinal,
1901                            control_handle: DeviceControlHandle { inner: this.inner.clone() },
1902                            method_type: fidl::MethodType::OneWay,
1903                        })
1904                    }
1905                    _ if header
1906                        .dynamic_flags()
1907                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1908                    {
1909                        this.inner.send_framework_err(
1910                            fidl::encoding::FrameworkErr::UnknownMethod,
1911                            header.tx_id,
1912                            header.ordinal,
1913                            header.dynamic_flags(),
1914                            (bytes, handles),
1915                        )?;
1916                        Ok(DeviceRequest::_UnknownMethod {
1917                            ordinal: header.ordinal,
1918                            control_handle: DeviceControlHandle { inner: this.inner.clone() },
1919                            method_type: fidl::MethodType::TwoWay,
1920                        })
1921                    }
1922                    _ => Err(fidl::Error::UnknownOrdinal {
1923                        ordinal: header.ordinal,
1924                        protocol_name:
1925                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1926                    }),
1927                }))
1928            },
1929        )
1930    }
1931}
1932
1933/// Client is expected to pass the vmo handle to nanohub when issuing a DownloadFirmware request.
1934#[derive(Debug)]
1935pub enum DeviceRequest {
1936    /// Request to sent to nanohub to load the firmware.
1937    DownloadFirmware {
1938        firmware: fidl::Vmo,
1939        offset: u64,
1940        responder: DeviceDownloadFirmwareResponder,
1941    },
1942    /// The name of the firmware binary running on the MCU.
1943    GetFirmwareName { responder: DeviceGetFirmwareNameResponder },
1944    /// The version of the firmware binary running on the MCU.
1945    GetFirmwareVersion { responder: DeviceGetFirmwareVersionResponder },
1946    /// The time since boot recorded by the AP and the MCU.
1947    GetTimeSync { responder: DeviceGetTimeSyncResponder },
1948    /// Set an MCU wake lock request to prevent the MCU from entering a low-power state.
1949    SetWakeLock { value: McuWakeLockValue, responder: DeviceSetWakeLockResponder },
1950    /// Get the current duration of time the MCU will remain awake.
1951    GetWakeUpEventDuration { responder: DeviceGetWakeUpEventDurationResponder },
1952    /// Set a duration of time for the MCU to remain awake.
1953    SetWakeUpEventDuration { duration: i64, responder: DeviceSetWakeUpEventDurationResponder },
1954    /// Initiates a hardware reset.
1955    HardwareReset {
1956        isp_pin_0: PinState,
1957        isp_pin_1: PinState,
1958        isp_pin_2: PinState,
1959        responder: DeviceHardwareResetResponder,
1960    },
1961    /// An interaction was received which does not match any known method.
1962    #[non_exhaustive]
1963    _UnknownMethod {
1964        /// Ordinal of the method that was called.
1965        ordinal: u64,
1966        control_handle: DeviceControlHandle,
1967        method_type: fidl::MethodType,
1968    },
1969}
1970
1971impl DeviceRequest {
1972    #[allow(irrefutable_let_patterns)]
1973    pub fn into_download_firmware(
1974        self,
1975    ) -> Option<(fidl::Vmo, u64, DeviceDownloadFirmwareResponder)> {
1976        if let DeviceRequest::DownloadFirmware { firmware, offset, responder } = self {
1977            Some((firmware, offset, responder))
1978        } else {
1979            None
1980        }
1981    }
1982
1983    #[allow(irrefutable_let_patterns)]
1984    pub fn into_get_firmware_name(self) -> Option<(DeviceGetFirmwareNameResponder)> {
1985        if let DeviceRequest::GetFirmwareName { responder } = self {
1986            Some((responder))
1987        } else {
1988            None
1989        }
1990    }
1991
1992    #[allow(irrefutable_let_patterns)]
1993    pub fn into_get_firmware_version(self) -> Option<(DeviceGetFirmwareVersionResponder)> {
1994        if let DeviceRequest::GetFirmwareVersion { responder } = self {
1995            Some((responder))
1996        } else {
1997            None
1998        }
1999    }
2000
2001    #[allow(irrefutable_let_patterns)]
2002    pub fn into_get_time_sync(self) -> Option<(DeviceGetTimeSyncResponder)> {
2003        if let DeviceRequest::GetTimeSync { responder } = self { Some((responder)) } else { None }
2004    }
2005
2006    #[allow(irrefutable_let_patterns)]
2007    pub fn into_set_wake_lock(self) -> Option<(McuWakeLockValue, DeviceSetWakeLockResponder)> {
2008        if let DeviceRequest::SetWakeLock { value, responder } = self {
2009            Some((value, responder))
2010        } else {
2011            None
2012        }
2013    }
2014
2015    #[allow(irrefutable_let_patterns)]
2016    pub fn into_get_wake_up_event_duration(
2017        self,
2018    ) -> Option<(DeviceGetWakeUpEventDurationResponder)> {
2019        if let DeviceRequest::GetWakeUpEventDuration { responder } = self {
2020            Some((responder))
2021        } else {
2022            None
2023        }
2024    }
2025
2026    #[allow(irrefutable_let_patterns)]
2027    pub fn into_set_wake_up_event_duration(
2028        self,
2029    ) -> Option<(i64, DeviceSetWakeUpEventDurationResponder)> {
2030        if let DeviceRequest::SetWakeUpEventDuration { duration, responder } = self {
2031            Some((duration, responder))
2032        } else {
2033            None
2034        }
2035    }
2036
2037    #[allow(irrefutable_let_patterns)]
2038    pub fn into_hardware_reset(
2039        self,
2040    ) -> Option<(PinState, PinState, PinState, DeviceHardwareResetResponder)> {
2041        if let DeviceRequest::HardwareReset { isp_pin_0, isp_pin_1, isp_pin_2, responder } = self {
2042            Some((isp_pin_0, isp_pin_1, isp_pin_2, responder))
2043        } else {
2044            None
2045        }
2046    }
2047
2048    /// Name of the method defined in FIDL
2049    pub fn method_name(&self) -> &'static str {
2050        match *self {
2051            DeviceRequest::DownloadFirmware { .. } => "download_firmware",
2052            DeviceRequest::GetFirmwareName { .. } => "get_firmware_name",
2053            DeviceRequest::GetFirmwareVersion { .. } => "get_firmware_version",
2054            DeviceRequest::GetTimeSync { .. } => "get_time_sync",
2055            DeviceRequest::SetWakeLock { .. } => "set_wake_lock",
2056            DeviceRequest::GetWakeUpEventDuration { .. } => "get_wake_up_event_duration",
2057            DeviceRequest::SetWakeUpEventDuration { .. } => "set_wake_up_event_duration",
2058            DeviceRequest::HardwareReset { .. } => "hardware_reset",
2059            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2060                "unknown one-way method"
2061            }
2062            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2063                "unknown two-way method"
2064            }
2065        }
2066    }
2067}
2068
2069#[derive(Debug, Clone)]
2070pub struct DeviceControlHandle {
2071    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2072}
2073
2074impl fidl::endpoints::ControlHandle for DeviceControlHandle {
2075    fn shutdown(&self) {
2076        self.inner.shutdown()
2077    }
2078    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2079        self.inner.shutdown_with_epitaph(status)
2080    }
2081
2082    fn is_closed(&self) -> bool {
2083        self.inner.channel().is_closed()
2084    }
2085    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2086        self.inner.channel().on_closed()
2087    }
2088
2089    #[cfg(target_os = "fuchsia")]
2090    fn signal_peer(
2091        &self,
2092        clear_mask: zx::Signals,
2093        set_mask: zx::Signals,
2094    ) -> Result<(), zx_status::Status> {
2095        use fidl::Peered;
2096        self.inner.channel().signal_peer(clear_mask, set_mask)
2097    }
2098}
2099
2100impl DeviceControlHandle {}
2101
2102#[must_use = "FIDL methods require a response to be sent"]
2103#[derive(Debug)]
2104pub struct DeviceDownloadFirmwareResponder {
2105    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2106    tx_id: u32,
2107}
2108
2109/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2110/// if the responder is dropped without sending a response, so that the client
2111/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2112impl std::ops::Drop for DeviceDownloadFirmwareResponder {
2113    fn drop(&mut self) {
2114        self.control_handle.shutdown();
2115        // Safety: drops once, never accessed again
2116        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2117    }
2118}
2119
2120impl fidl::endpoints::Responder for DeviceDownloadFirmwareResponder {
2121    type ControlHandle = DeviceControlHandle;
2122
2123    fn control_handle(&self) -> &DeviceControlHandle {
2124        &self.control_handle
2125    }
2126
2127    fn drop_without_shutdown(mut self) {
2128        // Safety: drops once, never accessed again due to mem::forget
2129        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2130        // Prevent Drop from running (which would shut down the channel)
2131        std::mem::forget(self);
2132    }
2133}
2134
2135impl DeviceDownloadFirmwareResponder {
2136    /// Sends a response to the FIDL transaction.
2137    ///
2138    /// Sets the channel to shutdown if an error occurs.
2139    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2140        let _result = self.send_raw(result);
2141        if _result.is_err() {
2142            self.control_handle.shutdown();
2143        }
2144        self.drop_without_shutdown();
2145        _result
2146    }
2147
2148    /// Similar to "send" but does not shutdown the channel if an error occurs.
2149    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2150        let _result = self.send_raw(result);
2151        self.drop_without_shutdown();
2152        _result
2153    }
2154
2155    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2156        self.control_handle
2157            .inner
2158            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2159                result,
2160                self.tx_id,
2161                0x7bba8137e24661e5,
2162                fidl::encoding::DynamicFlags::empty(),
2163            )
2164    }
2165}
2166
2167#[must_use = "FIDL methods require a response to be sent"]
2168#[derive(Debug)]
2169pub struct DeviceGetFirmwareNameResponder {
2170    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2171    tx_id: u32,
2172}
2173
2174/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2175/// if the responder is dropped without sending a response, so that the client
2176/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2177impl std::ops::Drop for DeviceGetFirmwareNameResponder {
2178    fn drop(&mut self) {
2179        self.control_handle.shutdown();
2180        // Safety: drops once, never accessed again
2181        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2182    }
2183}
2184
2185impl fidl::endpoints::Responder for DeviceGetFirmwareNameResponder {
2186    type ControlHandle = DeviceControlHandle;
2187
2188    fn control_handle(&self) -> &DeviceControlHandle {
2189        &self.control_handle
2190    }
2191
2192    fn drop_without_shutdown(mut self) {
2193        // Safety: drops once, never accessed again due to mem::forget
2194        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2195        // Prevent Drop from running (which would shut down the channel)
2196        std::mem::forget(self);
2197    }
2198}
2199
2200impl DeviceGetFirmwareNameResponder {
2201    /// Sends a response to the FIDL transaction.
2202    ///
2203    /// Sets the channel to shutdown if an error occurs.
2204    pub fn send(self, mut firmware_name: &str) -> Result<(), fidl::Error> {
2205        let _result = self.send_raw(firmware_name);
2206        if _result.is_err() {
2207            self.control_handle.shutdown();
2208        }
2209        self.drop_without_shutdown();
2210        _result
2211    }
2212
2213    /// Similar to "send" but does not shutdown the channel if an error occurs.
2214    pub fn send_no_shutdown_on_err(self, mut firmware_name: &str) -> Result<(), fidl::Error> {
2215        let _result = self.send_raw(firmware_name);
2216        self.drop_without_shutdown();
2217        _result
2218    }
2219
2220    fn send_raw(&self, mut firmware_name: &str) -> Result<(), fidl::Error> {
2221        self.control_handle.inner.send::<DeviceGetFirmwareNameResponse>(
2222            (firmware_name,),
2223            self.tx_id,
2224            0x1649434b5e5bcb8d,
2225            fidl::encoding::DynamicFlags::empty(),
2226        )
2227    }
2228}
2229
2230#[must_use = "FIDL methods require a response to be sent"]
2231#[derive(Debug)]
2232pub struct DeviceGetFirmwareVersionResponder {
2233    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2234    tx_id: u32,
2235}
2236
2237/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2238/// if the responder is dropped without sending a response, so that the client
2239/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2240impl std::ops::Drop for DeviceGetFirmwareVersionResponder {
2241    fn drop(&mut self) {
2242        self.control_handle.shutdown();
2243        // Safety: drops once, never accessed again
2244        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2245    }
2246}
2247
2248impl fidl::endpoints::Responder for DeviceGetFirmwareVersionResponder {
2249    type ControlHandle = DeviceControlHandle;
2250
2251    fn control_handle(&self) -> &DeviceControlHandle {
2252        &self.control_handle
2253    }
2254
2255    fn drop_without_shutdown(mut self) {
2256        // Safety: drops once, never accessed again due to mem::forget
2257        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2258        // Prevent Drop from running (which would shut down the channel)
2259        std::mem::forget(self);
2260    }
2261}
2262
2263impl DeviceGetFirmwareVersionResponder {
2264    /// Sends a response to the FIDL transaction.
2265    ///
2266    /// Sets the channel to shutdown if an error occurs.
2267    pub fn send(self, mut version_info: &McuVersionInfo) -> Result<(), fidl::Error> {
2268        let _result = self.send_raw(version_info);
2269        if _result.is_err() {
2270            self.control_handle.shutdown();
2271        }
2272        self.drop_without_shutdown();
2273        _result
2274    }
2275
2276    /// Similar to "send" but does not shutdown the channel if an error occurs.
2277    pub fn send_no_shutdown_on_err(
2278        self,
2279        mut version_info: &McuVersionInfo,
2280    ) -> Result<(), fidl::Error> {
2281        let _result = self.send_raw(version_info);
2282        self.drop_without_shutdown();
2283        _result
2284    }
2285
2286    fn send_raw(&self, mut version_info: &McuVersionInfo) -> Result<(), fidl::Error> {
2287        self.control_handle.inner.send::<DeviceGetFirmwareVersionResponse>(
2288            (version_info,),
2289            self.tx_id,
2290            0x4f0599abcc95736b,
2291            fidl::encoding::DynamicFlags::empty(),
2292        )
2293    }
2294}
2295
2296#[must_use = "FIDL methods require a response to be sent"]
2297#[derive(Debug)]
2298pub struct DeviceGetTimeSyncResponder {
2299    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2300    tx_id: u32,
2301}
2302
2303/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2304/// if the responder is dropped without sending a response, so that the client
2305/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2306impl std::ops::Drop for DeviceGetTimeSyncResponder {
2307    fn drop(&mut self) {
2308        self.control_handle.shutdown();
2309        // Safety: drops once, never accessed again
2310        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2311    }
2312}
2313
2314impl fidl::endpoints::Responder for DeviceGetTimeSyncResponder {
2315    type ControlHandle = DeviceControlHandle;
2316
2317    fn control_handle(&self) -> &DeviceControlHandle {
2318        &self.control_handle
2319    }
2320
2321    fn drop_without_shutdown(mut self) {
2322        // Safety: drops once, never accessed again due to mem::forget
2323        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2324        // Prevent Drop from running (which would shut down the channel)
2325        std::mem::forget(self);
2326    }
2327}
2328
2329impl DeviceGetTimeSyncResponder {
2330    /// Sends a response to the FIDL transaction.
2331    ///
2332    /// Sets the channel to shutdown if an error occurs.
2333    pub fn send(self, mut result: Result<&McuTimeSyncInfo, i32>) -> Result<(), fidl::Error> {
2334        let _result = self.send_raw(result);
2335        if _result.is_err() {
2336            self.control_handle.shutdown();
2337        }
2338        self.drop_without_shutdown();
2339        _result
2340    }
2341
2342    /// Similar to "send" but does not shutdown the channel if an error occurs.
2343    pub fn send_no_shutdown_on_err(
2344        self,
2345        mut result: Result<&McuTimeSyncInfo, i32>,
2346    ) -> Result<(), fidl::Error> {
2347        let _result = self.send_raw(result);
2348        self.drop_without_shutdown();
2349        _result
2350    }
2351
2352    fn send_raw(&self, mut result: Result<&McuTimeSyncInfo, i32>) -> Result<(), fidl::Error> {
2353        self.control_handle.inner.send::<fidl::encoding::ResultType<McuTimeSyncInfo, i32>>(
2354            result,
2355            self.tx_id,
2356            0x4406991222e3975d,
2357            fidl::encoding::DynamicFlags::empty(),
2358        )
2359    }
2360}
2361
2362#[must_use = "FIDL methods require a response to be sent"]
2363#[derive(Debug)]
2364pub struct DeviceSetWakeLockResponder {
2365    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2366    tx_id: u32,
2367}
2368
2369/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2370/// if the responder is dropped without sending a response, so that the client
2371/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2372impl std::ops::Drop for DeviceSetWakeLockResponder {
2373    fn drop(&mut self) {
2374        self.control_handle.shutdown();
2375        // Safety: drops once, never accessed again
2376        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2377    }
2378}
2379
2380impl fidl::endpoints::Responder for DeviceSetWakeLockResponder {
2381    type ControlHandle = DeviceControlHandle;
2382
2383    fn control_handle(&self) -> &DeviceControlHandle {
2384        &self.control_handle
2385    }
2386
2387    fn drop_without_shutdown(mut self) {
2388        // Safety: drops once, never accessed again due to mem::forget
2389        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2390        // Prevent Drop from running (which would shut down the channel)
2391        std::mem::forget(self);
2392    }
2393}
2394
2395impl DeviceSetWakeLockResponder {
2396    /// Sends a response to the FIDL transaction.
2397    ///
2398    /// Sets the channel to shutdown if an error occurs.
2399    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2400        let _result = self.send_raw(result);
2401        if _result.is_err() {
2402            self.control_handle.shutdown();
2403        }
2404        self.drop_without_shutdown();
2405        _result
2406    }
2407
2408    /// Similar to "send" but does not shutdown the channel if an error occurs.
2409    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2410        let _result = self.send_raw(result);
2411        self.drop_without_shutdown();
2412        _result
2413    }
2414
2415    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2416        self.control_handle
2417            .inner
2418            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2419                result,
2420                self.tx_id,
2421                0x9f83f614affa1dc,
2422                fidl::encoding::DynamicFlags::empty(),
2423            )
2424    }
2425}
2426
2427#[must_use = "FIDL methods require a response to be sent"]
2428#[derive(Debug)]
2429pub struct DeviceGetWakeUpEventDurationResponder {
2430    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2431    tx_id: u32,
2432}
2433
2434/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2435/// if the responder is dropped without sending a response, so that the client
2436/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2437impl std::ops::Drop for DeviceGetWakeUpEventDurationResponder {
2438    fn drop(&mut self) {
2439        self.control_handle.shutdown();
2440        // Safety: drops once, never accessed again
2441        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2442    }
2443}
2444
2445impl fidl::endpoints::Responder for DeviceGetWakeUpEventDurationResponder {
2446    type ControlHandle = DeviceControlHandle;
2447
2448    fn control_handle(&self) -> &DeviceControlHandle {
2449        &self.control_handle
2450    }
2451
2452    fn drop_without_shutdown(mut self) {
2453        // Safety: drops once, never accessed again due to mem::forget
2454        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2455        // Prevent Drop from running (which would shut down the channel)
2456        std::mem::forget(self);
2457    }
2458}
2459
2460impl DeviceGetWakeUpEventDurationResponder {
2461    /// Sends a response to the FIDL transaction.
2462    ///
2463    /// Sets the channel to shutdown if an error occurs.
2464    pub fn send(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
2465        let _result = self.send_raw(result);
2466        if _result.is_err() {
2467            self.control_handle.shutdown();
2468        }
2469        self.drop_without_shutdown();
2470        _result
2471    }
2472
2473    /// Similar to "send" but does not shutdown the channel if an error occurs.
2474    pub fn send_no_shutdown_on_err(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
2475        let _result = self.send_raw(result);
2476        self.drop_without_shutdown();
2477        _result
2478    }
2479
2480    fn send_raw(&self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
2481        self.control_handle.inner.send::<fidl::encoding::ResultType<
2482            DeviceGetWakeUpEventDurationResponse,
2483            i32,
2484        >>(
2485            result.map(|duration| (duration,)),
2486            self.tx_id,
2487            0x45c79749f65e7176,
2488            fidl::encoding::DynamicFlags::empty(),
2489        )
2490    }
2491}
2492
2493#[must_use = "FIDL methods require a response to be sent"]
2494#[derive(Debug)]
2495pub struct DeviceSetWakeUpEventDurationResponder {
2496    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2497    tx_id: u32,
2498}
2499
2500/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2501/// if the responder is dropped without sending a response, so that the client
2502/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2503impl std::ops::Drop for DeviceSetWakeUpEventDurationResponder {
2504    fn drop(&mut self) {
2505        self.control_handle.shutdown();
2506        // Safety: drops once, never accessed again
2507        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2508    }
2509}
2510
2511impl fidl::endpoints::Responder for DeviceSetWakeUpEventDurationResponder {
2512    type ControlHandle = DeviceControlHandle;
2513
2514    fn control_handle(&self) -> &DeviceControlHandle {
2515        &self.control_handle
2516    }
2517
2518    fn drop_without_shutdown(mut self) {
2519        // Safety: drops once, never accessed again due to mem::forget
2520        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2521        // Prevent Drop from running (which would shut down the channel)
2522        std::mem::forget(self);
2523    }
2524}
2525
2526impl DeviceSetWakeUpEventDurationResponder {
2527    /// Sends a response to the FIDL transaction.
2528    ///
2529    /// Sets the channel to shutdown if an error occurs.
2530    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2531        let _result = self.send_raw(result);
2532        if _result.is_err() {
2533            self.control_handle.shutdown();
2534        }
2535        self.drop_without_shutdown();
2536        _result
2537    }
2538
2539    /// Similar to "send" but does not shutdown the channel if an error occurs.
2540    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2541        let _result = self.send_raw(result);
2542        self.drop_without_shutdown();
2543        _result
2544    }
2545
2546    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2547        self.control_handle
2548            .inner
2549            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2550                result,
2551                self.tx_id,
2552                0x1fa1771ffa5f570,
2553                fidl::encoding::DynamicFlags::empty(),
2554            )
2555    }
2556}
2557
2558#[must_use = "FIDL methods require a response to be sent"]
2559#[derive(Debug)]
2560pub struct DeviceHardwareResetResponder {
2561    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2562    tx_id: u32,
2563}
2564
2565/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2566/// if the responder is dropped without sending a response, so that the client
2567/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2568impl std::ops::Drop for DeviceHardwareResetResponder {
2569    fn drop(&mut self) {
2570        self.control_handle.shutdown();
2571        // Safety: drops once, never accessed again
2572        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2573    }
2574}
2575
2576impl fidl::endpoints::Responder for DeviceHardwareResetResponder {
2577    type ControlHandle = DeviceControlHandle;
2578
2579    fn control_handle(&self) -> &DeviceControlHandle {
2580        &self.control_handle
2581    }
2582
2583    fn drop_without_shutdown(mut self) {
2584        // Safety: drops once, never accessed again due to mem::forget
2585        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2586        // Prevent Drop from running (which would shut down the channel)
2587        std::mem::forget(self);
2588    }
2589}
2590
2591impl DeviceHardwareResetResponder {
2592    /// Sends a response to the FIDL transaction.
2593    ///
2594    /// Sets the channel to shutdown if an error occurs.
2595    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2596        let _result = self.send_raw(result);
2597        if _result.is_err() {
2598            self.control_handle.shutdown();
2599        }
2600        self.drop_without_shutdown();
2601        _result
2602    }
2603
2604    /// Similar to "send" but does not shutdown the channel if an error occurs.
2605    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2606        let _result = self.send_raw(result);
2607        self.drop_without_shutdown();
2608        _result
2609    }
2610
2611    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2612        self.control_handle
2613            .inner
2614            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2615                result,
2616                self.tx_id,
2617                0x78e3d2ded2f929f,
2618                fidl::encoding::DynamicFlags::empty(),
2619            )
2620    }
2621}
2622
2623#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2624pub struct DisplayDeviceMarker;
2625
2626impl fidl::endpoints::ProtocolMarker for DisplayDeviceMarker {
2627    type Proxy = DisplayDeviceProxy;
2628    type RequestStream = DisplayDeviceRequestStream;
2629    #[cfg(target_os = "fuchsia")]
2630    type SynchronousProxy = DisplayDeviceSynchronousProxy;
2631
2632    const DEBUG_NAME: &'static str = "fuchsia.hardware.google.nanohub.DisplayDevice";
2633}
2634impl fidl::endpoints::DiscoverableProtocolMarker for DisplayDeviceMarker {}
2635pub type DisplayDeviceGetDisplayStateResult = Result<DisplayState, i32>;
2636pub type DisplayDeviceGetDisplayInfoResult = Result<DisplaySyncInfo, i32>;
2637pub type DisplayDeviceGetDisplaySelectResult = Result<DisplayDeviceGetDisplaySelectResponse, i32>;
2638pub type DisplayDeviceSetDisplaySelectResult = Result<(), i32>;
2639
2640pub trait DisplayDeviceProxyInterface: Send + Sync {
2641    type GetDisplayStateResponseFut: std::future::Future<Output = Result<DisplayDeviceGetDisplayStateResult, fidl::Error>>
2642        + Send;
2643    fn r#get_display_state(&self) -> Self::GetDisplayStateResponseFut;
2644    type GetDisplayInfoResponseFut: std::future::Future<Output = Result<DisplayDeviceGetDisplayInfoResult, fidl::Error>>
2645        + Send;
2646    fn r#get_display_info(&self) -> Self::GetDisplayInfoResponseFut;
2647    type GetDisplaySelectResponseFut: std::future::Future<Output = Result<DisplayDeviceGetDisplaySelectResult, fidl::Error>>
2648        + Send;
2649    fn r#get_display_select(&self) -> Self::GetDisplaySelectResponseFut;
2650    type SetDisplaySelectResponseFut: std::future::Future<Output = Result<DisplayDeviceSetDisplaySelectResult, fidl::Error>>
2651        + Send;
2652    fn r#set_display_select(
2653        &self,
2654        payload: &DisplayDeviceSetDisplaySelectRequest,
2655    ) -> Self::SetDisplaySelectResponseFut;
2656}
2657#[derive(Debug)]
2658#[cfg(target_os = "fuchsia")]
2659pub struct DisplayDeviceSynchronousProxy {
2660    client: fidl::client::sync::Client,
2661}
2662
2663#[cfg(target_os = "fuchsia")]
2664impl fidl::endpoints::SynchronousProxy for DisplayDeviceSynchronousProxy {
2665    type Proxy = DisplayDeviceProxy;
2666    type Protocol = DisplayDeviceMarker;
2667
2668    fn from_channel(inner: fidl::Channel) -> Self {
2669        Self::new(inner)
2670    }
2671
2672    fn into_channel(self) -> fidl::Channel {
2673        self.client.into_channel()
2674    }
2675
2676    fn as_channel(&self) -> &fidl::Channel {
2677        self.client.as_channel()
2678    }
2679}
2680
2681#[cfg(target_os = "fuchsia")]
2682impl DisplayDeviceSynchronousProxy {
2683    pub fn new(channel: fidl::Channel) -> Self {
2684        let protocol_name = <DisplayDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2685        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2686    }
2687
2688    pub fn into_channel(self) -> fidl::Channel {
2689        self.client.into_channel()
2690    }
2691
2692    /// Waits until an event arrives and returns it. It is safe for other
2693    /// threads to make concurrent requests while waiting for an event.
2694    pub fn wait_for_event(
2695        &self,
2696        deadline: zx::MonotonicInstant,
2697    ) -> Result<DisplayDeviceEvent, fidl::Error> {
2698        DisplayDeviceEvent::decode(self.client.wait_for_event(deadline)?)
2699    }
2700
2701    /// Gets the current state of the display.
2702    pub fn r#get_display_state(
2703        &self,
2704        ___deadline: zx::MonotonicInstant,
2705    ) -> Result<DisplayDeviceGetDisplayStateResult, fidl::Error> {
2706        let _response = self.client.send_query::<
2707            fidl::encoding::EmptyPayload,
2708            fidl::encoding::ResultType<DisplayState, i32>,
2709        >(
2710            (),
2711            0x1648924f6e003444,
2712            fidl::encoding::DynamicFlags::empty(),
2713            ___deadline,
2714        )?;
2715        Ok(_response.map(|x| x))
2716    }
2717
2718    /// Gets synchronization information for the display. This can include
2719    /// the display's mode, panel mode, and brightness levels.
2720    pub fn r#get_display_info(
2721        &self,
2722        ___deadline: zx::MonotonicInstant,
2723    ) -> Result<DisplayDeviceGetDisplayInfoResult, fidl::Error> {
2724        let _response = self.client.send_query::<
2725            fidl::encoding::EmptyPayload,
2726            fidl::encoding::ResultType<DisplaySyncInfo, i32>,
2727        >(
2728            (),
2729            0x311c8e4cb6b1b4d1,
2730            fidl::encoding::DynamicFlags::empty(),
2731            ___deadline,
2732        )?;
2733        Ok(_response.map(|x| x))
2734    }
2735
2736    /// Gets the current display owner, which is either the AP (Application
2737    /// Processor) or the MCU (Microcontroller Unit).
2738    pub fn r#get_display_select(
2739        &self,
2740        ___deadline: zx::MonotonicInstant,
2741    ) -> Result<DisplayDeviceGetDisplaySelectResult, fidl::Error> {
2742        let _response = self.client.send_query::<
2743            fidl::encoding::EmptyPayload,
2744            fidl::encoding::ResultType<DisplayDeviceGetDisplaySelectResponse, i32>,
2745        >(
2746            (),
2747            0x6191c86cffd6323,
2748            fidl::encoding::DynamicFlags::empty(),
2749            ___deadline,
2750        )?;
2751        Ok(_response.map(|x| x))
2752    }
2753
2754    /// Sets the display owner to be either the AP (Application Processor) or
2755    /// the MCU (Microcontroller Unit).
2756    pub fn r#set_display_select(
2757        &self,
2758        mut payload: &DisplayDeviceSetDisplaySelectRequest,
2759        ___deadline: zx::MonotonicInstant,
2760    ) -> Result<DisplayDeviceSetDisplaySelectResult, fidl::Error> {
2761        let _response = self.client.send_query::<
2762            DisplayDeviceSetDisplaySelectRequest,
2763            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2764        >(
2765            payload,
2766            0x2b07f6ba12e7a412,
2767            fidl::encoding::DynamicFlags::empty(),
2768            ___deadline,
2769        )?;
2770        Ok(_response.map(|x| x))
2771    }
2772}
2773
2774#[cfg(target_os = "fuchsia")]
2775impl From<DisplayDeviceSynchronousProxy> for zx::Handle {
2776    fn from(value: DisplayDeviceSynchronousProxy) -> Self {
2777        value.into_channel().into()
2778    }
2779}
2780
2781#[cfg(target_os = "fuchsia")]
2782impl From<fidl::Channel> for DisplayDeviceSynchronousProxy {
2783    fn from(value: fidl::Channel) -> Self {
2784        Self::new(value)
2785    }
2786}
2787
2788#[cfg(target_os = "fuchsia")]
2789impl fidl::endpoints::FromClient for DisplayDeviceSynchronousProxy {
2790    type Protocol = DisplayDeviceMarker;
2791
2792    fn from_client(value: fidl::endpoints::ClientEnd<DisplayDeviceMarker>) -> Self {
2793        Self::new(value.into_channel())
2794    }
2795}
2796
2797#[derive(Debug, Clone)]
2798pub struct DisplayDeviceProxy {
2799    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2800}
2801
2802impl fidl::endpoints::Proxy for DisplayDeviceProxy {
2803    type Protocol = DisplayDeviceMarker;
2804
2805    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2806        Self::new(inner)
2807    }
2808
2809    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2810        self.client.into_channel().map_err(|client| Self { client })
2811    }
2812
2813    fn as_channel(&self) -> &::fidl::AsyncChannel {
2814        self.client.as_channel()
2815    }
2816}
2817
2818impl DisplayDeviceProxy {
2819    /// Create a new Proxy for fuchsia.hardware.google.nanohub/DisplayDevice.
2820    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2821        let protocol_name = <DisplayDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2822        Self { client: fidl::client::Client::new(channel, protocol_name) }
2823    }
2824
2825    /// Get a Stream of events from the remote end of the protocol.
2826    ///
2827    /// # Panics
2828    ///
2829    /// Panics if the event stream was already taken.
2830    pub fn take_event_stream(&self) -> DisplayDeviceEventStream {
2831        DisplayDeviceEventStream { event_receiver: self.client.take_event_receiver() }
2832    }
2833
2834    /// Gets the current state of the display.
2835    pub fn r#get_display_state(
2836        &self,
2837    ) -> fidl::client::QueryResponseFut<
2838        DisplayDeviceGetDisplayStateResult,
2839        fidl::encoding::DefaultFuchsiaResourceDialect,
2840    > {
2841        DisplayDeviceProxyInterface::r#get_display_state(self)
2842    }
2843
2844    /// Gets synchronization information for the display. This can include
2845    /// the display's mode, panel mode, and brightness levels.
2846    pub fn r#get_display_info(
2847        &self,
2848    ) -> fidl::client::QueryResponseFut<
2849        DisplayDeviceGetDisplayInfoResult,
2850        fidl::encoding::DefaultFuchsiaResourceDialect,
2851    > {
2852        DisplayDeviceProxyInterface::r#get_display_info(self)
2853    }
2854
2855    /// Gets the current display owner, which is either the AP (Application
2856    /// Processor) or the MCU (Microcontroller Unit).
2857    pub fn r#get_display_select(
2858        &self,
2859    ) -> fidl::client::QueryResponseFut<
2860        DisplayDeviceGetDisplaySelectResult,
2861        fidl::encoding::DefaultFuchsiaResourceDialect,
2862    > {
2863        DisplayDeviceProxyInterface::r#get_display_select(self)
2864    }
2865
2866    /// Sets the display owner to be either the AP (Application Processor) or
2867    /// the MCU (Microcontroller Unit).
2868    pub fn r#set_display_select(
2869        &self,
2870        mut payload: &DisplayDeviceSetDisplaySelectRequest,
2871    ) -> fidl::client::QueryResponseFut<
2872        DisplayDeviceSetDisplaySelectResult,
2873        fidl::encoding::DefaultFuchsiaResourceDialect,
2874    > {
2875        DisplayDeviceProxyInterface::r#set_display_select(self, payload)
2876    }
2877}
2878
2879impl DisplayDeviceProxyInterface for DisplayDeviceProxy {
2880    type GetDisplayStateResponseFut = fidl::client::QueryResponseFut<
2881        DisplayDeviceGetDisplayStateResult,
2882        fidl::encoding::DefaultFuchsiaResourceDialect,
2883    >;
2884    fn r#get_display_state(&self) -> Self::GetDisplayStateResponseFut {
2885        fn _decode(
2886            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2887        ) -> Result<DisplayDeviceGetDisplayStateResult, fidl::Error> {
2888            let _response = fidl::client::decode_transaction_body::<
2889                fidl::encoding::ResultType<DisplayState, i32>,
2890                fidl::encoding::DefaultFuchsiaResourceDialect,
2891                0x1648924f6e003444,
2892            >(_buf?)?;
2893            Ok(_response.map(|x| x))
2894        }
2895        self.client.send_query_and_decode::<
2896            fidl::encoding::EmptyPayload,
2897            DisplayDeviceGetDisplayStateResult,
2898        >(
2899            (),
2900            0x1648924f6e003444,
2901            fidl::encoding::DynamicFlags::empty(),
2902            _decode,
2903        )
2904    }
2905
2906    type GetDisplayInfoResponseFut = fidl::client::QueryResponseFut<
2907        DisplayDeviceGetDisplayInfoResult,
2908        fidl::encoding::DefaultFuchsiaResourceDialect,
2909    >;
2910    fn r#get_display_info(&self) -> Self::GetDisplayInfoResponseFut {
2911        fn _decode(
2912            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2913        ) -> Result<DisplayDeviceGetDisplayInfoResult, fidl::Error> {
2914            let _response = fidl::client::decode_transaction_body::<
2915                fidl::encoding::ResultType<DisplaySyncInfo, i32>,
2916                fidl::encoding::DefaultFuchsiaResourceDialect,
2917                0x311c8e4cb6b1b4d1,
2918            >(_buf?)?;
2919            Ok(_response.map(|x| x))
2920        }
2921        self.client.send_query_and_decode::<
2922            fidl::encoding::EmptyPayload,
2923            DisplayDeviceGetDisplayInfoResult,
2924        >(
2925            (),
2926            0x311c8e4cb6b1b4d1,
2927            fidl::encoding::DynamicFlags::empty(),
2928            _decode,
2929        )
2930    }
2931
2932    type GetDisplaySelectResponseFut = fidl::client::QueryResponseFut<
2933        DisplayDeviceGetDisplaySelectResult,
2934        fidl::encoding::DefaultFuchsiaResourceDialect,
2935    >;
2936    fn r#get_display_select(&self) -> Self::GetDisplaySelectResponseFut {
2937        fn _decode(
2938            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2939        ) -> Result<DisplayDeviceGetDisplaySelectResult, fidl::Error> {
2940            let _response = fidl::client::decode_transaction_body::<
2941                fidl::encoding::ResultType<DisplayDeviceGetDisplaySelectResponse, i32>,
2942                fidl::encoding::DefaultFuchsiaResourceDialect,
2943                0x6191c86cffd6323,
2944            >(_buf?)?;
2945            Ok(_response.map(|x| x))
2946        }
2947        self.client.send_query_and_decode::<
2948            fidl::encoding::EmptyPayload,
2949            DisplayDeviceGetDisplaySelectResult,
2950        >(
2951            (),
2952            0x6191c86cffd6323,
2953            fidl::encoding::DynamicFlags::empty(),
2954            _decode,
2955        )
2956    }
2957
2958    type SetDisplaySelectResponseFut = fidl::client::QueryResponseFut<
2959        DisplayDeviceSetDisplaySelectResult,
2960        fidl::encoding::DefaultFuchsiaResourceDialect,
2961    >;
2962    fn r#set_display_select(
2963        &self,
2964        mut payload: &DisplayDeviceSetDisplaySelectRequest,
2965    ) -> Self::SetDisplaySelectResponseFut {
2966        fn _decode(
2967            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2968        ) -> Result<DisplayDeviceSetDisplaySelectResult, fidl::Error> {
2969            let _response = fidl::client::decode_transaction_body::<
2970                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2971                fidl::encoding::DefaultFuchsiaResourceDialect,
2972                0x2b07f6ba12e7a412,
2973            >(_buf?)?;
2974            Ok(_response.map(|x| x))
2975        }
2976        self.client.send_query_and_decode::<
2977            DisplayDeviceSetDisplaySelectRequest,
2978            DisplayDeviceSetDisplaySelectResult,
2979        >(
2980            payload,
2981            0x2b07f6ba12e7a412,
2982            fidl::encoding::DynamicFlags::empty(),
2983            _decode,
2984        )
2985    }
2986}
2987
2988pub struct DisplayDeviceEventStream {
2989    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2990}
2991
2992impl std::marker::Unpin for DisplayDeviceEventStream {}
2993
2994impl futures::stream::FusedStream for DisplayDeviceEventStream {
2995    fn is_terminated(&self) -> bool {
2996        self.event_receiver.is_terminated()
2997    }
2998}
2999
3000impl futures::Stream for DisplayDeviceEventStream {
3001    type Item = Result<DisplayDeviceEvent, fidl::Error>;
3002
3003    fn poll_next(
3004        mut self: std::pin::Pin<&mut Self>,
3005        cx: &mut std::task::Context<'_>,
3006    ) -> std::task::Poll<Option<Self::Item>> {
3007        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3008            &mut self.event_receiver,
3009            cx
3010        )?) {
3011            Some(buf) => std::task::Poll::Ready(Some(DisplayDeviceEvent::decode(buf))),
3012            None => std::task::Poll::Ready(None),
3013        }
3014    }
3015}
3016
3017#[derive(Debug)]
3018pub enum DisplayDeviceEvent {}
3019
3020impl DisplayDeviceEvent {
3021    /// Decodes a message buffer as a [`DisplayDeviceEvent`].
3022    fn decode(
3023        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3024    ) -> Result<DisplayDeviceEvent, fidl::Error> {
3025        let (bytes, _handles) = buf.split_mut();
3026        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3027        debug_assert_eq!(tx_header.tx_id, 0);
3028        match tx_header.ordinal {
3029            _ => Err(fidl::Error::UnknownOrdinal {
3030                ordinal: tx_header.ordinal,
3031                protocol_name: <DisplayDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3032            }),
3033        }
3034    }
3035}
3036
3037/// A Stream of incoming requests for fuchsia.hardware.google.nanohub/DisplayDevice.
3038pub struct DisplayDeviceRequestStream {
3039    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3040    is_terminated: bool,
3041}
3042
3043impl std::marker::Unpin for DisplayDeviceRequestStream {}
3044
3045impl futures::stream::FusedStream for DisplayDeviceRequestStream {
3046    fn is_terminated(&self) -> bool {
3047        self.is_terminated
3048    }
3049}
3050
3051impl fidl::endpoints::RequestStream for DisplayDeviceRequestStream {
3052    type Protocol = DisplayDeviceMarker;
3053    type ControlHandle = DisplayDeviceControlHandle;
3054
3055    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3056        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3057    }
3058
3059    fn control_handle(&self) -> Self::ControlHandle {
3060        DisplayDeviceControlHandle { inner: self.inner.clone() }
3061    }
3062
3063    fn into_inner(
3064        self,
3065    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3066    {
3067        (self.inner, self.is_terminated)
3068    }
3069
3070    fn from_inner(
3071        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3072        is_terminated: bool,
3073    ) -> Self {
3074        Self { inner, is_terminated }
3075    }
3076}
3077
3078impl futures::Stream for DisplayDeviceRequestStream {
3079    type Item = Result<DisplayDeviceRequest, fidl::Error>;
3080
3081    fn poll_next(
3082        mut self: std::pin::Pin<&mut Self>,
3083        cx: &mut std::task::Context<'_>,
3084    ) -> std::task::Poll<Option<Self::Item>> {
3085        let this = &mut *self;
3086        if this.inner.check_shutdown(cx) {
3087            this.is_terminated = true;
3088            return std::task::Poll::Ready(None);
3089        }
3090        if this.is_terminated {
3091            panic!("polled DisplayDeviceRequestStream after completion");
3092        }
3093        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3094            |bytes, handles| {
3095                match this.inner.channel().read_etc(cx, bytes, handles) {
3096                    std::task::Poll::Ready(Ok(())) => {}
3097                    std::task::Poll::Pending => return std::task::Poll::Pending,
3098                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3099                        this.is_terminated = true;
3100                        return std::task::Poll::Ready(None);
3101                    }
3102                    std::task::Poll::Ready(Err(e)) => {
3103                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3104                            e.into(),
3105                        ))));
3106                    }
3107                }
3108
3109                // A message has been received from the channel
3110                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3111
3112                std::task::Poll::Ready(Some(match header.ordinal {
3113                    0x1648924f6e003444 => {
3114                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3115                        let mut req = fidl::new_empty!(
3116                            fidl::encoding::EmptyPayload,
3117                            fidl::encoding::DefaultFuchsiaResourceDialect
3118                        );
3119                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3120                        let control_handle =
3121                            DisplayDeviceControlHandle { inner: this.inner.clone() };
3122                        Ok(DisplayDeviceRequest::GetDisplayState {
3123                            responder: DisplayDeviceGetDisplayStateResponder {
3124                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3125                                tx_id: header.tx_id,
3126                            },
3127                        })
3128                    }
3129                    0x311c8e4cb6b1b4d1 => {
3130                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3131                        let mut req = fidl::new_empty!(
3132                            fidl::encoding::EmptyPayload,
3133                            fidl::encoding::DefaultFuchsiaResourceDialect
3134                        );
3135                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3136                        let control_handle =
3137                            DisplayDeviceControlHandle { inner: this.inner.clone() };
3138                        Ok(DisplayDeviceRequest::GetDisplayInfo {
3139                            responder: DisplayDeviceGetDisplayInfoResponder {
3140                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3141                                tx_id: header.tx_id,
3142                            },
3143                        })
3144                    }
3145                    0x6191c86cffd6323 => {
3146                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3147                        let mut req = fidl::new_empty!(
3148                            fidl::encoding::EmptyPayload,
3149                            fidl::encoding::DefaultFuchsiaResourceDialect
3150                        );
3151                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3152                        let control_handle =
3153                            DisplayDeviceControlHandle { inner: this.inner.clone() };
3154                        Ok(DisplayDeviceRequest::GetDisplaySelect {
3155                            responder: DisplayDeviceGetDisplaySelectResponder {
3156                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3157                                tx_id: header.tx_id,
3158                            },
3159                        })
3160                    }
3161                    0x2b07f6ba12e7a412 => {
3162                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3163                        let mut req = fidl::new_empty!(
3164                            DisplayDeviceSetDisplaySelectRequest,
3165                            fidl::encoding::DefaultFuchsiaResourceDialect
3166                        );
3167                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DisplayDeviceSetDisplaySelectRequest>(&header, _body_bytes, handles, &mut req)?;
3168                        let control_handle =
3169                            DisplayDeviceControlHandle { inner: this.inner.clone() };
3170                        Ok(DisplayDeviceRequest::SetDisplaySelect {
3171                            payload: req,
3172                            responder: DisplayDeviceSetDisplaySelectResponder {
3173                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3174                                tx_id: header.tx_id,
3175                            },
3176                        })
3177                    }
3178                    _ => Err(fidl::Error::UnknownOrdinal {
3179                        ordinal: header.ordinal,
3180                        protocol_name:
3181                            <DisplayDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3182                    }),
3183                }))
3184            },
3185        )
3186    }
3187}
3188
3189/// Protocol for interacting with the Google-specific display hardware.
3190#[derive(Debug)]
3191pub enum DisplayDeviceRequest {
3192    /// Gets the current state of the display.
3193    GetDisplayState { responder: DisplayDeviceGetDisplayStateResponder },
3194    /// Gets synchronization information for the display. This can include
3195    /// the display's mode, panel mode, and brightness levels.
3196    GetDisplayInfo { responder: DisplayDeviceGetDisplayInfoResponder },
3197    /// Gets the current display owner, which is either the AP (Application
3198    /// Processor) or the MCU (Microcontroller Unit).
3199    GetDisplaySelect { responder: DisplayDeviceGetDisplaySelectResponder },
3200    /// Sets the display owner to be either the AP (Application Processor) or
3201    /// the MCU (Microcontroller Unit).
3202    SetDisplaySelect {
3203        payload: DisplayDeviceSetDisplaySelectRequest,
3204        responder: DisplayDeviceSetDisplaySelectResponder,
3205    },
3206}
3207
3208impl DisplayDeviceRequest {
3209    #[allow(irrefutable_let_patterns)]
3210    pub fn into_get_display_state(self) -> Option<(DisplayDeviceGetDisplayStateResponder)> {
3211        if let DisplayDeviceRequest::GetDisplayState { responder } = self {
3212            Some((responder))
3213        } else {
3214            None
3215        }
3216    }
3217
3218    #[allow(irrefutable_let_patterns)]
3219    pub fn into_get_display_info(self) -> Option<(DisplayDeviceGetDisplayInfoResponder)> {
3220        if let DisplayDeviceRequest::GetDisplayInfo { responder } = self {
3221            Some((responder))
3222        } else {
3223            None
3224        }
3225    }
3226
3227    #[allow(irrefutable_let_patterns)]
3228    pub fn into_get_display_select(self) -> Option<(DisplayDeviceGetDisplaySelectResponder)> {
3229        if let DisplayDeviceRequest::GetDisplaySelect { responder } = self {
3230            Some((responder))
3231        } else {
3232            None
3233        }
3234    }
3235
3236    #[allow(irrefutable_let_patterns)]
3237    pub fn into_set_display_select(
3238        self,
3239    ) -> Option<(DisplayDeviceSetDisplaySelectRequest, DisplayDeviceSetDisplaySelectResponder)>
3240    {
3241        if let DisplayDeviceRequest::SetDisplaySelect { payload, responder } = self {
3242            Some((payload, responder))
3243        } else {
3244            None
3245        }
3246    }
3247
3248    /// Name of the method defined in FIDL
3249    pub fn method_name(&self) -> &'static str {
3250        match *self {
3251            DisplayDeviceRequest::GetDisplayState { .. } => "get_display_state",
3252            DisplayDeviceRequest::GetDisplayInfo { .. } => "get_display_info",
3253            DisplayDeviceRequest::GetDisplaySelect { .. } => "get_display_select",
3254            DisplayDeviceRequest::SetDisplaySelect { .. } => "set_display_select",
3255        }
3256    }
3257}
3258
3259#[derive(Debug, Clone)]
3260pub struct DisplayDeviceControlHandle {
3261    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3262}
3263
3264impl fidl::endpoints::ControlHandle for DisplayDeviceControlHandle {
3265    fn shutdown(&self) {
3266        self.inner.shutdown()
3267    }
3268    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3269        self.inner.shutdown_with_epitaph(status)
3270    }
3271
3272    fn is_closed(&self) -> bool {
3273        self.inner.channel().is_closed()
3274    }
3275    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3276        self.inner.channel().on_closed()
3277    }
3278
3279    #[cfg(target_os = "fuchsia")]
3280    fn signal_peer(
3281        &self,
3282        clear_mask: zx::Signals,
3283        set_mask: zx::Signals,
3284    ) -> Result<(), zx_status::Status> {
3285        use fidl::Peered;
3286        self.inner.channel().signal_peer(clear_mask, set_mask)
3287    }
3288}
3289
3290impl DisplayDeviceControlHandle {}
3291
3292#[must_use = "FIDL methods require a response to be sent"]
3293#[derive(Debug)]
3294pub struct DisplayDeviceGetDisplayStateResponder {
3295    control_handle: std::mem::ManuallyDrop<DisplayDeviceControlHandle>,
3296    tx_id: u32,
3297}
3298
3299/// Set the the channel to be shutdown (see [`DisplayDeviceControlHandle::shutdown`])
3300/// if the responder is dropped without sending a response, so that the client
3301/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3302impl std::ops::Drop for DisplayDeviceGetDisplayStateResponder {
3303    fn drop(&mut self) {
3304        self.control_handle.shutdown();
3305        // Safety: drops once, never accessed again
3306        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3307    }
3308}
3309
3310impl fidl::endpoints::Responder for DisplayDeviceGetDisplayStateResponder {
3311    type ControlHandle = DisplayDeviceControlHandle;
3312
3313    fn control_handle(&self) -> &DisplayDeviceControlHandle {
3314        &self.control_handle
3315    }
3316
3317    fn drop_without_shutdown(mut self) {
3318        // Safety: drops once, never accessed again due to mem::forget
3319        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3320        // Prevent Drop from running (which would shut down the channel)
3321        std::mem::forget(self);
3322    }
3323}
3324
3325impl DisplayDeviceGetDisplayStateResponder {
3326    /// Sends a response to the FIDL transaction.
3327    ///
3328    /// Sets the channel to shutdown if an error occurs.
3329    pub fn send(self, mut result: Result<&DisplayState, i32>) -> Result<(), fidl::Error> {
3330        let _result = self.send_raw(result);
3331        if _result.is_err() {
3332            self.control_handle.shutdown();
3333        }
3334        self.drop_without_shutdown();
3335        _result
3336    }
3337
3338    /// Similar to "send" but does not shutdown the channel if an error occurs.
3339    pub fn send_no_shutdown_on_err(
3340        self,
3341        mut result: Result<&DisplayState, i32>,
3342    ) -> Result<(), fidl::Error> {
3343        let _result = self.send_raw(result);
3344        self.drop_without_shutdown();
3345        _result
3346    }
3347
3348    fn send_raw(&self, mut result: Result<&DisplayState, i32>) -> Result<(), fidl::Error> {
3349        self.control_handle.inner.send::<fidl::encoding::ResultType<DisplayState, i32>>(
3350            result,
3351            self.tx_id,
3352            0x1648924f6e003444,
3353            fidl::encoding::DynamicFlags::empty(),
3354        )
3355    }
3356}
3357
3358#[must_use = "FIDL methods require a response to be sent"]
3359#[derive(Debug)]
3360pub struct DisplayDeviceGetDisplayInfoResponder {
3361    control_handle: std::mem::ManuallyDrop<DisplayDeviceControlHandle>,
3362    tx_id: u32,
3363}
3364
3365/// Set the the channel to be shutdown (see [`DisplayDeviceControlHandle::shutdown`])
3366/// if the responder is dropped without sending a response, so that the client
3367/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3368impl std::ops::Drop for DisplayDeviceGetDisplayInfoResponder {
3369    fn drop(&mut self) {
3370        self.control_handle.shutdown();
3371        // Safety: drops once, never accessed again
3372        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3373    }
3374}
3375
3376impl fidl::endpoints::Responder for DisplayDeviceGetDisplayInfoResponder {
3377    type ControlHandle = DisplayDeviceControlHandle;
3378
3379    fn control_handle(&self) -> &DisplayDeviceControlHandle {
3380        &self.control_handle
3381    }
3382
3383    fn drop_without_shutdown(mut self) {
3384        // Safety: drops once, never accessed again due to mem::forget
3385        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3386        // Prevent Drop from running (which would shut down the channel)
3387        std::mem::forget(self);
3388    }
3389}
3390
3391impl DisplayDeviceGetDisplayInfoResponder {
3392    /// Sends a response to the FIDL transaction.
3393    ///
3394    /// Sets the channel to shutdown if an error occurs.
3395    pub fn send(self, mut result: Result<&DisplaySyncInfo, i32>) -> Result<(), fidl::Error> {
3396        let _result = self.send_raw(result);
3397        if _result.is_err() {
3398            self.control_handle.shutdown();
3399        }
3400        self.drop_without_shutdown();
3401        _result
3402    }
3403
3404    /// Similar to "send" but does not shutdown the channel if an error occurs.
3405    pub fn send_no_shutdown_on_err(
3406        self,
3407        mut result: Result<&DisplaySyncInfo, i32>,
3408    ) -> Result<(), fidl::Error> {
3409        let _result = self.send_raw(result);
3410        self.drop_without_shutdown();
3411        _result
3412    }
3413
3414    fn send_raw(&self, mut result: Result<&DisplaySyncInfo, i32>) -> Result<(), fidl::Error> {
3415        self.control_handle.inner.send::<fidl::encoding::ResultType<DisplaySyncInfo, i32>>(
3416            result,
3417            self.tx_id,
3418            0x311c8e4cb6b1b4d1,
3419            fidl::encoding::DynamicFlags::empty(),
3420        )
3421    }
3422}
3423
3424#[must_use = "FIDL methods require a response to be sent"]
3425#[derive(Debug)]
3426pub struct DisplayDeviceGetDisplaySelectResponder {
3427    control_handle: std::mem::ManuallyDrop<DisplayDeviceControlHandle>,
3428    tx_id: u32,
3429}
3430
3431/// Set the the channel to be shutdown (see [`DisplayDeviceControlHandle::shutdown`])
3432/// if the responder is dropped without sending a response, so that the client
3433/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3434impl std::ops::Drop for DisplayDeviceGetDisplaySelectResponder {
3435    fn drop(&mut self) {
3436        self.control_handle.shutdown();
3437        // Safety: drops once, never accessed again
3438        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3439    }
3440}
3441
3442impl fidl::endpoints::Responder for DisplayDeviceGetDisplaySelectResponder {
3443    type ControlHandle = DisplayDeviceControlHandle;
3444
3445    fn control_handle(&self) -> &DisplayDeviceControlHandle {
3446        &self.control_handle
3447    }
3448
3449    fn drop_without_shutdown(mut self) {
3450        // Safety: drops once, never accessed again due to mem::forget
3451        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3452        // Prevent Drop from running (which would shut down the channel)
3453        std::mem::forget(self);
3454    }
3455}
3456
3457impl DisplayDeviceGetDisplaySelectResponder {
3458    /// Sends a response to the FIDL transaction.
3459    ///
3460    /// Sets the channel to shutdown if an error occurs.
3461    pub fn send(
3462        self,
3463        mut result: Result<&DisplayDeviceGetDisplaySelectResponse, i32>,
3464    ) -> Result<(), fidl::Error> {
3465        let _result = self.send_raw(result);
3466        if _result.is_err() {
3467            self.control_handle.shutdown();
3468        }
3469        self.drop_without_shutdown();
3470        _result
3471    }
3472
3473    /// Similar to "send" but does not shutdown the channel if an error occurs.
3474    pub fn send_no_shutdown_on_err(
3475        self,
3476        mut result: Result<&DisplayDeviceGetDisplaySelectResponse, i32>,
3477    ) -> Result<(), fidl::Error> {
3478        let _result = self.send_raw(result);
3479        self.drop_without_shutdown();
3480        _result
3481    }
3482
3483    fn send_raw(
3484        &self,
3485        mut result: Result<&DisplayDeviceGetDisplaySelectResponse, i32>,
3486    ) -> Result<(), fidl::Error> {
3487        self.control_handle.inner.send::<fidl::encoding::ResultType<
3488            DisplayDeviceGetDisplaySelectResponse,
3489            i32,
3490        >>(
3491            result,
3492            self.tx_id,
3493            0x6191c86cffd6323,
3494            fidl::encoding::DynamicFlags::empty(),
3495        )
3496    }
3497}
3498
3499#[must_use = "FIDL methods require a response to be sent"]
3500#[derive(Debug)]
3501pub struct DisplayDeviceSetDisplaySelectResponder {
3502    control_handle: std::mem::ManuallyDrop<DisplayDeviceControlHandle>,
3503    tx_id: u32,
3504}
3505
3506/// Set the the channel to be shutdown (see [`DisplayDeviceControlHandle::shutdown`])
3507/// if the responder is dropped without sending a response, so that the client
3508/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3509impl std::ops::Drop for DisplayDeviceSetDisplaySelectResponder {
3510    fn drop(&mut self) {
3511        self.control_handle.shutdown();
3512        // Safety: drops once, never accessed again
3513        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3514    }
3515}
3516
3517impl fidl::endpoints::Responder for DisplayDeviceSetDisplaySelectResponder {
3518    type ControlHandle = DisplayDeviceControlHandle;
3519
3520    fn control_handle(&self) -> &DisplayDeviceControlHandle {
3521        &self.control_handle
3522    }
3523
3524    fn drop_without_shutdown(mut self) {
3525        // Safety: drops once, never accessed again due to mem::forget
3526        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3527        // Prevent Drop from running (which would shut down the channel)
3528        std::mem::forget(self);
3529    }
3530}
3531
3532impl DisplayDeviceSetDisplaySelectResponder {
3533    /// Sends a response to the FIDL transaction.
3534    ///
3535    /// Sets the channel to shutdown if an error occurs.
3536    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3537        let _result = self.send_raw(result);
3538        if _result.is_err() {
3539            self.control_handle.shutdown();
3540        }
3541        self.drop_without_shutdown();
3542        _result
3543    }
3544
3545    /// Similar to "send" but does not shutdown the channel if an error occurs.
3546    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3547        let _result = self.send_raw(result);
3548        self.drop_without_shutdown();
3549        _result
3550    }
3551
3552    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3553        self.control_handle
3554            .inner
3555            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3556                result,
3557                self.tx_id,
3558                0x2b07f6ba12e7a412,
3559                fidl::encoding::DynamicFlags::empty(),
3560            )
3561    }
3562}
3563
3564#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3565pub struct LifecycleObserverMarker;
3566
3567impl fidl::endpoints::ProtocolMarker for LifecycleObserverMarker {
3568    type Proxy = LifecycleObserverProxy;
3569    type RequestStream = LifecycleObserverRequestStream;
3570    #[cfg(target_os = "fuchsia")]
3571    type SynchronousProxy = LifecycleObserverSynchronousProxy;
3572
3573    const DEBUG_NAME: &'static str = "(anonymous) LifecycleObserver";
3574}
3575
3576pub trait LifecycleObserverProxyInterface: Send + Sync {}
3577#[derive(Debug)]
3578#[cfg(target_os = "fuchsia")]
3579pub struct LifecycleObserverSynchronousProxy {
3580    client: fidl::client::sync::Client,
3581}
3582
3583#[cfg(target_os = "fuchsia")]
3584impl fidl::endpoints::SynchronousProxy for LifecycleObserverSynchronousProxy {
3585    type Proxy = LifecycleObserverProxy;
3586    type Protocol = LifecycleObserverMarker;
3587
3588    fn from_channel(inner: fidl::Channel) -> Self {
3589        Self::new(inner)
3590    }
3591
3592    fn into_channel(self) -> fidl::Channel {
3593        self.client.into_channel()
3594    }
3595
3596    fn as_channel(&self) -> &fidl::Channel {
3597        self.client.as_channel()
3598    }
3599}
3600
3601#[cfg(target_os = "fuchsia")]
3602impl LifecycleObserverSynchronousProxy {
3603    pub fn new(channel: fidl::Channel) -> Self {
3604        let protocol_name =
3605            <LifecycleObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3606        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3607    }
3608
3609    pub fn into_channel(self) -> fidl::Channel {
3610        self.client.into_channel()
3611    }
3612
3613    /// Waits until an event arrives and returns it. It is safe for other
3614    /// threads to make concurrent requests while waiting for an event.
3615    pub fn wait_for_event(
3616        &self,
3617        deadline: zx::MonotonicInstant,
3618    ) -> Result<LifecycleObserverEvent, fidl::Error> {
3619        LifecycleObserverEvent::decode(self.client.wait_for_event(deadline)?)
3620    }
3621}
3622
3623#[cfg(target_os = "fuchsia")]
3624impl From<LifecycleObserverSynchronousProxy> for zx::Handle {
3625    fn from(value: LifecycleObserverSynchronousProxy) -> Self {
3626        value.into_channel().into()
3627    }
3628}
3629
3630#[cfg(target_os = "fuchsia")]
3631impl From<fidl::Channel> for LifecycleObserverSynchronousProxy {
3632    fn from(value: fidl::Channel) -> Self {
3633        Self::new(value)
3634    }
3635}
3636
3637#[cfg(target_os = "fuchsia")]
3638impl fidl::endpoints::FromClient for LifecycleObserverSynchronousProxy {
3639    type Protocol = LifecycleObserverMarker;
3640
3641    fn from_client(value: fidl::endpoints::ClientEnd<LifecycleObserverMarker>) -> Self {
3642        Self::new(value.into_channel())
3643    }
3644}
3645
3646#[derive(Debug, Clone)]
3647pub struct LifecycleObserverProxy {
3648    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3649}
3650
3651impl fidl::endpoints::Proxy for LifecycleObserverProxy {
3652    type Protocol = LifecycleObserverMarker;
3653
3654    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3655        Self::new(inner)
3656    }
3657
3658    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3659        self.client.into_channel().map_err(|client| Self { client })
3660    }
3661
3662    fn as_channel(&self) -> &::fidl::AsyncChannel {
3663        self.client.as_channel()
3664    }
3665}
3666
3667impl LifecycleObserverProxy {
3668    /// Create a new Proxy for fuchsia.hardware.google.nanohub/LifecycleObserver.
3669    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3670        let protocol_name =
3671            <LifecycleObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3672        Self { client: fidl::client::Client::new(channel, protocol_name) }
3673    }
3674
3675    /// Get a Stream of events from the remote end of the protocol.
3676    ///
3677    /// # Panics
3678    ///
3679    /// Panics if the event stream was already taken.
3680    pub fn take_event_stream(&self) -> LifecycleObserverEventStream {
3681        LifecycleObserverEventStream { event_receiver: self.client.take_event_receiver() }
3682    }
3683}
3684
3685impl LifecycleObserverProxyInterface for LifecycleObserverProxy {}
3686
3687pub struct LifecycleObserverEventStream {
3688    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3689}
3690
3691impl std::marker::Unpin for LifecycleObserverEventStream {}
3692
3693impl futures::stream::FusedStream for LifecycleObserverEventStream {
3694    fn is_terminated(&self) -> bool {
3695        self.event_receiver.is_terminated()
3696    }
3697}
3698
3699impl futures::Stream for LifecycleObserverEventStream {
3700    type Item = Result<LifecycleObserverEvent, fidl::Error>;
3701
3702    fn poll_next(
3703        mut self: std::pin::Pin<&mut Self>,
3704        cx: &mut std::task::Context<'_>,
3705    ) -> std::task::Poll<Option<Self::Item>> {
3706        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3707            &mut self.event_receiver,
3708            cx
3709        )?) {
3710            Some(buf) => std::task::Poll::Ready(Some(LifecycleObserverEvent::decode(buf))),
3711            None => std::task::Poll::Ready(None),
3712        }
3713    }
3714}
3715
3716#[derive(Debug)]
3717pub enum LifecycleObserverEvent {
3718    OnLifecycleChange { event: LifecycleEvent },
3719}
3720
3721impl LifecycleObserverEvent {
3722    #[allow(irrefutable_let_patterns)]
3723    pub fn into_on_lifecycle_change(self) -> Option<LifecycleEvent> {
3724        if let LifecycleObserverEvent::OnLifecycleChange { event } = self {
3725            Some((event))
3726        } else {
3727            None
3728        }
3729    }
3730
3731    /// Decodes a message buffer as a [`LifecycleObserverEvent`].
3732    fn decode(
3733        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3734    ) -> Result<LifecycleObserverEvent, fidl::Error> {
3735        let (bytes, _handles) = buf.split_mut();
3736        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3737        debug_assert_eq!(tx_header.tx_id, 0);
3738        match tx_header.ordinal {
3739            0x7034eb94979bd8de => {
3740                let mut out = fidl::new_empty!(
3741                    LifecycleObserverOnLifecycleChangeRequest,
3742                    fidl::encoding::DefaultFuchsiaResourceDialect
3743                );
3744                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LifecycleObserverOnLifecycleChangeRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3745                Ok((LifecycleObserverEvent::OnLifecycleChange { event: out.event }))
3746            }
3747            _ => Err(fidl::Error::UnknownOrdinal {
3748                ordinal: tx_header.ordinal,
3749                protocol_name:
3750                    <LifecycleObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3751            }),
3752        }
3753    }
3754}
3755
3756/// A Stream of incoming requests for fuchsia.hardware.google.nanohub/LifecycleObserver.
3757pub struct LifecycleObserverRequestStream {
3758    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3759    is_terminated: bool,
3760}
3761
3762impl std::marker::Unpin for LifecycleObserverRequestStream {}
3763
3764impl futures::stream::FusedStream for LifecycleObserverRequestStream {
3765    fn is_terminated(&self) -> bool {
3766        self.is_terminated
3767    }
3768}
3769
3770impl fidl::endpoints::RequestStream for LifecycleObserverRequestStream {
3771    type Protocol = LifecycleObserverMarker;
3772    type ControlHandle = LifecycleObserverControlHandle;
3773
3774    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3775        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3776    }
3777
3778    fn control_handle(&self) -> Self::ControlHandle {
3779        LifecycleObserverControlHandle { inner: self.inner.clone() }
3780    }
3781
3782    fn into_inner(
3783        self,
3784    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3785    {
3786        (self.inner, self.is_terminated)
3787    }
3788
3789    fn from_inner(
3790        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3791        is_terminated: bool,
3792    ) -> Self {
3793        Self { inner, is_terminated }
3794    }
3795}
3796
3797impl futures::Stream for LifecycleObserverRequestStream {
3798    type Item = Result<LifecycleObserverRequest, fidl::Error>;
3799
3800    fn poll_next(
3801        mut self: std::pin::Pin<&mut Self>,
3802        cx: &mut std::task::Context<'_>,
3803    ) -> std::task::Poll<Option<Self::Item>> {
3804        let this = &mut *self;
3805        if this.inner.check_shutdown(cx) {
3806            this.is_terminated = true;
3807            return std::task::Poll::Ready(None);
3808        }
3809        if this.is_terminated {
3810            panic!("polled LifecycleObserverRequestStream after completion");
3811        }
3812        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3813            |bytes, handles| {
3814                match this.inner.channel().read_etc(cx, bytes, handles) {
3815                    std::task::Poll::Ready(Ok(())) => {}
3816                    std::task::Poll::Pending => return std::task::Poll::Pending,
3817                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3818                        this.is_terminated = true;
3819                        return std::task::Poll::Ready(None);
3820                    }
3821                    std::task::Poll::Ready(Err(e)) => {
3822                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3823                            e.into(),
3824                        ))));
3825                    }
3826                }
3827
3828                // A message has been received from the channel
3829                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3830
3831                std::task::Poll::Ready(Some(match header.ordinal {
3832                    _ => Err(fidl::Error::UnknownOrdinal {
3833                        ordinal: header.ordinal,
3834                        protocol_name:
3835                            <LifecycleObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3836                    }),
3837                }))
3838            },
3839        )
3840    }
3841}
3842
3843/// Observer interface for lifecycle events.
3844#[derive(Debug)]
3845pub enum LifecycleObserverRequest {}
3846
3847impl LifecycleObserverRequest {
3848    /// Name of the method defined in FIDL
3849    pub fn method_name(&self) -> &'static str {
3850        match *self {}
3851    }
3852}
3853
3854#[derive(Debug, Clone)]
3855pub struct LifecycleObserverControlHandle {
3856    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3857}
3858
3859impl fidl::endpoints::ControlHandle for LifecycleObserverControlHandle {
3860    fn shutdown(&self) {
3861        self.inner.shutdown()
3862    }
3863    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3864        self.inner.shutdown_with_epitaph(status)
3865    }
3866
3867    fn is_closed(&self) -> bool {
3868        self.inner.channel().is_closed()
3869    }
3870    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3871        self.inner.channel().on_closed()
3872    }
3873
3874    #[cfg(target_os = "fuchsia")]
3875    fn signal_peer(
3876        &self,
3877        clear_mask: zx::Signals,
3878        set_mask: zx::Signals,
3879    ) -> Result<(), zx_status::Status> {
3880        use fidl::Peered;
3881        self.inner.channel().signal_peer(clear_mask, set_mask)
3882    }
3883}
3884
3885impl LifecycleObserverControlHandle {
3886    pub fn send_on_lifecycle_change(&self, mut event: LifecycleEvent) -> Result<(), fidl::Error> {
3887        self.inner.send::<LifecycleObserverOnLifecycleChangeRequest>(
3888            (event,),
3889            0,
3890            0x7034eb94979bd8de,
3891            fidl::encoding::DynamicFlags::empty(),
3892        )
3893    }
3894}
3895
3896#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3897pub struct DataChannelServiceMarker;
3898
3899#[cfg(target_os = "fuchsia")]
3900impl fidl::endpoints::ServiceMarker for DataChannelServiceMarker {
3901    type Proxy = DataChannelServiceProxy;
3902    type Request = DataChannelServiceRequest;
3903    const SERVICE_NAME: &'static str = "fuchsia.hardware.google.nanohub.DataChannelService";
3904}
3905
3906/// A request for one of the member protocols of DataChannelService.
3907///
3908/// Service for clients.
3909///
3910/// The data channel is pre-bound to a particular identifier as per bind rules.
3911#[cfg(target_os = "fuchsia")]
3912pub enum DataChannelServiceRequest {
3913    Device(DataChannelRequestStream),
3914    Lifecycle(LifecycleObserverRequestStream),
3915}
3916
3917#[cfg(target_os = "fuchsia")]
3918impl fidl::endpoints::ServiceRequest for DataChannelServiceRequest {
3919    type Service = DataChannelServiceMarker;
3920
3921    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
3922        match name {
3923            "device" => Self::Device(
3924                <DataChannelRequestStream as fidl::endpoints::RequestStream>::from_channel(
3925                    _channel,
3926                ),
3927            ),
3928            "lifecycle" => Self::Lifecycle(
3929                <LifecycleObserverRequestStream as fidl::endpoints::RequestStream>::from_channel(
3930                    _channel,
3931                ),
3932            ),
3933            _ => panic!("no such member protocol name for service DataChannelService"),
3934        }
3935    }
3936
3937    fn member_names() -> &'static [&'static str] {
3938        &["device", "lifecycle"]
3939    }
3940}
3941/// Service for clients.
3942///
3943/// The data channel is pre-bound to a particular identifier as per bind rules.
3944#[cfg(target_os = "fuchsia")]
3945pub struct DataChannelServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
3946
3947#[cfg(target_os = "fuchsia")]
3948impl fidl::endpoints::ServiceProxy for DataChannelServiceProxy {
3949    type Service = DataChannelServiceMarker;
3950
3951    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
3952        Self(opener)
3953    }
3954}
3955
3956#[cfg(target_os = "fuchsia")]
3957impl DataChannelServiceProxy {
3958    pub fn connect_to_device(&self) -> Result<DataChannelProxy, fidl::Error> {
3959        let (proxy, server_end) = fidl::endpoints::create_proxy::<DataChannelMarker>();
3960        self.connect_channel_to_device(server_end)?;
3961        Ok(proxy)
3962    }
3963
3964    /// Like `connect_to_device`, but returns a sync proxy.
3965    /// See [`Self::connect_to_device`] for more details.
3966    pub fn connect_to_device_sync(&self) -> Result<DataChannelSynchronousProxy, fidl::Error> {
3967        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DataChannelMarker>();
3968        self.connect_channel_to_device(server_end)?;
3969        Ok(proxy)
3970    }
3971
3972    /// Like `connect_to_device`, but accepts a server end.
3973    /// See [`Self::connect_to_device`] for more details.
3974    pub fn connect_channel_to_device(
3975        &self,
3976        server_end: fidl::endpoints::ServerEnd<DataChannelMarker>,
3977    ) -> Result<(), fidl::Error> {
3978        self.0.open_member("device", server_end.into_channel())
3979    }
3980    pub fn connect_to_lifecycle(&self) -> Result<LifecycleObserverProxy, fidl::Error> {
3981        let (proxy, server_end) = fidl::endpoints::create_proxy::<LifecycleObserverMarker>();
3982        self.connect_channel_to_lifecycle(server_end)?;
3983        Ok(proxy)
3984    }
3985
3986    /// Like `connect_to_lifecycle`, but returns a sync proxy.
3987    /// See [`Self::connect_to_lifecycle`] for more details.
3988    pub fn connect_to_lifecycle_sync(
3989        &self,
3990    ) -> Result<LifecycleObserverSynchronousProxy, fidl::Error> {
3991        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<LifecycleObserverMarker>();
3992        self.connect_channel_to_lifecycle(server_end)?;
3993        Ok(proxy)
3994    }
3995
3996    /// Like `connect_to_lifecycle`, but accepts a server end.
3997    /// See [`Self::connect_to_lifecycle`] for more details.
3998    pub fn connect_channel_to_lifecycle(
3999        &self,
4000        server_end: fidl::endpoints::ServerEnd<LifecycleObserverMarker>,
4001    ) -> Result<(), fidl::Error> {
4002        self.0.open_member("lifecycle", server_end.into_channel())
4003    }
4004
4005    pub fn instance_name(&self) -> &str {
4006        self.0.instance_name()
4007    }
4008}
4009
4010#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4011pub struct DisplayServiceMarker;
4012
4013#[cfg(target_os = "fuchsia")]
4014impl fidl::endpoints::ServiceMarker for DisplayServiceMarker {
4015    type Proxy = DisplayServiceProxy;
4016    type Request = DisplayServiceRequest;
4017    const SERVICE_NAME: &'static str = "fuchsia.hardware.google.nanohub.DisplayService";
4018}
4019
4020/// A request for one of the member protocols of DisplayService.
4021///
4022/// The service that provides access to the display device.
4023#[cfg(target_os = "fuchsia")]
4024pub enum DisplayServiceRequest {
4025    /// The display device.
4026    Mcudisplay(DisplayDeviceRequestStream),
4027}
4028
4029#[cfg(target_os = "fuchsia")]
4030impl fidl::endpoints::ServiceRequest for DisplayServiceRequest {
4031    type Service = DisplayServiceMarker;
4032
4033    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
4034        match name {
4035            "mcudisplay" => Self::Mcudisplay(
4036                <DisplayDeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(
4037                    _channel,
4038                ),
4039            ),
4040            _ => panic!("no such member protocol name for service DisplayService"),
4041        }
4042    }
4043
4044    fn member_names() -> &'static [&'static str] {
4045        &["mcudisplay"]
4046    }
4047}
4048/// The service that provides access to the display device.
4049#[cfg(target_os = "fuchsia")]
4050pub struct DisplayServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
4051
4052#[cfg(target_os = "fuchsia")]
4053impl fidl::endpoints::ServiceProxy for DisplayServiceProxy {
4054    type Service = DisplayServiceMarker;
4055
4056    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
4057        Self(opener)
4058    }
4059}
4060
4061#[cfg(target_os = "fuchsia")]
4062impl DisplayServiceProxy {
4063    /// The display device.
4064    pub fn connect_to_mcudisplay(&self) -> Result<DisplayDeviceProxy, fidl::Error> {
4065        let (proxy, server_end) = fidl::endpoints::create_proxy::<DisplayDeviceMarker>();
4066        self.connect_channel_to_mcudisplay(server_end)?;
4067        Ok(proxy)
4068    }
4069
4070    /// Like `connect_to_mcudisplay`, but returns a sync proxy.
4071    /// See [`Self::connect_to_mcudisplay`] for more details.
4072    pub fn connect_to_mcudisplay_sync(&self) -> Result<DisplayDeviceSynchronousProxy, fidl::Error> {
4073        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DisplayDeviceMarker>();
4074        self.connect_channel_to_mcudisplay(server_end)?;
4075        Ok(proxy)
4076    }
4077
4078    /// Like `connect_to_mcudisplay`, but accepts a server end.
4079    /// See [`Self::connect_to_mcudisplay`] for more details.
4080    pub fn connect_channel_to_mcudisplay(
4081        &self,
4082        server_end: fidl::endpoints::ServerEnd<DisplayDeviceMarker>,
4083    ) -> Result<(), fidl::Error> {
4084        self.0.open_member("mcudisplay", server_end.into_channel())
4085    }
4086
4087    pub fn instance_name(&self) -> &str {
4088        self.0.instance_name()
4089    }
4090}
4091
4092#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4093pub struct ServiceMarker;
4094
4095#[cfg(target_os = "fuchsia")]
4096impl fidl::endpoints::ServiceMarker for ServiceMarker {
4097    type Proxy = ServiceProxy;
4098    type Request = ServiceRequest;
4099    const SERVICE_NAME: &'static str = "fuchsia.hardware.google.nanohub.Service";
4100}
4101
4102/// A request for one of the member protocols of Service.
4103///
4104#[cfg(target_os = "fuchsia")]
4105pub enum ServiceRequest {
4106    Nanohub(DeviceRequestStream),
4107}
4108
4109#[cfg(target_os = "fuchsia")]
4110impl fidl::endpoints::ServiceRequest for ServiceRequest {
4111    type Service = ServiceMarker;
4112
4113    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
4114        match name {
4115            "nanohub" => Self::Nanohub(
4116                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
4117            ),
4118            _ => panic!("no such member protocol name for service Service"),
4119        }
4120    }
4121
4122    fn member_names() -> &'static [&'static str] {
4123        &["nanohub"]
4124    }
4125}
4126#[cfg(target_os = "fuchsia")]
4127pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
4128
4129#[cfg(target_os = "fuchsia")]
4130impl fidl::endpoints::ServiceProxy for ServiceProxy {
4131    type Service = ServiceMarker;
4132
4133    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
4134        Self(opener)
4135    }
4136}
4137
4138#[cfg(target_os = "fuchsia")]
4139impl ServiceProxy {
4140    pub fn connect_to_nanohub(&self) -> Result<DeviceProxy, fidl::Error> {
4141        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
4142        self.connect_channel_to_nanohub(server_end)?;
4143        Ok(proxy)
4144    }
4145
4146    /// Like `connect_to_nanohub`, but returns a sync proxy.
4147    /// See [`Self::connect_to_nanohub`] for more details.
4148    pub fn connect_to_nanohub_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
4149        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
4150        self.connect_channel_to_nanohub(server_end)?;
4151        Ok(proxy)
4152    }
4153
4154    /// Like `connect_to_nanohub`, but accepts a server end.
4155    /// See [`Self::connect_to_nanohub`] for more details.
4156    pub fn connect_channel_to_nanohub(
4157        &self,
4158        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
4159    ) -> Result<(), fidl::Error> {
4160        self.0.open_member("nanohub", server_end.into_channel())
4161    }
4162
4163    pub fn instance_name(&self) -> &str {
4164        self.0.instance_name()
4165    }
4166}
4167
4168mod internal {
4169    use super::*;
4170
4171    impl fidl::encoding::ResourceTypeMarker for DataChannelRegisterRequest {
4172        type Borrowed<'a> = &'a mut Self;
4173        fn take_or_borrow<'a>(
4174            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4175        ) -> Self::Borrowed<'a> {
4176            value
4177        }
4178    }
4179
4180    unsafe impl fidl::encoding::TypeMarker for DataChannelRegisterRequest {
4181        type Owned = Self;
4182
4183        #[inline(always)]
4184        fn inline_align(_context: fidl::encoding::Context) -> usize {
4185            4
4186        }
4187
4188        #[inline(always)]
4189        fn inline_size(_context: fidl::encoding::Context) -> usize {
4190            4
4191        }
4192    }
4193
4194    unsafe impl
4195        fidl::encoding::Encode<
4196            DataChannelRegisterRequest,
4197            fidl::encoding::DefaultFuchsiaResourceDialect,
4198        > for &mut DataChannelRegisterRequest
4199    {
4200        #[inline]
4201        unsafe fn encode(
4202            self,
4203            encoder: &mut fidl::encoding::Encoder<
4204                '_,
4205                fidl::encoding::DefaultFuchsiaResourceDialect,
4206            >,
4207            offset: usize,
4208            _depth: fidl::encoding::Depth,
4209        ) -> fidl::Result<()> {
4210            encoder.debug_check_bounds::<DataChannelRegisterRequest>(offset);
4211            // Delegate to tuple encoding.
4212            fidl::encoding::Encode::<
4213                DataChannelRegisterRequest,
4214                fidl::encoding::DefaultFuchsiaResourceDialect,
4215            >::encode(
4216                (<fidl::encoding::HandleType<
4217                    fidl::Event,
4218                    { fidl::ObjectType::EVENT.into_raw() },
4219                    2147483648,
4220                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4221                    &mut self.event
4222                ),),
4223                encoder,
4224                offset,
4225                _depth,
4226            )
4227        }
4228    }
4229    unsafe impl<
4230        T0: fidl::encoding::Encode<
4231                fidl::encoding::HandleType<
4232                    fidl::Event,
4233                    { fidl::ObjectType::EVENT.into_raw() },
4234                    2147483648,
4235                >,
4236                fidl::encoding::DefaultFuchsiaResourceDialect,
4237            >,
4238    >
4239        fidl::encoding::Encode<
4240            DataChannelRegisterRequest,
4241            fidl::encoding::DefaultFuchsiaResourceDialect,
4242        > for (T0,)
4243    {
4244        #[inline]
4245        unsafe fn encode(
4246            self,
4247            encoder: &mut fidl::encoding::Encoder<
4248                '_,
4249                fidl::encoding::DefaultFuchsiaResourceDialect,
4250            >,
4251            offset: usize,
4252            depth: fidl::encoding::Depth,
4253        ) -> fidl::Result<()> {
4254            encoder.debug_check_bounds::<DataChannelRegisterRequest>(offset);
4255            // Zero out padding regions. There's no need to apply masks
4256            // because the unmasked parts will be overwritten by fields.
4257            // Write the fields.
4258            self.0.encode(encoder, offset + 0, depth)?;
4259            Ok(())
4260        }
4261    }
4262
4263    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4264        for DataChannelRegisterRequest
4265    {
4266        #[inline(always)]
4267        fn new_empty() -> Self {
4268            Self {
4269                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
4270            }
4271        }
4272
4273        #[inline]
4274        unsafe fn decode(
4275            &mut self,
4276            decoder: &mut fidl::encoding::Decoder<
4277                '_,
4278                fidl::encoding::DefaultFuchsiaResourceDialect,
4279            >,
4280            offset: usize,
4281            _depth: fidl::encoding::Depth,
4282        ) -> fidl::Result<()> {
4283            decoder.debug_check_bounds::<Self>(offset);
4284            // Verify that padding bytes are zero.
4285            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
4286            Ok(())
4287        }
4288    }
4289
4290    impl fidl::encoding::ResourceTypeMarker for DeviceDownloadFirmwareRequest {
4291        type Borrowed<'a> = &'a mut Self;
4292        fn take_or_borrow<'a>(
4293            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4294        ) -> Self::Borrowed<'a> {
4295            value
4296        }
4297    }
4298
4299    unsafe impl fidl::encoding::TypeMarker for DeviceDownloadFirmwareRequest {
4300        type Owned = Self;
4301
4302        #[inline(always)]
4303        fn inline_align(_context: fidl::encoding::Context) -> usize {
4304            8
4305        }
4306
4307        #[inline(always)]
4308        fn inline_size(_context: fidl::encoding::Context) -> usize {
4309            16
4310        }
4311    }
4312
4313    unsafe impl
4314        fidl::encoding::Encode<
4315            DeviceDownloadFirmwareRequest,
4316            fidl::encoding::DefaultFuchsiaResourceDialect,
4317        > for &mut DeviceDownloadFirmwareRequest
4318    {
4319        #[inline]
4320        unsafe fn encode(
4321            self,
4322            encoder: &mut fidl::encoding::Encoder<
4323                '_,
4324                fidl::encoding::DefaultFuchsiaResourceDialect,
4325            >,
4326            offset: usize,
4327            _depth: fidl::encoding::Depth,
4328        ) -> fidl::Result<()> {
4329            encoder.debug_check_bounds::<DeviceDownloadFirmwareRequest>(offset);
4330            // Delegate to tuple encoding.
4331            fidl::encoding::Encode::<
4332                DeviceDownloadFirmwareRequest,
4333                fidl::encoding::DefaultFuchsiaResourceDialect,
4334            >::encode(
4335                (
4336                    <fidl::encoding::HandleType<
4337                        fidl::Vmo,
4338                        { fidl::ObjectType::VMO.into_raw() },
4339                        49271,
4340                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4341                        &mut self.firmware
4342                    ),
4343                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.offset),
4344                ),
4345                encoder,
4346                offset,
4347                _depth,
4348            )
4349        }
4350    }
4351    unsafe impl<
4352        T0: fidl::encoding::Encode<
4353                fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49271>,
4354                fidl::encoding::DefaultFuchsiaResourceDialect,
4355            >,
4356        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
4357    >
4358        fidl::encoding::Encode<
4359            DeviceDownloadFirmwareRequest,
4360            fidl::encoding::DefaultFuchsiaResourceDialect,
4361        > for (T0, T1)
4362    {
4363        #[inline]
4364        unsafe fn encode(
4365            self,
4366            encoder: &mut fidl::encoding::Encoder<
4367                '_,
4368                fidl::encoding::DefaultFuchsiaResourceDialect,
4369            >,
4370            offset: usize,
4371            depth: fidl::encoding::Depth,
4372        ) -> fidl::Result<()> {
4373            encoder.debug_check_bounds::<DeviceDownloadFirmwareRequest>(offset);
4374            // Zero out padding regions. There's no need to apply masks
4375            // because the unmasked parts will be overwritten by fields.
4376            unsafe {
4377                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
4378                (ptr as *mut u64).write_unaligned(0);
4379            }
4380            // Write the fields.
4381            self.0.encode(encoder, offset + 0, depth)?;
4382            self.1.encode(encoder, offset + 8, depth)?;
4383            Ok(())
4384        }
4385    }
4386
4387    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4388        for DeviceDownloadFirmwareRequest
4389    {
4390        #[inline(always)]
4391        fn new_empty() -> Self {
4392            Self {
4393                firmware: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49271>, fidl::encoding::DefaultFuchsiaResourceDialect),
4394                offset: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
4395            }
4396        }
4397
4398        #[inline]
4399        unsafe fn decode(
4400            &mut self,
4401            decoder: &mut fidl::encoding::Decoder<
4402                '_,
4403                fidl::encoding::DefaultFuchsiaResourceDialect,
4404            >,
4405            offset: usize,
4406            _depth: fidl::encoding::Depth,
4407        ) -> fidl::Result<()> {
4408            decoder.debug_check_bounds::<Self>(offset);
4409            // Verify that padding bytes are zero.
4410            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
4411            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4412            let mask = 0xffffffff00000000u64;
4413            let maskedval = padval & mask;
4414            if maskedval != 0 {
4415                return Err(fidl::Error::NonZeroPadding {
4416                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
4417                });
4418            }
4419            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49271>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.firmware, decoder, offset + 0, _depth)?;
4420            fidl::decode!(
4421                u64,
4422                fidl::encoding::DefaultFuchsiaResourceDialect,
4423                &mut self.offset,
4424                decoder,
4425                offset + 8,
4426                _depth
4427            )?;
4428            Ok(())
4429        }
4430    }
4431
4432    impl DataChannelReadResponse {
4433        #[inline(always)]
4434        fn max_ordinal_present(&self) -> u64 {
4435            if let Some(_) = self.wake_lease {
4436                return 2;
4437            }
4438            if let Some(_) = self.data {
4439                return 1;
4440            }
4441            0
4442        }
4443    }
4444
4445    impl fidl::encoding::ResourceTypeMarker for DataChannelReadResponse {
4446        type Borrowed<'a> = &'a mut Self;
4447        fn take_or_borrow<'a>(
4448            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4449        ) -> Self::Borrowed<'a> {
4450            value
4451        }
4452    }
4453
4454    unsafe impl fidl::encoding::TypeMarker for DataChannelReadResponse {
4455        type Owned = Self;
4456
4457        #[inline(always)]
4458        fn inline_align(_context: fidl::encoding::Context) -> usize {
4459            8
4460        }
4461
4462        #[inline(always)]
4463        fn inline_size(_context: fidl::encoding::Context) -> usize {
4464            16
4465        }
4466    }
4467
4468    unsafe impl
4469        fidl::encoding::Encode<
4470            DataChannelReadResponse,
4471            fidl::encoding::DefaultFuchsiaResourceDialect,
4472        > for &mut DataChannelReadResponse
4473    {
4474        unsafe fn encode(
4475            self,
4476            encoder: &mut fidl::encoding::Encoder<
4477                '_,
4478                fidl::encoding::DefaultFuchsiaResourceDialect,
4479            >,
4480            offset: usize,
4481            mut depth: fidl::encoding::Depth,
4482        ) -> fidl::Result<()> {
4483            encoder.debug_check_bounds::<DataChannelReadResponse>(offset);
4484            // Vector header
4485            let max_ordinal: u64 = self.max_ordinal_present();
4486            encoder.write_num(max_ordinal, offset);
4487            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4488            // Calling encoder.out_of_line_offset(0) is not allowed.
4489            if max_ordinal == 0 {
4490                return Ok(());
4491            }
4492            depth.increment()?;
4493            let envelope_size = 8;
4494            let bytes_len = max_ordinal as usize * envelope_size;
4495            #[allow(unused_variables)]
4496            let offset = encoder.out_of_line_offset(bytes_len);
4497            let mut _prev_end_offset: usize = 0;
4498            if 1 > max_ordinal {
4499                return Ok(());
4500            }
4501
4502            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4503            // are envelope_size bytes.
4504            let cur_offset: usize = (1 - 1) * envelope_size;
4505
4506            // Zero reserved fields.
4507            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4508
4509            // Safety:
4510            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4511            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4512            //   envelope_size bytes, there is always sufficient room.
4513            fidl::encoding::encode_in_envelope_optional::<
4514                fidl::encoding::Vector<u8, 4096>,
4515                fidl::encoding::DefaultFuchsiaResourceDialect,
4516            >(
4517                self.data.as_ref().map(
4518                    <fidl::encoding::Vector<u8, 4096> as fidl::encoding::ValueTypeMarker>::borrow,
4519                ),
4520                encoder,
4521                offset + cur_offset,
4522                depth,
4523            )?;
4524
4525            _prev_end_offset = cur_offset + envelope_size;
4526            if 2 > max_ordinal {
4527                return Ok(());
4528            }
4529
4530            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4531            // are envelope_size bytes.
4532            let cur_offset: usize = (2 - 1) * envelope_size;
4533
4534            // Zero reserved fields.
4535            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4536
4537            // Safety:
4538            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4539            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4540            //   envelope_size bytes, there is always sufficient room.
4541            fidl::encoding::encode_in_envelope_optional::<
4542                fidl::encoding::HandleType<
4543                    fidl::EventPair,
4544                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4545                    2147483648,
4546                >,
4547                fidl::encoding::DefaultFuchsiaResourceDialect,
4548            >(
4549                self.wake_lease.as_mut().map(
4550                    <fidl::encoding::HandleType<
4551                        fidl::EventPair,
4552                        { fidl::ObjectType::EVENTPAIR.into_raw() },
4553                        2147483648,
4554                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4555                ),
4556                encoder,
4557                offset + cur_offset,
4558                depth,
4559            )?;
4560
4561            _prev_end_offset = cur_offset + envelope_size;
4562
4563            Ok(())
4564        }
4565    }
4566
4567    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4568        for DataChannelReadResponse
4569    {
4570        #[inline(always)]
4571        fn new_empty() -> Self {
4572            Self::default()
4573        }
4574
4575        unsafe fn decode(
4576            &mut self,
4577            decoder: &mut fidl::encoding::Decoder<
4578                '_,
4579                fidl::encoding::DefaultFuchsiaResourceDialect,
4580            >,
4581            offset: usize,
4582            mut depth: fidl::encoding::Depth,
4583        ) -> fidl::Result<()> {
4584            decoder.debug_check_bounds::<Self>(offset);
4585            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4586                None => return Err(fidl::Error::NotNullable),
4587                Some(len) => len,
4588            };
4589            // Calling decoder.out_of_line_offset(0) is not allowed.
4590            if len == 0 {
4591                return Ok(());
4592            };
4593            depth.increment()?;
4594            let envelope_size = 8;
4595            let bytes_len = len * envelope_size;
4596            let offset = decoder.out_of_line_offset(bytes_len)?;
4597            // Decode the envelope for each type.
4598            let mut _next_ordinal_to_read = 0;
4599            let mut next_offset = offset;
4600            let end_offset = offset + bytes_len;
4601            _next_ordinal_to_read += 1;
4602            if next_offset >= end_offset {
4603                return Ok(());
4604            }
4605
4606            // Decode unknown envelopes for gaps in ordinals.
4607            while _next_ordinal_to_read < 1 {
4608                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4609                _next_ordinal_to_read += 1;
4610                next_offset += envelope_size;
4611            }
4612
4613            let next_out_of_line = decoder.next_out_of_line();
4614            let handles_before = decoder.remaining_handles();
4615            if let Some((inlined, num_bytes, num_handles)) =
4616                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4617            {
4618                let member_inline_size =
4619                    <fidl::encoding::Vector<u8, 4096> as fidl::encoding::TypeMarker>::inline_size(
4620                        decoder.context,
4621                    );
4622                if inlined != (member_inline_size <= 4) {
4623                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4624                }
4625                let inner_offset;
4626                let mut inner_depth = depth.clone();
4627                if inlined {
4628                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4629                    inner_offset = next_offset;
4630                } else {
4631                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4632                    inner_depth.increment()?;
4633                }
4634                let val_ref =
4635                self.data.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 4096>, fidl::encoding::DefaultFuchsiaResourceDialect));
4636                fidl::decode!(fidl::encoding::Vector<u8, 4096>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4637                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4638                {
4639                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4640                }
4641                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4642                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4643                }
4644            }
4645
4646            next_offset += envelope_size;
4647            _next_ordinal_to_read += 1;
4648            if next_offset >= end_offset {
4649                return Ok(());
4650            }
4651
4652            // Decode unknown envelopes for gaps in ordinals.
4653            while _next_ordinal_to_read < 2 {
4654                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4655                _next_ordinal_to_read += 1;
4656                next_offset += envelope_size;
4657            }
4658
4659            let next_out_of_line = decoder.next_out_of_line();
4660            let handles_before = decoder.remaining_handles();
4661            if let Some((inlined, num_bytes, num_handles)) =
4662                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4663            {
4664                let member_inline_size = <fidl::encoding::HandleType<
4665                    fidl::EventPair,
4666                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4667                    2147483648,
4668                > as fidl::encoding::TypeMarker>::inline_size(
4669                    decoder.context
4670                );
4671                if inlined != (member_inline_size <= 4) {
4672                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4673                }
4674                let inner_offset;
4675                let mut inner_depth = depth.clone();
4676                if inlined {
4677                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4678                    inner_offset = next_offset;
4679                } else {
4680                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4681                    inner_depth.increment()?;
4682                }
4683                let val_ref =
4684                self.wake_lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
4685                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4686                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4687                {
4688                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4689                }
4690                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4691                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4692                }
4693            }
4694
4695            next_offset += envelope_size;
4696
4697            // Decode the remaining unknown envelopes.
4698            while next_offset < end_offset {
4699                _next_ordinal_to_read += 1;
4700                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4701                next_offset += envelope_size;
4702            }
4703
4704            Ok(())
4705        }
4706    }
4707}