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