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 DeviceDownloadFirmwareRequest {
16    pub firmware: fidl::Vmo,
17    pub offset: u64,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for DeviceDownloadFirmwareRequest
22{
23}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct DeviceMarker;
27
28impl fidl::endpoints::ProtocolMarker for DeviceMarker {
29    type Proxy = DeviceProxy;
30    type RequestStream = DeviceRequestStream;
31    #[cfg(target_os = "fuchsia")]
32    type SynchronousProxy = DeviceSynchronousProxy;
33
34    const DEBUG_NAME: &'static str = "fuchsia.hardware.google.nanohub.Device";
35}
36impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
37pub type DeviceDownloadFirmwareResult = Result<(), i32>;
38pub type DeviceGetTimeSyncResult = Result<McuTimeSyncInfo, i32>;
39pub type DeviceSetWakeLockResult = Result<(), i32>;
40pub type DeviceGetWakeUpEventDurationResult = Result<i64, i32>;
41pub type DeviceSetWakeUpEventDurationResult = Result<(), i32>;
42pub type DeviceHardwareResetResult = Result<(), i32>;
43
44pub trait DeviceProxyInterface: Send + Sync {
45    type DownloadFirmwareResponseFut: std::future::Future<Output = Result<DeviceDownloadFirmwareResult, fidl::Error>>
46        + Send;
47    fn r#download_firmware(
48        &self,
49        firmware: fidl::Vmo,
50        offset: u64,
51    ) -> Self::DownloadFirmwareResponseFut;
52    type GetFirmwareNameResponseFut: std::future::Future<Output = Result<String, fidl::Error>>
53        + Send;
54    fn r#get_firmware_name(&self) -> Self::GetFirmwareNameResponseFut;
55    type GetFirmwareVersionResponseFut: std::future::Future<Output = Result<McuVersionInfo, fidl::Error>>
56        + Send;
57    fn r#get_firmware_version(&self) -> Self::GetFirmwareVersionResponseFut;
58    type GetTimeSyncResponseFut: std::future::Future<Output = Result<DeviceGetTimeSyncResult, fidl::Error>>
59        + Send;
60    fn r#get_time_sync(&self) -> Self::GetTimeSyncResponseFut;
61    type SetWakeLockResponseFut: std::future::Future<Output = Result<DeviceSetWakeLockResult, fidl::Error>>
62        + Send;
63    fn r#set_wake_lock(&self, value: McuWakeLockValue) -> Self::SetWakeLockResponseFut;
64    type GetWakeUpEventDurationResponseFut: std::future::Future<Output = Result<DeviceGetWakeUpEventDurationResult, fidl::Error>>
65        + Send;
66    fn r#get_wake_up_event_duration(&self) -> Self::GetWakeUpEventDurationResponseFut;
67    type SetWakeUpEventDurationResponseFut: std::future::Future<Output = Result<DeviceSetWakeUpEventDurationResult, fidl::Error>>
68        + Send;
69    fn r#set_wake_up_event_duration(
70        &self,
71        duration: i64,
72    ) -> Self::SetWakeUpEventDurationResponseFut;
73    type HardwareResetResponseFut: std::future::Future<Output = Result<DeviceHardwareResetResult, fidl::Error>>
74        + Send;
75    fn r#hardware_reset(
76        &self,
77        isp_pin_0: PinState,
78        isp_pin_1: PinState,
79        isp_pin_2: PinState,
80    ) -> Self::HardwareResetResponseFut;
81}
82#[derive(Debug)]
83#[cfg(target_os = "fuchsia")]
84pub struct DeviceSynchronousProxy {
85    client: fidl::client::sync::Client,
86}
87
88#[cfg(target_os = "fuchsia")]
89impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
90    type Proxy = DeviceProxy;
91    type Protocol = DeviceMarker;
92
93    fn from_channel(inner: fidl::Channel) -> Self {
94        Self::new(inner)
95    }
96
97    fn into_channel(self) -> fidl::Channel {
98        self.client.into_channel()
99    }
100
101    fn as_channel(&self) -> &fidl::Channel {
102        self.client.as_channel()
103    }
104}
105
106#[cfg(target_os = "fuchsia")]
107impl DeviceSynchronousProxy {
108    pub fn new(channel: fidl::Channel) -> Self {
109        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
110        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
111    }
112
113    pub fn into_channel(self) -> fidl::Channel {
114        self.client.into_channel()
115    }
116
117    /// Waits until an event arrives and returns it. It is safe for other
118    /// threads to make concurrent requests while waiting for an event.
119    pub fn wait_for_event(
120        &self,
121        deadline: zx::MonotonicInstant,
122    ) -> Result<DeviceEvent, fidl::Error> {
123        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
124    }
125
126    /// Request to sent to nanohub to load the firmware.
127    pub fn r#download_firmware(
128        &self,
129        mut firmware: fidl::Vmo,
130        mut offset: u64,
131        ___deadline: zx::MonotonicInstant,
132    ) -> Result<DeviceDownloadFirmwareResult, fidl::Error> {
133        let _response = self.client.send_query::<
134            DeviceDownloadFirmwareRequest,
135            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
136        >(
137            (firmware, offset,),
138            0x7bba8137e24661e5,
139            fidl::encoding::DynamicFlags::empty(),
140            ___deadline,
141        )?;
142        Ok(_response.map(|x| x))
143    }
144
145    /// The name of the firmware binary running on the MCU.
146    pub fn r#get_firmware_name(
147        &self,
148        ___deadline: zx::MonotonicInstant,
149    ) -> Result<String, fidl::Error> {
150        let _response =
151            self.client.send_query::<fidl::encoding::EmptyPayload, DeviceGetFirmwareNameResponse>(
152                (),
153                0x1649434b5e5bcb8d,
154                fidl::encoding::DynamicFlags::empty(),
155                ___deadline,
156            )?;
157        Ok(_response.firmware_name)
158    }
159
160    /// The version of the firmware binary running on the MCU.
161    pub fn r#get_firmware_version(
162        &self,
163        ___deadline: zx::MonotonicInstant,
164    ) -> Result<McuVersionInfo, fidl::Error> {
165        let _response = self
166            .client
167            .send_query::<fidl::encoding::EmptyPayload, DeviceGetFirmwareVersionResponse>(
168                (),
169                0x4f0599abcc95736b,
170                fidl::encoding::DynamicFlags::empty(),
171                ___deadline,
172            )?;
173        Ok(_response.version_info)
174    }
175
176    /// The time since boot recorded by the AP and the MCU.
177    pub fn r#get_time_sync(
178        &self,
179        ___deadline: zx::MonotonicInstant,
180    ) -> Result<DeviceGetTimeSyncResult, fidl::Error> {
181        let _response = self.client.send_query::<
182            fidl::encoding::EmptyPayload,
183            fidl::encoding::ResultType<McuTimeSyncInfo, i32>,
184        >(
185            (),
186            0x4406991222e3975d,
187            fidl::encoding::DynamicFlags::empty(),
188            ___deadline,
189        )?;
190        Ok(_response.map(|x| x))
191    }
192
193    /// Set an MCU wake lock request to prevent the MCU from entering a low-power state.
194    pub fn r#set_wake_lock(
195        &self,
196        mut value: McuWakeLockValue,
197        ___deadline: zx::MonotonicInstant,
198    ) -> Result<DeviceSetWakeLockResult, fidl::Error> {
199        let _response = self.client.send_query::<
200            DeviceSetWakeLockRequest,
201            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
202        >(
203            (value,),
204            0x9f83f614affa1dc,
205            fidl::encoding::DynamicFlags::empty(),
206            ___deadline,
207        )?;
208        Ok(_response.map(|x| x))
209    }
210
211    /// Get the current duration of time the MCU will remain awake.
212    pub fn r#get_wake_up_event_duration(
213        &self,
214        ___deadline: zx::MonotonicInstant,
215    ) -> Result<DeviceGetWakeUpEventDurationResult, fidl::Error> {
216        let _response = self.client.send_query::<
217            fidl::encoding::EmptyPayload,
218            fidl::encoding::ResultType<DeviceGetWakeUpEventDurationResponse, i32>,
219        >(
220            (),
221            0x45c79749f65e7176,
222            fidl::encoding::DynamicFlags::empty(),
223            ___deadline,
224        )?;
225        Ok(_response.map(|x| x.duration))
226    }
227
228    /// Set a duration of time for the MCU to remain awake.
229    pub fn r#set_wake_up_event_duration(
230        &self,
231        mut duration: i64,
232        ___deadline: zx::MonotonicInstant,
233    ) -> Result<DeviceSetWakeUpEventDurationResult, fidl::Error> {
234        let _response = self.client.send_query::<
235            DeviceSetWakeUpEventDurationRequest,
236            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
237        >(
238            (duration,),
239            0x1fa1771ffa5f570,
240            fidl::encoding::DynamicFlags::empty(),
241            ___deadline,
242        )?;
243        Ok(_response.map(|x| x))
244    }
245
246    /// Initiates a hardware reset.
247    pub fn r#hardware_reset(
248        &self,
249        mut isp_pin_0: PinState,
250        mut isp_pin_1: PinState,
251        mut isp_pin_2: PinState,
252        ___deadline: zx::MonotonicInstant,
253    ) -> Result<DeviceHardwareResetResult, fidl::Error> {
254        let _response = self.client.send_query::<
255            HardwareResetPinStates,
256            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
257        >(
258            (isp_pin_0, isp_pin_1, isp_pin_2,),
259            0x78e3d2ded2f929f,
260            fidl::encoding::DynamicFlags::empty(),
261            ___deadline,
262        )?;
263        Ok(_response.map(|x| x))
264    }
265}
266
267#[cfg(target_os = "fuchsia")]
268impl From<DeviceSynchronousProxy> for zx::Handle {
269    fn from(value: DeviceSynchronousProxy) -> Self {
270        value.into_channel().into()
271    }
272}
273
274#[cfg(target_os = "fuchsia")]
275impl From<fidl::Channel> for DeviceSynchronousProxy {
276    fn from(value: fidl::Channel) -> Self {
277        Self::new(value)
278    }
279}
280
281#[cfg(target_os = "fuchsia")]
282impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
283    type Protocol = DeviceMarker;
284
285    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
286        Self::new(value.into_channel())
287    }
288}
289
290#[derive(Debug, Clone)]
291pub struct DeviceProxy {
292    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
293}
294
295impl fidl::endpoints::Proxy for DeviceProxy {
296    type Protocol = DeviceMarker;
297
298    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
299        Self::new(inner)
300    }
301
302    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
303        self.client.into_channel().map_err(|client| Self { client })
304    }
305
306    fn as_channel(&self) -> &::fidl::AsyncChannel {
307        self.client.as_channel()
308    }
309}
310
311impl DeviceProxy {
312    /// Create a new Proxy for fuchsia.hardware.google.nanohub/Device.
313    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
314        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
315        Self { client: fidl::client::Client::new(channel, protocol_name) }
316    }
317
318    /// Get a Stream of events from the remote end of the protocol.
319    ///
320    /// # Panics
321    ///
322    /// Panics if the event stream was already taken.
323    pub fn take_event_stream(&self) -> DeviceEventStream {
324        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
325    }
326
327    /// Request to sent to nanohub to load the firmware.
328    pub fn r#download_firmware(
329        &self,
330        mut firmware: fidl::Vmo,
331        mut offset: u64,
332    ) -> fidl::client::QueryResponseFut<
333        DeviceDownloadFirmwareResult,
334        fidl::encoding::DefaultFuchsiaResourceDialect,
335    > {
336        DeviceProxyInterface::r#download_firmware(self, firmware, offset)
337    }
338
339    /// The name of the firmware binary running on the MCU.
340    pub fn r#get_firmware_name(
341        &self,
342    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
343        DeviceProxyInterface::r#get_firmware_name(self)
344    }
345
346    /// The version of the firmware binary running on the MCU.
347    pub fn r#get_firmware_version(
348        &self,
349    ) -> fidl::client::QueryResponseFut<McuVersionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
350    {
351        DeviceProxyInterface::r#get_firmware_version(self)
352    }
353
354    /// The time since boot recorded by the AP and the MCU.
355    pub fn r#get_time_sync(
356        &self,
357    ) -> fidl::client::QueryResponseFut<
358        DeviceGetTimeSyncResult,
359        fidl::encoding::DefaultFuchsiaResourceDialect,
360    > {
361        DeviceProxyInterface::r#get_time_sync(self)
362    }
363
364    /// Set an MCU wake lock request to prevent the MCU from entering a low-power state.
365    pub fn r#set_wake_lock(
366        &self,
367        mut value: McuWakeLockValue,
368    ) -> fidl::client::QueryResponseFut<
369        DeviceSetWakeLockResult,
370        fidl::encoding::DefaultFuchsiaResourceDialect,
371    > {
372        DeviceProxyInterface::r#set_wake_lock(self, value)
373    }
374
375    /// Get the current duration of time the MCU will remain awake.
376    pub fn r#get_wake_up_event_duration(
377        &self,
378    ) -> fidl::client::QueryResponseFut<
379        DeviceGetWakeUpEventDurationResult,
380        fidl::encoding::DefaultFuchsiaResourceDialect,
381    > {
382        DeviceProxyInterface::r#get_wake_up_event_duration(self)
383    }
384
385    /// Set a duration of time for the MCU to remain awake.
386    pub fn r#set_wake_up_event_duration(
387        &self,
388        mut duration: i64,
389    ) -> fidl::client::QueryResponseFut<
390        DeviceSetWakeUpEventDurationResult,
391        fidl::encoding::DefaultFuchsiaResourceDialect,
392    > {
393        DeviceProxyInterface::r#set_wake_up_event_duration(self, duration)
394    }
395
396    /// Initiates a hardware reset.
397    pub fn r#hardware_reset(
398        &self,
399        mut isp_pin_0: PinState,
400        mut isp_pin_1: PinState,
401        mut isp_pin_2: PinState,
402    ) -> fidl::client::QueryResponseFut<
403        DeviceHardwareResetResult,
404        fidl::encoding::DefaultFuchsiaResourceDialect,
405    > {
406        DeviceProxyInterface::r#hardware_reset(self, isp_pin_0, isp_pin_1, isp_pin_2)
407    }
408}
409
410impl DeviceProxyInterface for DeviceProxy {
411    type DownloadFirmwareResponseFut = fidl::client::QueryResponseFut<
412        DeviceDownloadFirmwareResult,
413        fidl::encoding::DefaultFuchsiaResourceDialect,
414    >;
415    fn r#download_firmware(
416        &self,
417        mut firmware: fidl::Vmo,
418        mut offset: u64,
419    ) -> Self::DownloadFirmwareResponseFut {
420        fn _decode(
421            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
422        ) -> Result<DeviceDownloadFirmwareResult, fidl::Error> {
423            let _response = fidl::client::decode_transaction_body::<
424                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
425                fidl::encoding::DefaultFuchsiaResourceDialect,
426                0x7bba8137e24661e5,
427            >(_buf?)?;
428            Ok(_response.map(|x| x))
429        }
430        self.client
431            .send_query_and_decode::<DeviceDownloadFirmwareRequest, DeviceDownloadFirmwareResult>(
432                (firmware, offset),
433                0x7bba8137e24661e5,
434                fidl::encoding::DynamicFlags::empty(),
435                _decode,
436            )
437    }
438
439    type GetFirmwareNameResponseFut =
440        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
441    fn r#get_firmware_name(&self) -> Self::GetFirmwareNameResponseFut {
442        fn _decode(
443            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
444        ) -> Result<String, fidl::Error> {
445            let _response = fidl::client::decode_transaction_body::<
446                DeviceGetFirmwareNameResponse,
447                fidl::encoding::DefaultFuchsiaResourceDialect,
448                0x1649434b5e5bcb8d,
449            >(_buf?)?;
450            Ok(_response.firmware_name)
451        }
452        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
453            (),
454            0x1649434b5e5bcb8d,
455            fidl::encoding::DynamicFlags::empty(),
456            _decode,
457        )
458    }
459
460    type GetFirmwareVersionResponseFut = fidl::client::QueryResponseFut<
461        McuVersionInfo,
462        fidl::encoding::DefaultFuchsiaResourceDialect,
463    >;
464    fn r#get_firmware_version(&self) -> Self::GetFirmwareVersionResponseFut {
465        fn _decode(
466            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
467        ) -> Result<McuVersionInfo, fidl::Error> {
468            let _response = fidl::client::decode_transaction_body::<
469                DeviceGetFirmwareVersionResponse,
470                fidl::encoding::DefaultFuchsiaResourceDialect,
471                0x4f0599abcc95736b,
472            >(_buf?)?;
473            Ok(_response.version_info)
474        }
475        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, McuVersionInfo>(
476            (),
477            0x4f0599abcc95736b,
478            fidl::encoding::DynamicFlags::empty(),
479            _decode,
480        )
481    }
482
483    type GetTimeSyncResponseFut = fidl::client::QueryResponseFut<
484        DeviceGetTimeSyncResult,
485        fidl::encoding::DefaultFuchsiaResourceDialect,
486    >;
487    fn r#get_time_sync(&self) -> Self::GetTimeSyncResponseFut {
488        fn _decode(
489            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
490        ) -> Result<DeviceGetTimeSyncResult, fidl::Error> {
491            let _response = fidl::client::decode_transaction_body::<
492                fidl::encoding::ResultType<McuTimeSyncInfo, i32>,
493                fidl::encoding::DefaultFuchsiaResourceDialect,
494                0x4406991222e3975d,
495            >(_buf?)?;
496            Ok(_response.map(|x| x))
497        }
498        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetTimeSyncResult>(
499            (),
500            0x4406991222e3975d,
501            fidl::encoding::DynamicFlags::empty(),
502            _decode,
503        )
504    }
505
506    type SetWakeLockResponseFut = fidl::client::QueryResponseFut<
507        DeviceSetWakeLockResult,
508        fidl::encoding::DefaultFuchsiaResourceDialect,
509    >;
510    fn r#set_wake_lock(&self, mut value: McuWakeLockValue) -> Self::SetWakeLockResponseFut {
511        fn _decode(
512            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
513        ) -> Result<DeviceSetWakeLockResult, fidl::Error> {
514            let _response = fidl::client::decode_transaction_body::<
515                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
516                fidl::encoding::DefaultFuchsiaResourceDialect,
517                0x9f83f614affa1dc,
518            >(_buf?)?;
519            Ok(_response.map(|x| x))
520        }
521        self.client.send_query_and_decode::<DeviceSetWakeLockRequest, DeviceSetWakeLockResult>(
522            (value,),
523            0x9f83f614affa1dc,
524            fidl::encoding::DynamicFlags::empty(),
525            _decode,
526        )
527    }
528
529    type GetWakeUpEventDurationResponseFut = fidl::client::QueryResponseFut<
530        DeviceGetWakeUpEventDurationResult,
531        fidl::encoding::DefaultFuchsiaResourceDialect,
532    >;
533    fn r#get_wake_up_event_duration(&self) -> Self::GetWakeUpEventDurationResponseFut {
534        fn _decode(
535            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
536        ) -> Result<DeviceGetWakeUpEventDurationResult, fidl::Error> {
537            let _response = fidl::client::decode_transaction_body::<
538                fidl::encoding::ResultType<DeviceGetWakeUpEventDurationResponse, i32>,
539                fidl::encoding::DefaultFuchsiaResourceDialect,
540                0x45c79749f65e7176,
541            >(_buf?)?;
542            Ok(_response.map(|x| x.duration))
543        }
544        self.client.send_query_and_decode::<
545            fidl::encoding::EmptyPayload,
546            DeviceGetWakeUpEventDurationResult,
547        >(
548            (),
549            0x45c79749f65e7176,
550            fidl::encoding::DynamicFlags::empty(),
551            _decode,
552        )
553    }
554
555    type SetWakeUpEventDurationResponseFut = fidl::client::QueryResponseFut<
556        DeviceSetWakeUpEventDurationResult,
557        fidl::encoding::DefaultFuchsiaResourceDialect,
558    >;
559    fn r#set_wake_up_event_duration(
560        &self,
561        mut duration: i64,
562    ) -> Self::SetWakeUpEventDurationResponseFut {
563        fn _decode(
564            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
565        ) -> Result<DeviceSetWakeUpEventDurationResult, fidl::Error> {
566            let _response = fidl::client::decode_transaction_body::<
567                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
568                fidl::encoding::DefaultFuchsiaResourceDialect,
569                0x1fa1771ffa5f570,
570            >(_buf?)?;
571            Ok(_response.map(|x| x))
572        }
573        self.client.send_query_and_decode::<
574            DeviceSetWakeUpEventDurationRequest,
575            DeviceSetWakeUpEventDurationResult,
576        >(
577            (duration,),
578            0x1fa1771ffa5f570,
579            fidl::encoding::DynamicFlags::empty(),
580            _decode,
581        )
582    }
583
584    type HardwareResetResponseFut = fidl::client::QueryResponseFut<
585        DeviceHardwareResetResult,
586        fidl::encoding::DefaultFuchsiaResourceDialect,
587    >;
588    fn r#hardware_reset(
589        &self,
590        mut isp_pin_0: PinState,
591        mut isp_pin_1: PinState,
592        mut isp_pin_2: PinState,
593    ) -> Self::HardwareResetResponseFut {
594        fn _decode(
595            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
596        ) -> Result<DeviceHardwareResetResult, fidl::Error> {
597            let _response = fidl::client::decode_transaction_body::<
598                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
599                fidl::encoding::DefaultFuchsiaResourceDialect,
600                0x78e3d2ded2f929f,
601            >(_buf?)?;
602            Ok(_response.map(|x| x))
603        }
604        self.client.send_query_and_decode::<HardwareResetPinStates, DeviceHardwareResetResult>(
605            (isp_pin_0, isp_pin_1, isp_pin_2),
606            0x78e3d2ded2f929f,
607            fidl::encoding::DynamicFlags::empty(),
608            _decode,
609        )
610    }
611}
612
613pub struct DeviceEventStream {
614    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
615}
616
617impl std::marker::Unpin for DeviceEventStream {}
618
619impl futures::stream::FusedStream for DeviceEventStream {
620    fn is_terminated(&self) -> bool {
621        self.event_receiver.is_terminated()
622    }
623}
624
625impl futures::Stream for DeviceEventStream {
626    type Item = Result<DeviceEvent, fidl::Error>;
627
628    fn poll_next(
629        mut self: std::pin::Pin<&mut Self>,
630        cx: &mut std::task::Context<'_>,
631    ) -> std::task::Poll<Option<Self::Item>> {
632        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
633            &mut self.event_receiver,
634            cx
635        )?) {
636            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
637            None => std::task::Poll::Ready(None),
638        }
639    }
640}
641
642#[derive(Debug)]
643pub enum DeviceEvent {
644    #[non_exhaustive]
645    _UnknownEvent {
646        /// Ordinal of the event that was sent.
647        ordinal: u64,
648    },
649}
650
651impl DeviceEvent {
652    /// Decodes a message buffer as a [`DeviceEvent`].
653    fn decode(
654        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
655    ) -> Result<DeviceEvent, fidl::Error> {
656        let (bytes, _handles) = buf.split_mut();
657        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
658        debug_assert_eq!(tx_header.tx_id, 0);
659        match tx_header.ordinal {
660            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
661                Ok(DeviceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
662            }
663            _ => Err(fidl::Error::UnknownOrdinal {
664                ordinal: tx_header.ordinal,
665                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
666            }),
667        }
668    }
669}
670
671/// A Stream of incoming requests for fuchsia.hardware.google.nanohub/Device.
672pub struct DeviceRequestStream {
673    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
674    is_terminated: bool,
675}
676
677impl std::marker::Unpin for DeviceRequestStream {}
678
679impl futures::stream::FusedStream for DeviceRequestStream {
680    fn is_terminated(&self) -> bool {
681        self.is_terminated
682    }
683}
684
685impl fidl::endpoints::RequestStream for DeviceRequestStream {
686    type Protocol = DeviceMarker;
687    type ControlHandle = DeviceControlHandle;
688
689    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
690        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
691    }
692
693    fn control_handle(&self) -> Self::ControlHandle {
694        DeviceControlHandle { inner: self.inner.clone() }
695    }
696
697    fn into_inner(
698        self,
699    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
700    {
701        (self.inner, self.is_terminated)
702    }
703
704    fn from_inner(
705        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
706        is_terminated: bool,
707    ) -> Self {
708        Self { inner, is_terminated }
709    }
710}
711
712impl futures::Stream for DeviceRequestStream {
713    type Item = Result<DeviceRequest, fidl::Error>;
714
715    fn poll_next(
716        mut self: std::pin::Pin<&mut Self>,
717        cx: &mut std::task::Context<'_>,
718    ) -> std::task::Poll<Option<Self::Item>> {
719        let this = &mut *self;
720        if this.inner.check_shutdown(cx) {
721            this.is_terminated = true;
722            return std::task::Poll::Ready(None);
723        }
724        if this.is_terminated {
725            panic!("polled DeviceRequestStream after completion");
726        }
727        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
728            |bytes, handles| {
729                match this.inner.channel().read_etc(cx, bytes, handles) {
730                    std::task::Poll::Ready(Ok(())) => {}
731                    std::task::Poll::Pending => return std::task::Poll::Pending,
732                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
733                        this.is_terminated = true;
734                        return std::task::Poll::Ready(None);
735                    }
736                    std::task::Poll::Ready(Err(e)) => {
737                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
738                            e.into(),
739                        ))))
740                    }
741                }
742
743                // A message has been received from the channel
744                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
745
746                std::task::Poll::Ready(Some(match header.ordinal {
747                    0x7bba8137e24661e5 => {
748                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
749                        let mut req = fidl::new_empty!(
750                            DeviceDownloadFirmwareRequest,
751                            fidl::encoding::DefaultFuchsiaResourceDialect
752                        );
753                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceDownloadFirmwareRequest>(&header, _body_bytes, handles, &mut req)?;
754                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
755                        Ok(DeviceRequest::DownloadFirmware {
756                            firmware: req.firmware,
757                            offset: req.offset,
758
759                            responder: DeviceDownloadFirmwareResponder {
760                                control_handle: std::mem::ManuallyDrop::new(control_handle),
761                                tx_id: header.tx_id,
762                            },
763                        })
764                    }
765                    0x1649434b5e5bcb8d => {
766                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
767                        let mut req = fidl::new_empty!(
768                            fidl::encoding::EmptyPayload,
769                            fidl::encoding::DefaultFuchsiaResourceDialect
770                        );
771                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
772                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
773                        Ok(DeviceRequest::GetFirmwareName {
774                            responder: DeviceGetFirmwareNameResponder {
775                                control_handle: std::mem::ManuallyDrop::new(control_handle),
776                                tx_id: header.tx_id,
777                            },
778                        })
779                    }
780                    0x4f0599abcc95736b => {
781                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
782                        let mut req = fidl::new_empty!(
783                            fidl::encoding::EmptyPayload,
784                            fidl::encoding::DefaultFuchsiaResourceDialect
785                        );
786                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
787                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
788                        Ok(DeviceRequest::GetFirmwareVersion {
789                            responder: DeviceGetFirmwareVersionResponder {
790                                control_handle: std::mem::ManuallyDrop::new(control_handle),
791                                tx_id: header.tx_id,
792                            },
793                        })
794                    }
795                    0x4406991222e3975d => {
796                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
797                        let mut req = fidl::new_empty!(
798                            fidl::encoding::EmptyPayload,
799                            fidl::encoding::DefaultFuchsiaResourceDialect
800                        );
801                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
802                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
803                        Ok(DeviceRequest::GetTimeSync {
804                            responder: DeviceGetTimeSyncResponder {
805                                control_handle: std::mem::ManuallyDrop::new(control_handle),
806                                tx_id: header.tx_id,
807                            },
808                        })
809                    }
810                    0x9f83f614affa1dc => {
811                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
812                        let mut req = fidl::new_empty!(
813                            DeviceSetWakeLockRequest,
814                            fidl::encoding::DefaultFuchsiaResourceDialect
815                        );
816                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetWakeLockRequest>(&header, _body_bytes, handles, &mut req)?;
817                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
818                        Ok(DeviceRequest::SetWakeLock {
819                            value: req.value,
820
821                            responder: DeviceSetWakeLockResponder {
822                                control_handle: std::mem::ManuallyDrop::new(control_handle),
823                                tx_id: header.tx_id,
824                            },
825                        })
826                    }
827                    0x45c79749f65e7176 => {
828                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
829                        let mut req = fidl::new_empty!(
830                            fidl::encoding::EmptyPayload,
831                            fidl::encoding::DefaultFuchsiaResourceDialect
832                        );
833                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
834                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
835                        Ok(DeviceRequest::GetWakeUpEventDuration {
836                            responder: DeviceGetWakeUpEventDurationResponder {
837                                control_handle: std::mem::ManuallyDrop::new(control_handle),
838                                tx_id: header.tx_id,
839                            },
840                        })
841                    }
842                    0x1fa1771ffa5f570 => {
843                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
844                        let mut req = fidl::new_empty!(
845                            DeviceSetWakeUpEventDurationRequest,
846                            fidl::encoding::DefaultFuchsiaResourceDialect
847                        );
848                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetWakeUpEventDurationRequest>(&header, _body_bytes, handles, &mut req)?;
849                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
850                        Ok(DeviceRequest::SetWakeUpEventDuration {
851                            duration: req.duration,
852
853                            responder: DeviceSetWakeUpEventDurationResponder {
854                                control_handle: std::mem::ManuallyDrop::new(control_handle),
855                                tx_id: header.tx_id,
856                            },
857                        })
858                    }
859                    0x78e3d2ded2f929f => {
860                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
861                        let mut req = fidl::new_empty!(
862                            HardwareResetPinStates,
863                            fidl::encoding::DefaultFuchsiaResourceDialect
864                        );
865                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HardwareResetPinStates>(&header, _body_bytes, handles, &mut req)?;
866                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
867                        Ok(DeviceRequest::HardwareReset {
868                            isp_pin_0: req.isp_pin_0,
869                            isp_pin_1: req.isp_pin_1,
870                            isp_pin_2: req.isp_pin_2,
871
872                            responder: DeviceHardwareResetResponder {
873                                control_handle: std::mem::ManuallyDrop::new(control_handle),
874                                tx_id: header.tx_id,
875                            },
876                        })
877                    }
878                    _ if header.tx_id == 0
879                        && header
880                            .dynamic_flags()
881                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
882                    {
883                        Ok(DeviceRequest::_UnknownMethod {
884                            ordinal: header.ordinal,
885                            control_handle: DeviceControlHandle { inner: this.inner.clone() },
886                            method_type: fidl::MethodType::OneWay,
887                        })
888                    }
889                    _ if header
890                        .dynamic_flags()
891                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
892                    {
893                        this.inner.send_framework_err(
894                            fidl::encoding::FrameworkErr::UnknownMethod,
895                            header.tx_id,
896                            header.ordinal,
897                            header.dynamic_flags(),
898                            (bytes, handles),
899                        )?;
900                        Ok(DeviceRequest::_UnknownMethod {
901                            ordinal: header.ordinal,
902                            control_handle: DeviceControlHandle { inner: this.inner.clone() },
903                            method_type: fidl::MethodType::TwoWay,
904                        })
905                    }
906                    _ => Err(fidl::Error::UnknownOrdinal {
907                        ordinal: header.ordinal,
908                        protocol_name:
909                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
910                    }),
911                }))
912            },
913        )
914    }
915}
916
917/// Client is expected to pass the vmo handle to nanohub when issuing a DownloadFirmware request.
918#[derive(Debug)]
919pub enum DeviceRequest {
920    /// Request to sent to nanohub to load the firmware.
921    DownloadFirmware {
922        firmware: fidl::Vmo,
923        offset: u64,
924        responder: DeviceDownloadFirmwareResponder,
925    },
926    /// The name of the firmware binary running on the MCU.
927    GetFirmwareName { responder: DeviceGetFirmwareNameResponder },
928    /// The version of the firmware binary running on the MCU.
929    GetFirmwareVersion { responder: DeviceGetFirmwareVersionResponder },
930    /// The time since boot recorded by the AP and the MCU.
931    GetTimeSync { responder: DeviceGetTimeSyncResponder },
932    /// Set an MCU wake lock request to prevent the MCU from entering a low-power state.
933    SetWakeLock { value: McuWakeLockValue, responder: DeviceSetWakeLockResponder },
934    /// Get the current duration of time the MCU will remain awake.
935    GetWakeUpEventDuration { responder: DeviceGetWakeUpEventDurationResponder },
936    /// Set a duration of time for the MCU to remain awake.
937    SetWakeUpEventDuration { duration: i64, responder: DeviceSetWakeUpEventDurationResponder },
938    /// Initiates a hardware reset.
939    HardwareReset {
940        isp_pin_0: PinState,
941        isp_pin_1: PinState,
942        isp_pin_2: PinState,
943        responder: DeviceHardwareResetResponder,
944    },
945    /// An interaction was received which does not match any known method.
946    #[non_exhaustive]
947    _UnknownMethod {
948        /// Ordinal of the method that was called.
949        ordinal: u64,
950        control_handle: DeviceControlHandle,
951        method_type: fidl::MethodType,
952    },
953}
954
955impl DeviceRequest {
956    #[allow(irrefutable_let_patterns)]
957    pub fn into_download_firmware(
958        self,
959    ) -> Option<(fidl::Vmo, u64, DeviceDownloadFirmwareResponder)> {
960        if let DeviceRequest::DownloadFirmware { firmware, offset, responder } = self {
961            Some((firmware, offset, responder))
962        } else {
963            None
964        }
965    }
966
967    #[allow(irrefutable_let_patterns)]
968    pub fn into_get_firmware_name(self) -> Option<(DeviceGetFirmwareNameResponder)> {
969        if let DeviceRequest::GetFirmwareName { responder } = self {
970            Some((responder))
971        } else {
972            None
973        }
974    }
975
976    #[allow(irrefutable_let_patterns)]
977    pub fn into_get_firmware_version(self) -> Option<(DeviceGetFirmwareVersionResponder)> {
978        if let DeviceRequest::GetFirmwareVersion { responder } = self {
979            Some((responder))
980        } else {
981            None
982        }
983    }
984
985    #[allow(irrefutable_let_patterns)]
986    pub fn into_get_time_sync(self) -> Option<(DeviceGetTimeSyncResponder)> {
987        if let DeviceRequest::GetTimeSync { responder } = self {
988            Some((responder))
989        } else {
990            None
991        }
992    }
993
994    #[allow(irrefutable_let_patterns)]
995    pub fn into_set_wake_lock(self) -> Option<(McuWakeLockValue, DeviceSetWakeLockResponder)> {
996        if let DeviceRequest::SetWakeLock { value, responder } = self {
997            Some((value, responder))
998        } else {
999            None
1000        }
1001    }
1002
1003    #[allow(irrefutable_let_patterns)]
1004    pub fn into_get_wake_up_event_duration(
1005        self,
1006    ) -> Option<(DeviceGetWakeUpEventDurationResponder)> {
1007        if let DeviceRequest::GetWakeUpEventDuration { responder } = self {
1008            Some((responder))
1009        } else {
1010            None
1011        }
1012    }
1013
1014    #[allow(irrefutable_let_patterns)]
1015    pub fn into_set_wake_up_event_duration(
1016        self,
1017    ) -> Option<(i64, DeviceSetWakeUpEventDurationResponder)> {
1018        if let DeviceRequest::SetWakeUpEventDuration { duration, responder } = self {
1019            Some((duration, responder))
1020        } else {
1021            None
1022        }
1023    }
1024
1025    #[allow(irrefutable_let_patterns)]
1026    pub fn into_hardware_reset(
1027        self,
1028    ) -> Option<(PinState, PinState, PinState, DeviceHardwareResetResponder)> {
1029        if let DeviceRequest::HardwareReset { isp_pin_0, isp_pin_1, isp_pin_2, responder } = self {
1030            Some((isp_pin_0, isp_pin_1, isp_pin_2, responder))
1031        } else {
1032            None
1033        }
1034    }
1035
1036    /// Name of the method defined in FIDL
1037    pub fn method_name(&self) -> &'static str {
1038        match *self {
1039            DeviceRequest::DownloadFirmware { .. } => "download_firmware",
1040            DeviceRequest::GetFirmwareName { .. } => "get_firmware_name",
1041            DeviceRequest::GetFirmwareVersion { .. } => "get_firmware_version",
1042            DeviceRequest::GetTimeSync { .. } => "get_time_sync",
1043            DeviceRequest::SetWakeLock { .. } => "set_wake_lock",
1044            DeviceRequest::GetWakeUpEventDuration { .. } => "get_wake_up_event_duration",
1045            DeviceRequest::SetWakeUpEventDuration { .. } => "set_wake_up_event_duration",
1046            DeviceRequest::HardwareReset { .. } => "hardware_reset",
1047            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1048                "unknown one-way method"
1049            }
1050            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1051                "unknown two-way method"
1052            }
1053        }
1054    }
1055}
1056
1057#[derive(Debug, Clone)]
1058pub struct DeviceControlHandle {
1059    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1060}
1061
1062impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1063    fn shutdown(&self) {
1064        self.inner.shutdown()
1065    }
1066    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1067        self.inner.shutdown_with_epitaph(status)
1068    }
1069
1070    fn is_closed(&self) -> bool {
1071        self.inner.channel().is_closed()
1072    }
1073    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1074        self.inner.channel().on_closed()
1075    }
1076
1077    #[cfg(target_os = "fuchsia")]
1078    fn signal_peer(
1079        &self,
1080        clear_mask: zx::Signals,
1081        set_mask: zx::Signals,
1082    ) -> Result<(), zx_status::Status> {
1083        use fidl::Peered;
1084        self.inner.channel().signal_peer(clear_mask, set_mask)
1085    }
1086}
1087
1088impl DeviceControlHandle {}
1089
1090#[must_use = "FIDL methods require a response to be sent"]
1091#[derive(Debug)]
1092pub struct DeviceDownloadFirmwareResponder {
1093    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1094    tx_id: u32,
1095}
1096
1097/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1098/// if the responder is dropped without sending a response, so that the client
1099/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1100impl std::ops::Drop for DeviceDownloadFirmwareResponder {
1101    fn drop(&mut self) {
1102        self.control_handle.shutdown();
1103        // Safety: drops once, never accessed again
1104        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1105    }
1106}
1107
1108impl fidl::endpoints::Responder for DeviceDownloadFirmwareResponder {
1109    type ControlHandle = DeviceControlHandle;
1110
1111    fn control_handle(&self) -> &DeviceControlHandle {
1112        &self.control_handle
1113    }
1114
1115    fn drop_without_shutdown(mut self) {
1116        // Safety: drops once, never accessed again due to mem::forget
1117        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1118        // Prevent Drop from running (which would shut down the channel)
1119        std::mem::forget(self);
1120    }
1121}
1122
1123impl DeviceDownloadFirmwareResponder {
1124    /// Sends a response to the FIDL transaction.
1125    ///
1126    /// Sets the channel to shutdown if an error occurs.
1127    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1128        let _result = self.send_raw(result);
1129        if _result.is_err() {
1130            self.control_handle.shutdown();
1131        }
1132        self.drop_without_shutdown();
1133        _result
1134    }
1135
1136    /// Similar to "send" but does not shutdown the channel if an error occurs.
1137    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1138        let _result = self.send_raw(result);
1139        self.drop_without_shutdown();
1140        _result
1141    }
1142
1143    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1144        self.control_handle
1145            .inner
1146            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1147                result,
1148                self.tx_id,
1149                0x7bba8137e24661e5,
1150                fidl::encoding::DynamicFlags::empty(),
1151            )
1152    }
1153}
1154
1155#[must_use = "FIDL methods require a response to be sent"]
1156#[derive(Debug)]
1157pub struct DeviceGetFirmwareNameResponder {
1158    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1159    tx_id: u32,
1160}
1161
1162/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1163/// if the responder is dropped without sending a response, so that the client
1164/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1165impl std::ops::Drop for DeviceGetFirmwareNameResponder {
1166    fn drop(&mut self) {
1167        self.control_handle.shutdown();
1168        // Safety: drops once, never accessed again
1169        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1170    }
1171}
1172
1173impl fidl::endpoints::Responder for DeviceGetFirmwareNameResponder {
1174    type ControlHandle = DeviceControlHandle;
1175
1176    fn control_handle(&self) -> &DeviceControlHandle {
1177        &self.control_handle
1178    }
1179
1180    fn drop_without_shutdown(mut self) {
1181        // Safety: drops once, never accessed again due to mem::forget
1182        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1183        // Prevent Drop from running (which would shut down the channel)
1184        std::mem::forget(self);
1185    }
1186}
1187
1188impl DeviceGetFirmwareNameResponder {
1189    /// Sends a response to the FIDL transaction.
1190    ///
1191    /// Sets the channel to shutdown if an error occurs.
1192    pub fn send(self, mut firmware_name: &str) -> Result<(), fidl::Error> {
1193        let _result = self.send_raw(firmware_name);
1194        if _result.is_err() {
1195            self.control_handle.shutdown();
1196        }
1197        self.drop_without_shutdown();
1198        _result
1199    }
1200
1201    /// Similar to "send" but does not shutdown the channel if an error occurs.
1202    pub fn send_no_shutdown_on_err(self, mut firmware_name: &str) -> Result<(), fidl::Error> {
1203        let _result = self.send_raw(firmware_name);
1204        self.drop_without_shutdown();
1205        _result
1206    }
1207
1208    fn send_raw(&self, mut firmware_name: &str) -> Result<(), fidl::Error> {
1209        self.control_handle.inner.send::<DeviceGetFirmwareNameResponse>(
1210            (firmware_name,),
1211            self.tx_id,
1212            0x1649434b5e5bcb8d,
1213            fidl::encoding::DynamicFlags::empty(),
1214        )
1215    }
1216}
1217
1218#[must_use = "FIDL methods require a response to be sent"]
1219#[derive(Debug)]
1220pub struct DeviceGetFirmwareVersionResponder {
1221    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1222    tx_id: u32,
1223}
1224
1225/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1226/// if the responder is dropped without sending a response, so that the client
1227/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1228impl std::ops::Drop for DeviceGetFirmwareVersionResponder {
1229    fn drop(&mut self) {
1230        self.control_handle.shutdown();
1231        // Safety: drops once, never accessed again
1232        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1233    }
1234}
1235
1236impl fidl::endpoints::Responder for DeviceGetFirmwareVersionResponder {
1237    type ControlHandle = DeviceControlHandle;
1238
1239    fn control_handle(&self) -> &DeviceControlHandle {
1240        &self.control_handle
1241    }
1242
1243    fn drop_without_shutdown(mut self) {
1244        // Safety: drops once, never accessed again due to mem::forget
1245        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1246        // Prevent Drop from running (which would shut down the channel)
1247        std::mem::forget(self);
1248    }
1249}
1250
1251impl DeviceGetFirmwareVersionResponder {
1252    /// Sends a response to the FIDL transaction.
1253    ///
1254    /// Sets the channel to shutdown if an error occurs.
1255    pub fn send(self, mut version_info: &McuVersionInfo) -> Result<(), fidl::Error> {
1256        let _result = self.send_raw(version_info);
1257        if _result.is_err() {
1258            self.control_handle.shutdown();
1259        }
1260        self.drop_without_shutdown();
1261        _result
1262    }
1263
1264    /// Similar to "send" but does not shutdown the channel if an error occurs.
1265    pub fn send_no_shutdown_on_err(
1266        self,
1267        mut version_info: &McuVersionInfo,
1268    ) -> Result<(), fidl::Error> {
1269        let _result = self.send_raw(version_info);
1270        self.drop_without_shutdown();
1271        _result
1272    }
1273
1274    fn send_raw(&self, mut version_info: &McuVersionInfo) -> Result<(), fidl::Error> {
1275        self.control_handle.inner.send::<DeviceGetFirmwareVersionResponse>(
1276            (version_info,),
1277            self.tx_id,
1278            0x4f0599abcc95736b,
1279            fidl::encoding::DynamicFlags::empty(),
1280        )
1281    }
1282}
1283
1284#[must_use = "FIDL methods require a response to be sent"]
1285#[derive(Debug)]
1286pub struct DeviceGetTimeSyncResponder {
1287    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1288    tx_id: u32,
1289}
1290
1291/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1292/// if the responder is dropped without sending a response, so that the client
1293/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1294impl std::ops::Drop for DeviceGetTimeSyncResponder {
1295    fn drop(&mut self) {
1296        self.control_handle.shutdown();
1297        // Safety: drops once, never accessed again
1298        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1299    }
1300}
1301
1302impl fidl::endpoints::Responder for DeviceGetTimeSyncResponder {
1303    type ControlHandle = DeviceControlHandle;
1304
1305    fn control_handle(&self) -> &DeviceControlHandle {
1306        &self.control_handle
1307    }
1308
1309    fn drop_without_shutdown(mut self) {
1310        // Safety: drops once, never accessed again due to mem::forget
1311        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1312        // Prevent Drop from running (which would shut down the channel)
1313        std::mem::forget(self);
1314    }
1315}
1316
1317impl DeviceGetTimeSyncResponder {
1318    /// Sends a response to the FIDL transaction.
1319    ///
1320    /// Sets the channel to shutdown if an error occurs.
1321    pub fn send(self, mut result: Result<&McuTimeSyncInfo, i32>) -> Result<(), fidl::Error> {
1322        let _result = self.send_raw(result);
1323        if _result.is_err() {
1324            self.control_handle.shutdown();
1325        }
1326        self.drop_without_shutdown();
1327        _result
1328    }
1329
1330    /// Similar to "send" but does not shutdown the channel if an error occurs.
1331    pub fn send_no_shutdown_on_err(
1332        self,
1333        mut result: Result<&McuTimeSyncInfo, i32>,
1334    ) -> Result<(), fidl::Error> {
1335        let _result = self.send_raw(result);
1336        self.drop_without_shutdown();
1337        _result
1338    }
1339
1340    fn send_raw(&self, mut result: Result<&McuTimeSyncInfo, i32>) -> Result<(), fidl::Error> {
1341        self.control_handle.inner.send::<fidl::encoding::ResultType<McuTimeSyncInfo, i32>>(
1342            result,
1343            self.tx_id,
1344            0x4406991222e3975d,
1345            fidl::encoding::DynamicFlags::empty(),
1346        )
1347    }
1348}
1349
1350#[must_use = "FIDL methods require a response to be sent"]
1351#[derive(Debug)]
1352pub struct DeviceSetWakeLockResponder {
1353    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1354    tx_id: u32,
1355}
1356
1357/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1358/// if the responder is dropped without sending a response, so that the client
1359/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1360impl std::ops::Drop for DeviceSetWakeLockResponder {
1361    fn drop(&mut self) {
1362        self.control_handle.shutdown();
1363        // Safety: drops once, never accessed again
1364        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1365    }
1366}
1367
1368impl fidl::endpoints::Responder for DeviceSetWakeLockResponder {
1369    type ControlHandle = DeviceControlHandle;
1370
1371    fn control_handle(&self) -> &DeviceControlHandle {
1372        &self.control_handle
1373    }
1374
1375    fn drop_without_shutdown(mut self) {
1376        // Safety: drops once, never accessed again due to mem::forget
1377        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1378        // Prevent Drop from running (which would shut down the channel)
1379        std::mem::forget(self);
1380    }
1381}
1382
1383impl DeviceSetWakeLockResponder {
1384    /// Sends a response to the FIDL transaction.
1385    ///
1386    /// Sets the channel to shutdown if an error occurs.
1387    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1388        let _result = self.send_raw(result);
1389        if _result.is_err() {
1390            self.control_handle.shutdown();
1391        }
1392        self.drop_without_shutdown();
1393        _result
1394    }
1395
1396    /// Similar to "send" but does not shutdown the channel if an error occurs.
1397    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1398        let _result = self.send_raw(result);
1399        self.drop_without_shutdown();
1400        _result
1401    }
1402
1403    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1404        self.control_handle
1405            .inner
1406            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1407                result,
1408                self.tx_id,
1409                0x9f83f614affa1dc,
1410                fidl::encoding::DynamicFlags::empty(),
1411            )
1412    }
1413}
1414
1415#[must_use = "FIDL methods require a response to be sent"]
1416#[derive(Debug)]
1417pub struct DeviceGetWakeUpEventDurationResponder {
1418    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1419    tx_id: u32,
1420}
1421
1422/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1423/// if the responder is dropped without sending a response, so that the client
1424/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1425impl std::ops::Drop for DeviceGetWakeUpEventDurationResponder {
1426    fn drop(&mut self) {
1427        self.control_handle.shutdown();
1428        // Safety: drops once, never accessed again
1429        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1430    }
1431}
1432
1433impl fidl::endpoints::Responder for DeviceGetWakeUpEventDurationResponder {
1434    type ControlHandle = DeviceControlHandle;
1435
1436    fn control_handle(&self) -> &DeviceControlHandle {
1437        &self.control_handle
1438    }
1439
1440    fn drop_without_shutdown(mut self) {
1441        // Safety: drops once, never accessed again due to mem::forget
1442        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1443        // Prevent Drop from running (which would shut down the channel)
1444        std::mem::forget(self);
1445    }
1446}
1447
1448impl DeviceGetWakeUpEventDurationResponder {
1449    /// Sends a response to the FIDL transaction.
1450    ///
1451    /// Sets the channel to shutdown if an error occurs.
1452    pub fn send(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1453        let _result = self.send_raw(result);
1454        if _result.is_err() {
1455            self.control_handle.shutdown();
1456        }
1457        self.drop_without_shutdown();
1458        _result
1459    }
1460
1461    /// Similar to "send" but does not shutdown the channel if an error occurs.
1462    pub fn send_no_shutdown_on_err(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1463        let _result = self.send_raw(result);
1464        self.drop_without_shutdown();
1465        _result
1466    }
1467
1468    fn send_raw(&self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1469        self.control_handle.inner.send::<fidl::encoding::ResultType<
1470            DeviceGetWakeUpEventDurationResponse,
1471            i32,
1472        >>(
1473            result.map(|duration| (duration,)),
1474            self.tx_id,
1475            0x45c79749f65e7176,
1476            fidl::encoding::DynamicFlags::empty(),
1477        )
1478    }
1479}
1480
1481#[must_use = "FIDL methods require a response to be sent"]
1482#[derive(Debug)]
1483pub struct DeviceSetWakeUpEventDurationResponder {
1484    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1485    tx_id: u32,
1486}
1487
1488/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1489/// if the responder is dropped without sending a response, so that the client
1490/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1491impl std::ops::Drop for DeviceSetWakeUpEventDurationResponder {
1492    fn drop(&mut self) {
1493        self.control_handle.shutdown();
1494        // Safety: drops once, never accessed again
1495        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1496    }
1497}
1498
1499impl fidl::endpoints::Responder for DeviceSetWakeUpEventDurationResponder {
1500    type ControlHandle = DeviceControlHandle;
1501
1502    fn control_handle(&self) -> &DeviceControlHandle {
1503        &self.control_handle
1504    }
1505
1506    fn drop_without_shutdown(mut self) {
1507        // Safety: drops once, never accessed again due to mem::forget
1508        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1509        // Prevent Drop from running (which would shut down the channel)
1510        std::mem::forget(self);
1511    }
1512}
1513
1514impl DeviceSetWakeUpEventDurationResponder {
1515    /// Sends a response to the FIDL transaction.
1516    ///
1517    /// Sets the channel to shutdown if an error occurs.
1518    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1519        let _result = self.send_raw(result);
1520        if _result.is_err() {
1521            self.control_handle.shutdown();
1522        }
1523        self.drop_without_shutdown();
1524        _result
1525    }
1526
1527    /// Similar to "send" but does not shutdown the channel if an error occurs.
1528    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1529        let _result = self.send_raw(result);
1530        self.drop_without_shutdown();
1531        _result
1532    }
1533
1534    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1535        self.control_handle
1536            .inner
1537            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1538                result,
1539                self.tx_id,
1540                0x1fa1771ffa5f570,
1541                fidl::encoding::DynamicFlags::empty(),
1542            )
1543    }
1544}
1545
1546#[must_use = "FIDL methods require a response to be sent"]
1547#[derive(Debug)]
1548pub struct DeviceHardwareResetResponder {
1549    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1550    tx_id: u32,
1551}
1552
1553/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1554/// if the responder is dropped without sending a response, so that the client
1555/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1556impl std::ops::Drop for DeviceHardwareResetResponder {
1557    fn drop(&mut self) {
1558        self.control_handle.shutdown();
1559        // Safety: drops once, never accessed again
1560        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1561    }
1562}
1563
1564impl fidl::endpoints::Responder for DeviceHardwareResetResponder {
1565    type ControlHandle = DeviceControlHandle;
1566
1567    fn control_handle(&self) -> &DeviceControlHandle {
1568        &self.control_handle
1569    }
1570
1571    fn drop_without_shutdown(mut self) {
1572        // Safety: drops once, never accessed again due to mem::forget
1573        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1574        // Prevent Drop from running (which would shut down the channel)
1575        std::mem::forget(self);
1576    }
1577}
1578
1579impl DeviceHardwareResetResponder {
1580    /// Sends a response to the FIDL transaction.
1581    ///
1582    /// Sets the channel to shutdown if an error occurs.
1583    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1584        let _result = self.send_raw(result);
1585        if _result.is_err() {
1586            self.control_handle.shutdown();
1587        }
1588        self.drop_without_shutdown();
1589        _result
1590    }
1591
1592    /// Similar to "send" but does not shutdown the channel if an error occurs.
1593    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1594        let _result = self.send_raw(result);
1595        self.drop_without_shutdown();
1596        _result
1597    }
1598
1599    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1600        self.control_handle
1601            .inner
1602            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1603                result,
1604                self.tx_id,
1605                0x78e3d2ded2f929f,
1606                fidl::encoding::DynamicFlags::empty(),
1607            )
1608    }
1609}
1610
1611#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1612pub struct ServiceMarker;
1613
1614#[cfg(target_os = "fuchsia")]
1615impl fidl::endpoints::ServiceMarker for ServiceMarker {
1616    type Proxy = ServiceProxy;
1617    type Request = ServiceRequest;
1618    const SERVICE_NAME: &'static str = "fuchsia.hardware.google.nanohub.Service";
1619}
1620
1621/// A request for one of the member protocols of Service.
1622///
1623#[cfg(target_os = "fuchsia")]
1624pub enum ServiceRequest {
1625    Nanohub(DeviceRequestStream),
1626}
1627
1628#[cfg(target_os = "fuchsia")]
1629impl fidl::endpoints::ServiceRequest for ServiceRequest {
1630    type Service = ServiceMarker;
1631
1632    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1633        match name {
1634            "nanohub" => Self::Nanohub(
1635                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1636            ),
1637            _ => panic!("no such member protocol name for service Service"),
1638        }
1639    }
1640
1641    fn member_names() -> &'static [&'static str] {
1642        &["nanohub"]
1643    }
1644}
1645#[cfg(target_os = "fuchsia")]
1646pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1647
1648#[cfg(target_os = "fuchsia")]
1649impl fidl::endpoints::ServiceProxy for ServiceProxy {
1650    type Service = ServiceMarker;
1651
1652    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1653        Self(opener)
1654    }
1655}
1656
1657#[cfg(target_os = "fuchsia")]
1658impl ServiceProxy {
1659    pub fn connect_to_nanohub(&self) -> Result<DeviceProxy, fidl::Error> {
1660        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1661        self.connect_channel_to_nanohub(server_end)?;
1662        Ok(proxy)
1663    }
1664
1665    /// Like `connect_to_nanohub`, but returns a sync proxy.
1666    /// See [`Self::connect_to_nanohub`] for more details.
1667    pub fn connect_to_nanohub_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1668        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1669        self.connect_channel_to_nanohub(server_end)?;
1670        Ok(proxy)
1671    }
1672
1673    /// Like `connect_to_nanohub`, but accepts a server end.
1674    /// See [`Self::connect_to_nanohub`] for more details.
1675    pub fn connect_channel_to_nanohub(
1676        &self,
1677        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1678    ) -> Result<(), fidl::Error> {
1679        self.0.open_member("nanohub", server_end.into_channel())
1680    }
1681
1682    pub fn instance_name(&self) -> &str {
1683        self.0.instance_name()
1684    }
1685}
1686
1687mod internal {
1688    use super::*;
1689
1690    impl fidl::encoding::ResourceTypeMarker for DeviceDownloadFirmwareRequest {
1691        type Borrowed<'a> = &'a mut Self;
1692        fn take_or_borrow<'a>(
1693            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1694        ) -> Self::Borrowed<'a> {
1695            value
1696        }
1697    }
1698
1699    unsafe impl fidl::encoding::TypeMarker for DeviceDownloadFirmwareRequest {
1700        type Owned = Self;
1701
1702        #[inline(always)]
1703        fn inline_align(_context: fidl::encoding::Context) -> usize {
1704            8
1705        }
1706
1707        #[inline(always)]
1708        fn inline_size(_context: fidl::encoding::Context) -> usize {
1709            16
1710        }
1711    }
1712
1713    unsafe impl
1714        fidl::encoding::Encode<
1715            DeviceDownloadFirmwareRequest,
1716            fidl::encoding::DefaultFuchsiaResourceDialect,
1717        > for &mut DeviceDownloadFirmwareRequest
1718    {
1719        #[inline]
1720        unsafe fn encode(
1721            self,
1722            encoder: &mut fidl::encoding::Encoder<
1723                '_,
1724                fidl::encoding::DefaultFuchsiaResourceDialect,
1725            >,
1726            offset: usize,
1727            _depth: fidl::encoding::Depth,
1728        ) -> fidl::Result<()> {
1729            encoder.debug_check_bounds::<DeviceDownloadFirmwareRequest>(offset);
1730            // Delegate to tuple encoding.
1731            fidl::encoding::Encode::<
1732                DeviceDownloadFirmwareRequest,
1733                fidl::encoding::DefaultFuchsiaResourceDialect,
1734            >::encode(
1735                (
1736                    <fidl::encoding::HandleType<
1737                        fidl::Vmo,
1738                        { fidl::ObjectType::VMO.into_raw() },
1739                        49271,
1740                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1741                        &mut self.firmware
1742                    ),
1743                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.offset),
1744                ),
1745                encoder,
1746                offset,
1747                _depth,
1748            )
1749        }
1750    }
1751    unsafe impl<
1752            T0: fidl::encoding::Encode<
1753                fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49271>,
1754                fidl::encoding::DefaultFuchsiaResourceDialect,
1755            >,
1756            T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
1757        >
1758        fidl::encoding::Encode<
1759            DeviceDownloadFirmwareRequest,
1760            fidl::encoding::DefaultFuchsiaResourceDialect,
1761        > for (T0, T1)
1762    {
1763        #[inline]
1764        unsafe fn encode(
1765            self,
1766            encoder: &mut fidl::encoding::Encoder<
1767                '_,
1768                fidl::encoding::DefaultFuchsiaResourceDialect,
1769            >,
1770            offset: usize,
1771            depth: fidl::encoding::Depth,
1772        ) -> fidl::Result<()> {
1773            encoder.debug_check_bounds::<DeviceDownloadFirmwareRequest>(offset);
1774            // Zero out padding regions. There's no need to apply masks
1775            // because the unmasked parts will be overwritten by fields.
1776            unsafe {
1777                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1778                (ptr as *mut u64).write_unaligned(0);
1779            }
1780            // Write the fields.
1781            self.0.encode(encoder, offset + 0, depth)?;
1782            self.1.encode(encoder, offset + 8, depth)?;
1783            Ok(())
1784        }
1785    }
1786
1787    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1788        for DeviceDownloadFirmwareRequest
1789    {
1790        #[inline(always)]
1791        fn new_empty() -> Self {
1792            Self {
1793                firmware: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49271>, fidl::encoding::DefaultFuchsiaResourceDialect),
1794                offset: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
1795            }
1796        }
1797
1798        #[inline]
1799        unsafe fn decode(
1800            &mut self,
1801            decoder: &mut fidl::encoding::Decoder<
1802                '_,
1803                fidl::encoding::DefaultFuchsiaResourceDialect,
1804            >,
1805            offset: usize,
1806            _depth: fidl::encoding::Depth,
1807        ) -> fidl::Result<()> {
1808            decoder.debug_check_bounds::<Self>(offset);
1809            // Verify that padding bytes are zero.
1810            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1811            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1812            let mask = 0xffffffff00000000u64;
1813            let maskedval = padval & mask;
1814            if maskedval != 0 {
1815                return Err(fidl::Error::NonZeroPadding {
1816                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1817                });
1818            }
1819            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49271>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.firmware, decoder, offset + 0, _depth)?;
1820            fidl::decode!(
1821                u64,
1822                fidl::encoding::DefaultFuchsiaResourceDialect,
1823                &mut self.offset,
1824                decoder,
1825                offset + 8,
1826                _depth
1827            )?;
1828            Ok(())
1829        }
1830    }
1831}