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::NullableHandle {
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
1215    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1216        self.inner.shutdown_with_epitaph(status)
1217    }
1218
1219    fn is_closed(&self) -> bool {
1220        self.inner.channel().is_closed()
1221    }
1222    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1223        self.inner.channel().on_closed()
1224    }
1225
1226    #[cfg(target_os = "fuchsia")]
1227    fn signal_peer(
1228        &self,
1229        clear_mask: zx::Signals,
1230        set_mask: zx::Signals,
1231    ) -> Result<(), zx_status::Status> {
1232        use fidl::Peered;
1233        self.inner.channel().signal_peer(clear_mask, set_mask)
1234    }
1235}
1236
1237impl AdminControlHandle {}
1238
1239#[must_use = "FIDL methods require a response to be sent"]
1240#[derive(Debug)]
1241pub struct AdminPowerFullyOnResponder {
1242    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1243    tx_id: u32,
1244}
1245
1246/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1247/// if the responder is dropped without sending a response, so that the client
1248/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1249impl std::ops::Drop for AdminPowerFullyOnResponder {
1250    fn drop(&mut self) {
1251        self.control_handle.shutdown();
1252        // Safety: drops once, never accessed again
1253        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1254    }
1255}
1256
1257impl fidl::endpoints::Responder for AdminPowerFullyOnResponder {
1258    type ControlHandle = AdminControlHandle;
1259
1260    fn control_handle(&self) -> &AdminControlHandle {
1261        &self.control_handle
1262    }
1263
1264    fn drop_without_shutdown(mut self) {
1265        // Safety: drops once, never accessed again due to mem::forget
1266        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1267        // Prevent Drop from running (which would shut down the channel)
1268        std::mem::forget(self);
1269    }
1270}
1271
1272impl AdminPowerFullyOnResponder {
1273    /// Sends a response to the FIDL transaction.
1274    ///
1275    /// Sets the channel to shutdown if an error occurs.
1276    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1277        let _result = self.send_raw(result);
1278        if _result.is_err() {
1279            self.control_handle.shutdown();
1280        }
1281        self.drop_without_shutdown();
1282        _result
1283    }
1284
1285    /// Similar to "send" but does not shutdown the channel if an error occurs.
1286    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1287        let _result = self.send_raw(result);
1288        self.drop_without_shutdown();
1289        _result
1290    }
1291
1292    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1293        self.control_handle
1294            .inner
1295            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1296                result,
1297                self.tx_id,
1298                0xb3272d15e00712f,
1299                fidl::encoding::DynamicFlags::empty(),
1300            )
1301    }
1302}
1303
1304#[must_use = "FIDL methods require a response to be sent"]
1305#[derive(Debug)]
1306pub struct AdminShutdownResponder {
1307    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1308    tx_id: u32,
1309}
1310
1311/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1312/// if the responder is dropped without sending a response, so that the client
1313/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1314impl std::ops::Drop for AdminShutdownResponder {
1315    fn drop(&mut self) {
1316        self.control_handle.shutdown();
1317        // Safety: drops once, never accessed again
1318        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1319    }
1320}
1321
1322impl fidl::endpoints::Responder for AdminShutdownResponder {
1323    type ControlHandle = AdminControlHandle;
1324
1325    fn control_handle(&self) -> &AdminControlHandle {
1326        &self.control_handle
1327    }
1328
1329    fn drop_without_shutdown(mut self) {
1330        // Safety: drops once, never accessed again due to mem::forget
1331        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1332        // Prevent Drop from running (which would shut down the channel)
1333        std::mem::forget(self);
1334    }
1335}
1336
1337impl AdminShutdownResponder {
1338    /// Sends a response to the FIDL transaction.
1339    ///
1340    /// Sets the channel to shutdown if an error occurs.
1341    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1342        let _result = self.send_raw(result);
1343        if _result.is_err() {
1344            self.control_handle.shutdown();
1345        }
1346        self.drop_without_shutdown();
1347        _result
1348    }
1349
1350    /// Similar to "send" but does not shutdown the channel if an error occurs.
1351    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1352        let _result = self.send_raw(result);
1353        self.drop_without_shutdown();
1354        _result
1355    }
1356
1357    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1358        self.control_handle
1359            .inner
1360            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1361                result,
1362                self.tx_id,
1363                0x3722c53e45dc022f,
1364                fidl::encoding::DynamicFlags::empty(),
1365            )
1366    }
1367}
1368
1369#[must_use = "FIDL methods require a response to be sent"]
1370#[derive(Debug)]
1371pub struct AdminRebootResponder {
1372    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1373    tx_id: u32,
1374}
1375
1376/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1377/// if the responder is dropped without sending a response, so that the client
1378/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1379impl std::ops::Drop for AdminRebootResponder {
1380    fn drop(&mut self) {
1381        self.control_handle.shutdown();
1382        // Safety: drops once, never accessed again
1383        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1384    }
1385}
1386
1387impl fidl::endpoints::Responder for AdminRebootResponder {
1388    type ControlHandle = AdminControlHandle;
1389
1390    fn control_handle(&self) -> &AdminControlHandle {
1391        &self.control_handle
1392    }
1393
1394    fn drop_without_shutdown(mut self) {
1395        // Safety: drops once, never accessed again due to mem::forget
1396        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1397        // Prevent Drop from running (which would shut down the channel)
1398        std::mem::forget(self);
1399    }
1400}
1401
1402impl AdminRebootResponder {
1403    /// Sends a response to the FIDL transaction.
1404    ///
1405    /// Sets the channel to shutdown if an error occurs.
1406    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1407        let _result = self.send_raw(result);
1408        if _result.is_err() {
1409            self.control_handle.shutdown();
1410        }
1411        self.drop_without_shutdown();
1412        _result
1413    }
1414
1415    /// Similar to "send" but does not shutdown the channel if an error occurs.
1416    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1417        let _result = self.send_raw(result);
1418        self.drop_without_shutdown();
1419        _result
1420    }
1421
1422    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1423        self.control_handle
1424            .inner
1425            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1426                result,
1427                self.tx_id,
1428                0x21f258bd20297368,
1429                fidl::encoding::DynamicFlags::empty(),
1430            )
1431    }
1432}
1433
1434#[must_use = "FIDL methods require a response to be sent"]
1435#[derive(Debug)]
1436pub struct AdminPerformRebootResponder {
1437    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1438    tx_id: u32,
1439}
1440
1441/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1442/// if the responder is dropped without sending a response, so that the client
1443/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1444impl std::ops::Drop for AdminPerformRebootResponder {
1445    fn drop(&mut self) {
1446        self.control_handle.shutdown();
1447        // Safety: drops once, never accessed again
1448        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1449    }
1450}
1451
1452impl fidl::endpoints::Responder for AdminPerformRebootResponder {
1453    type ControlHandle = AdminControlHandle;
1454
1455    fn control_handle(&self) -> &AdminControlHandle {
1456        &self.control_handle
1457    }
1458
1459    fn drop_without_shutdown(mut self) {
1460        // Safety: drops once, never accessed again due to mem::forget
1461        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1462        // Prevent Drop from running (which would shut down the channel)
1463        std::mem::forget(self);
1464    }
1465}
1466
1467impl AdminPerformRebootResponder {
1468    /// Sends a response to the FIDL transaction.
1469    ///
1470    /// Sets the channel to shutdown if an error occurs.
1471    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1472        let _result = self.send_raw(result);
1473        if _result.is_err() {
1474            self.control_handle.shutdown();
1475        }
1476        self.drop_without_shutdown();
1477        _result
1478    }
1479
1480    /// Similar to "send" but does not shutdown the channel if an error occurs.
1481    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1482        let _result = self.send_raw(result);
1483        self.drop_without_shutdown();
1484        _result
1485    }
1486
1487    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1488        self.control_handle
1489            .inner
1490            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1491                result,
1492                self.tx_id,
1493                0x9416b4d36a80b4,
1494                fidl::encoding::DynamicFlags::empty(),
1495            )
1496    }
1497}
1498
1499#[must_use = "FIDL methods require a response to be sent"]
1500#[derive(Debug)]
1501pub struct AdminRebootToBootloaderResponder {
1502    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1503    tx_id: u32,
1504}
1505
1506/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1507/// if the responder is dropped without sending a response, so that the client
1508/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1509impl std::ops::Drop for AdminRebootToBootloaderResponder {
1510    fn drop(&mut self) {
1511        self.control_handle.shutdown();
1512        // Safety: drops once, never accessed again
1513        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1514    }
1515}
1516
1517impl fidl::endpoints::Responder for AdminRebootToBootloaderResponder {
1518    type ControlHandle = AdminControlHandle;
1519
1520    fn control_handle(&self) -> &AdminControlHandle {
1521        &self.control_handle
1522    }
1523
1524    fn drop_without_shutdown(mut self) {
1525        // Safety: drops once, never accessed again due to mem::forget
1526        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1527        // Prevent Drop from running (which would shut down the channel)
1528        std::mem::forget(self);
1529    }
1530}
1531
1532impl AdminRebootToBootloaderResponder {
1533    /// Sends a response to the FIDL transaction.
1534    ///
1535    /// Sets the channel to shutdown if an error occurs.
1536    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1537        let _result = self.send_raw(result);
1538        if _result.is_err() {
1539            self.control_handle.shutdown();
1540        }
1541        self.drop_without_shutdown();
1542        _result
1543    }
1544
1545    /// Similar to "send" but does not shutdown the channel if an error occurs.
1546    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1547        let _result = self.send_raw(result);
1548        self.drop_without_shutdown();
1549        _result
1550    }
1551
1552    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1553        self.control_handle
1554            .inner
1555            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1556                result,
1557                self.tx_id,
1558                0x6dce331b33786aa,
1559                fidl::encoding::DynamicFlags::empty(),
1560            )
1561    }
1562}
1563
1564#[must_use = "FIDL methods require a response to be sent"]
1565#[derive(Debug)]
1566pub struct AdminRebootToRecoveryResponder {
1567    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1568    tx_id: u32,
1569}
1570
1571/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1572/// if the responder is dropped without sending a response, so that the client
1573/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1574impl std::ops::Drop for AdminRebootToRecoveryResponder {
1575    fn drop(&mut self) {
1576        self.control_handle.shutdown();
1577        // Safety: drops once, never accessed again
1578        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1579    }
1580}
1581
1582impl fidl::endpoints::Responder for AdminRebootToRecoveryResponder {
1583    type ControlHandle = AdminControlHandle;
1584
1585    fn control_handle(&self) -> &AdminControlHandle {
1586        &self.control_handle
1587    }
1588
1589    fn drop_without_shutdown(mut self) {
1590        // Safety: drops once, never accessed again due to mem::forget
1591        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1592        // Prevent Drop from running (which would shut down the channel)
1593        std::mem::forget(self);
1594    }
1595}
1596
1597impl AdminRebootToRecoveryResponder {
1598    /// Sends a response to the FIDL transaction.
1599    ///
1600    /// Sets the channel to shutdown if an error occurs.
1601    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1602        let _result = self.send_raw(result);
1603        if _result.is_err() {
1604            self.control_handle.shutdown();
1605        }
1606        self.drop_without_shutdown();
1607        _result
1608    }
1609
1610    /// Similar to "send" but does not shutdown the channel if an error occurs.
1611    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1612        let _result = self.send_raw(result);
1613        self.drop_without_shutdown();
1614        _result
1615    }
1616
1617    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1618        self.control_handle
1619            .inner
1620            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1621                result,
1622                self.tx_id,
1623                0x1575c566be54f505,
1624                fidl::encoding::DynamicFlags::empty(),
1625            )
1626    }
1627}
1628
1629#[must_use = "FIDL methods require a response to be sent"]
1630#[derive(Debug)]
1631pub struct AdminPoweroffResponder {
1632    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1633    tx_id: u32,
1634}
1635
1636/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1637/// if the responder is dropped without sending a response, so that the client
1638/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1639impl std::ops::Drop for AdminPoweroffResponder {
1640    fn drop(&mut self) {
1641        self.control_handle.shutdown();
1642        // Safety: drops once, never accessed again
1643        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1644    }
1645}
1646
1647impl fidl::endpoints::Responder for AdminPoweroffResponder {
1648    type ControlHandle = AdminControlHandle;
1649
1650    fn control_handle(&self) -> &AdminControlHandle {
1651        &self.control_handle
1652    }
1653
1654    fn drop_without_shutdown(mut self) {
1655        // Safety: drops once, never accessed again due to mem::forget
1656        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1657        // Prevent Drop from running (which would shut down the channel)
1658        std::mem::forget(self);
1659    }
1660}
1661
1662impl AdminPoweroffResponder {
1663    /// Sends a response to the FIDL transaction.
1664    ///
1665    /// Sets the channel to shutdown if an error occurs.
1666    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1667        let _result = self.send_raw(result);
1668        if _result.is_err() {
1669            self.control_handle.shutdown();
1670        }
1671        self.drop_without_shutdown();
1672        _result
1673    }
1674
1675    /// Similar to "send" but does not shutdown the channel if an error occurs.
1676    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1677        let _result = self.send_raw(result);
1678        self.drop_without_shutdown();
1679        _result
1680    }
1681
1682    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1683        self.control_handle
1684            .inner
1685            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1686                result,
1687                self.tx_id,
1688                0x24101c5d0b439748,
1689                fidl::encoding::DynamicFlags::empty(),
1690            )
1691    }
1692}
1693
1694#[must_use = "FIDL methods require a response to be sent"]
1695#[derive(Debug)]
1696pub struct AdminMexecResponder {
1697    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1698    tx_id: u32,
1699}
1700
1701/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1702/// if the responder is dropped without sending a response, so that the client
1703/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1704impl std::ops::Drop for AdminMexecResponder {
1705    fn drop(&mut self) {
1706        self.control_handle.shutdown();
1707        // Safety: drops once, never accessed again
1708        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1709    }
1710}
1711
1712impl fidl::endpoints::Responder for AdminMexecResponder {
1713    type ControlHandle = AdminControlHandle;
1714
1715    fn control_handle(&self) -> &AdminControlHandle {
1716        &self.control_handle
1717    }
1718
1719    fn drop_without_shutdown(mut self) {
1720        // Safety: drops once, never accessed again due to mem::forget
1721        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1722        // Prevent Drop from running (which would shut down the channel)
1723        std::mem::forget(self);
1724    }
1725}
1726
1727impl AdminMexecResponder {
1728    /// Sends a response to the FIDL transaction.
1729    ///
1730    /// Sets the channel to shutdown if an error occurs.
1731    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1732        let _result = self.send_raw(result);
1733        if _result.is_err() {
1734            self.control_handle.shutdown();
1735        }
1736        self.drop_without_shutdown();
1737        _result
1738    }
1739
1740    /// Similar to "send" but does not shutdown the channel if an error occurs.
1741    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1742        let _result = self.send_raw(result);
1743        self.drop_without_shutdown();
1744        _result
1745    }
1746
1747    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1748        self.control_handle
1749            .inner
1750            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1751                result,
1752                self.tx_id,
1753                0x1f91e77ec781a4c6,
1754                fidl::encoding::DynamicFlags::empty(),
1755            )
1756    }
1757}
1758
1759#[must_use = "FIDL methods require a response to be sent"]
1760#[derive(Debug)]
1761pub struct AdminSuspendToRamResponder {
1762    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1763    tx_id: u32,
1764}
1765
1766/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1767/// if the responder is dropped without sending a response, so that the client
1768/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1769impl std::ops::Drop for AdminSuspendToRamResponder {
1770    fn drop(&mut self) {
1771        self.control_handle.shutdown();
1772        // Safety: drops once, never accessed again
1773        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1774    }
1775}
1776
1777impl fidl::endpoints::Responder for AdminSuspendToRamResponder {
1778    type ControlHandle = AdminControlHandle;
1779
1780    fn control_handle(&self) -> &AdminControlHandle {
1781        &self.control_handle
1782    }
1783
1784    fn drop_without_shutdown(mut self) {
1785        // Safety: drops once, never accessed again due to mem::forget
1786        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1787        // Prevent Drop from running (which would shut down the channel)
1788        std::mem::forget(self);
1789    }
1790}
1791
1792impl AdminSuspendToRamResponder {
1793    /// Sends a response to the FIDL transaction.
1794    ///
1795    /// Sets the channel to shutdown if an error occurs.
1796    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1797        let _result = self.send_raw(result);
1798        if _result.is_err() {
1799            self.control_handle.shutdown();
1800        }
1801        self.drop_without_shutdown();
1802        _result
1803    }
1804
1805    /// Similar to "send" but does not shutdown the channel if an error occurs.
1806    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1807        let _result = self.send_raw(result);
1808        self.drop_without_shutdown();
1809        _result
1810    }
1811
1812    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1813        self.control_handle
1814            .inner
1815            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1816                result,
1817                self.tx_id,
1818                0x3b0e356782e7620e,
1819                fidl::encoding::DynamicFlags::empty(),
1820            )
1821    }
1822}
1823
1824#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1825pub struct RebootMethodsWatcherMarker;
1826
1827impl fidl::endpoints::ProtocolMarker for RebootMethodsWatcherMarker {
1828    type Proxy = RebootMethodsWatcherProxy;
1829    type RequestStream = RebootMethodsWatcherRequestStream;
1830    #[cfg(target_os = "fuchsia")]
1831    type SynchronousProxy = RebootMethodsWatcherSynchronousProxy;
1832
1833    const DEBUG_NAME: &'static str = "(anonymous) RebootMethodsWatcher";
1834}
1835
1836pub trait RebootMethodsWatcherProxyInterface: Send + Sync {
1837    type OnRebootResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1838    fn r#on_reboot(&self, reason: RebootReason) -> Self::OnRebootResponseFut;
1839}
1840#[derive(Debug)]
1841#[cfg(target_os = "fuchsia")]
1842pub struct RebootMethodsWatcherSynchronousProxy {
1843    client: fidl::client::sync::Client,
1844}
1845
1846#[cfg(target_os = "fuchsia")]
1847impl fidl::endpoints::SynchronousProxy for RebootMethodsWatcherSynchronousProxy {
1848    type Proxy = RebootMethodsWatcherProxy;
1849    type Protocol = RebootMethodsWatcherMarker;
1850
1851    fn from_channel(inner: fidl::Channel) -> Self {
1852        Self::new(inner)
1853    }
1854
1855    fn into_channel(self) -> fidl::Channel {
1856        self.client.into_channel()
1857    }
1858
1859    fn as_channel(&self) -> &fidl::Channel {
1860        self.client.as_channel()
1861    }
1862}
1863
1864#[cfg(target_os = "fuchsia")]
1865impl RebootMethodsWatcherSynchronousProxy {
1866    pub fn new(channel: fidl::Channel) -> Self {
1867        let protocol_name =
1868            <RebootMethodsWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1869        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1870    }
1871
1872    pub fn into_channel(self) -> fidl::Channel {
1873        self.client.into_channel()
1874    }
1875
1876    /// Waits until an event arrives and returns it. It is safe for other
1877    /// threads to make concurrent requests while waiting for an event.
1878    pub fn wait_for_event(
1879        &self,
1880        deadline: zx::MonotonicInstant,
1881    ) -> Result<RebootMethodsWatcherEvent, fidl::Error> {
1882        RebootMethodsWatcherEvent::decode(self.client.wait_for_event(deadline)?)
1883    }
1884
1885    pub fn r#on_reboot(
1886        &self,
1887        mut reason: RebootReason,
1888        ___deadline: zx::MonotonicInstant,
1889    ) -> Result<(), fidl::Error> {
1890        let _response = self
1891            .client
1892            .send_query::<RebootMethodsWatcherOnRebootRequest, fidl::encoding::EmptyPayload>(
1893                (reason,),
1894                0x225a5f32436a1b13,
1895                fidl::encoding::DynamicFlags::empty(),
1896                ___deadline,
1897            )?;
1898        Ok(_response)
1899    }
1900}
1901
1902#[cfg(target_os = "fuchsia")]
1903impl From<RebootMethodsWatcherSynchronousProxy> for zx::NullableHandle {
1904    fn from(value: RebootMethodsWatcherSynchronousProxy) -> Self {
1905        value.into_channel().into()
1906    }
1907}
1908
1909#[cfg(target_os = "fuchsia")]
1910impl From<fidl::Channel> for RebootMethodsWatcherSynchronousProxy {
1911    fn from(value: fidl::Channel) -> Self {
1912        Self::new(value)
1913    }
1914}
1915
1916#[cfg(target_os = "fuchsia")]
1917impl fidl::endpoints::FromClient for RebootMethodsWatcherSynchronousProxy {
1918    type Protocol = RebootMethodsWatcherMarker;
1919
1920    fn from_client(value: fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>) -> Self {
1921        Self::new(value.into_channel())
1922    }
1923}
1924
1925#[derive(Debug, Clone)]
1926pub struct RebootMethodsWatcherProxy {
1927    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1928}
1929
1930impl fidl::endpoints::Proxy for RebootMethodsWatcherProxy {
1931    type Protocol = RebootMethodsWatcherMarker;
1932
1933    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1934        Self::new(inner)
1935    }
1936
1937    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1938        self.client.into_channel().map_err(|client| Self { client })
1939    }
1940
1941    fn as_channel(&self) -> &::fidl::AsyncChannel {
1942        self.client.as_channel()
1943    }
1944}
1945
1946impl RebootMethodsWatcherProxy {
1947    /// Create a new Proxy for fuchsia.hardware.power.statecontrol/RebootMethodsWatcher.
1948    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1949        let protocol_name =
1950            <RebootMethodsWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1951        Self { client: fidl::client::Client::new(channel, protocol_name) }
1952    }
1953
1954    /// Get a Stream of events from the remote end of the protocol.
1955    ///
1956    /// # Panics
1957    ///
1958    /// Panics if the event stream was already taken.
1959    pub fn take_event_stream(&self) -> RebootMethodsWatcherEventStream {
1960        RebootMethodsWatcherEventStream { event_receiver: self.client.take_event_receiver() }
1961    }
1962
1963    pub fn r#on_reboot(
1964        &self,
1965        mut reason: RebootReason,
1966    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1967        RebootMethodsWatcherProxyInterface::r#on_reboot(self, reason)
1968    }
1969}
1970
1971impl RebootMethodsWatcherProxyInterface for RebootMethodsWatcherProxy {
1972    type OnRebootResponseFut =
1973        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1974    fn r#on_reboot(&self, mut reason: RebootReason) -> Self::OnRebootResponseFut {
1975        fn _decode(
1976            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1977        ) -> Result<(), fidl::Error> {
1978            let _response = fidl::client::decode_transaction_body::<
1979                fidl::encoding::EmptyPayload,
1980                fidl::encoding::DefaultFuchsiaResourceDialect,
1981                0x225a5f32436a1b13,
1982            >(_buf?)?;
1983            Ok(_response)
1984        }
1985        self.client.send_query_and_decode::<RebootMethodsWatcherOnRebootRequest, ()>(
1986            (reason,),
1987            0x225a5f32436a1b13,
1988            fidl::encoding::DynamicFlags::empty(),
1989            _decode,
1990        )
1991    }
1992}
1993
1994pub struct RebootMethodsWatcherEventStream {
1995    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1996}
1997
1998impl std::marker::Unpin for RebootMethodsWatcherEventStream {}
1999
2000impl futures::stream::FusedStream for RebootMethodsWatcherEventStream {
2001    fn is_terminated(&self) -> bool {
2002        self.event_receiver.is_terminated()
2003    }
2004}
2005
2006impl futures::Stream for RebootMethodsWatcherEventStream {
2007    type Item = Result<RebootMethodsWatcherEvent, fidl::Error>;
2008
2009    fn poll_next(
2010        mut self: std::pin::Pin<&mut Self>,
2011        cx: &mut std::task::Context<'_>,
2012    ) -> std::task::Poll<Option<Self::Item>> {
2013        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2014            &mut self.event_receiver,
2015            cx
2016        )?) {
2017            Some(buf) => std::task::Poll::Ready(Some(RebootMethodsWatcherEvent::decode(buf))),
2018            None => std::task::Poll::Ready(None),
2019        }
2020    }
2021}
2022
2023#[derive(Debug)]
2024pub enum RebootMethodsWatcherEvent {}
2025
2026impl RebootMethodsWatcherEvent {
2027    /// Decodes a message buffer as a [`RebootMethodsWatcherEvent`].
2028    fn decode(
2029        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2030    ) -> Result<RebootMethodsWatcherEvent, fidl::Error> {
2031        let (bytes, _handles) = buf.split_mut();
2032        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2033        debug_assert_eq!(tx_header.tx_id, 0);
2034        match tx_header.ordinal {
2035            _ => Err(fidl::Error::UnknownOrdinal {
2036                ordinal: tx_header.ordinal,
2037                protocol_name:
2038                    <RebootMethodsWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2039            }),
2040        }
2041    }
2042}
2043
2044/// A Stream of incoming requests for fuchsia.hardware.power.statecontrol/RebootMethodsWatcher.
2045pub struct RebootMethodsWatcherRequestStream {
2046    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2047    is_terminated: bool,
2048}
2049
2050impl std::marker::Unpin for RebootMethodsWatcherRequestStream {}
2051
2052impl futures::stream::FusedStream for RebootMethodsWatcherRequestStream {
2053    fn is_terminated(&self) -> bool {
2054        self.is_terminated
2055    }
2056}
2057
2058impl fidl::endpoints::RequestStream for RebootMethodsWatcherRequestStream {
2059    type Protocol = RebootMethodsWatcherMarker;
2060    type ControlHandle = RebootMethodsWatcherControlHandle;
2061
2062    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2063        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2064    }
2065
2066    fn control_handle(&self) -> Self::ControlHandle {
2067        RebootMethodsWatcherControlHandle { inner: self.inner.clone() }
2068    }
2069
2070    fn into_inner(
2071        self,
2072    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2073    {
2074        (self.inner, self.is_terminated)
2075    }
2076
2077    fn from_inner(
2078        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2079        is_terminated: bool,
2080    ) -> Self {
2081        Self { inner, is_terminated }
2082    }
2083}
2084
2085impl futures::Stream for RebootMethodsWatcherRequestStream {
2086    type Item = Result<RebootMethodsWatcherRequest, fidl::Error>;
2087
2088    fn poll_next(
2089        mut self: std::pin::Pin<&mut Self>,
2090        cx: &mut std::task::Context<'_>,
2091    ) -> std::task::Poll<Option<Self::Item>> {
2092        let this = &mut *self;
2093        if this.inner.check_shutdown(cx) {
2094            this.is_terminated = true;
2095            return std::task::Poll::Ready(None);
2096        }
2097        if this.is_terminated {
2098            panic!("polled RebootMethodsWatcherRequestStream after completion");
2099        }
2100        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2101            |bytes, handles| {
2102                match this.inner.channel().read_etc(cx, bytes, handles) {
2103                    std::task::Poll::Ready(Ok(())) => {}
2104                    std::task::Poll::Pending => return std::task::Poll::Pending,
2105                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2106                        this.is_terminated = true;
2107                        return std::task::Poll::Ready(None);
2108                    }
2109                    std::task::Poll::Ready(Err(e)) => {
2110                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2111                            e.into(),
2112                        ))));
2113                    }
2114                }
2115
2116                // A message has been received from the channel
2117                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2118
2119                std::task::Poll::Ready(Some(match header.ordinal {
2120                0x225a5f32436a1b13 => {
2121                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2122                    let mut req = fidl::new_empty!(RebootMethodsWatcherOnRebootRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2123                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RebootMethodsWatcherOnRebootRequest>(&header, _body_bytes, handles, &mut req)?;
2124                    let control_handle = RebootMethodsWatcherControlHandle {
2125                        inner: this.inner.clone(),
2126                    };
2127                    Ok(RebootMethodsWatcherRequest::OnReboot {reason: req.reason,
2128
2129                        responder: RebootMethodsWatcherOnRebootResponder {
2130                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2131                            tx_id: header.tx_id,
2132                        },
2133                    })
2134                }
2135                _ => Err(fidl::Error::UnknownOrdinal {
2136                    ordinal: header.ordinal,
2137                    protocol_name: <RebootMethodsWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2138                }),
2139            }))
2140            },
2141        )
2142    }
2143}
2144
2145/// Allows components to be notified when Reboot related methods are called.
2146/// Watchers will be given 'MAX_REBOOT_WATCHER_RESPONSE_TIME_SECONDS' to return
2147/// before the system power state is changed. The channel will be used once to
2148/// send a notification to the watcher. Once the watcher responds or the timeout
2149/// expires, the channel will be closed by the client of RebootMethodsWatcher.
2150///
2151/// Replaced by `RebootWatcher`
2152#[derive(Debug)]
2153pub enum RebootMethodsWatcherRequest {
2154    OnReboot { reason: RebootReason, responder: RebootMethodsWatcherOnRebootResponder },
2155}
2156
2157impl RebootMethodsWatcherRequest {
2158    #[allow(irrefutable_let_patterns)]
2159    pub fn into_on_reboot(self) -> Option<(RebootReason, RebootMethodsWatcherOnRebootResponder)> {
2160        if let RebootMethodsWatcherRequest::OnReboot { reason, responder } = self {
2161            Some((reason, responder))
2162        } else {
2163            None
2164        }
2165    }
2166
2167    /// Name of the method defined in FIDL
2168    pub fn method_name(&self) -> &'static str {
2169        match *self {
2170            RebootMethodsWatcherRequest::OnReboot { .. } => "on_reboot",
2171        }
2172    }
2173}
2174
2175#[derive(Debug, Clone)]
2176pub struct RebootMethodsWatcherControlHandle {
2177    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2178}
2179
2180impl fidl::endpoints::ControlHandle for RebootMethodsWatcherControlHandle {
2181    fn shutdown(&self) {
2182        self.inner.shutdown()
2183    }
2184
2185    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2186        self.inner.shutdown_with_epitaph(status)
2187    }
2188
2189    fn is_closed(&self) -> bool {
2190        self.inner.channel().is_closed()
2191    }
2192    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2193        self.inner.channel().on_closed()
2194    }
2195
2196    #[cfg(target_os = "fuchsia")]
2197    fn signal_peer(
2198        &self,
2199        clear_mask: zx::Signals,
2200        set_mask: zx::Signals,
2201    ) -> Result<(), zx_status::Status> {
2202        use fidl::Peered;
2203        self.inner.channel().signal_peer(clear_mask, set_mask)
2204    }
2205}
2206
2207impl RebootMethodsWatcherControlHandle {}
2208
2209#[must_use = "FIDL methods require a response to be sent"]
2210#[derive(Debug)]
2211pub struct RebootMethodsWatcherOnRebootResponder {
2212    control_handle: std::mem::ManuallyDrop<RebootMethodsWatcherControlHandle>,
2213    tx_id: u32,
2214}
2215
2216/// Set the the channel to be shutdown (see [`RebootMethodsWatcherControlHandle::shutdown`])
2217/// if the responder is dropped without sending a response, so that the client
2218/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2219impl std::ops::Drop for RebootMethodsWatcherOnRebootResponder {
2220    fn drop(&mut self) {
2221        self.control_handle.shutdown();
2222        // Safety: drops once, never accessed again
2223        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2224    }
2225}
2226
2227impl fidl::endpoints::Responder for RebootMethodsWatcherOnRebootResponder {
2228    type ControlHandle = RebootMethodsWatcherControlHandle;
2229
2230    fn control_handle(&self) -> &RebootMethodsWatcherControlHandle {
2231        &self.control_handle
2232    }
2233
2234    fn drop_without_shutdown(mut self) {
2235        // Safety: drops once, never accessed again due to mem::forget
2236        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2237        // Prevent Drop from running (which would shut down the channel)
2238        std::mem::forget(self);
2239    }
2240}
2241
2242impl RebootMethodsWatcherOnRebootResponder {
2243    /// Sends a response to the FIDL transaction.
2244    ///
2245    /// Sets the channel to shutdown if an error occurs.
2246    pub fn send(self) -> Result<(), fidl::Error> {
2247        let _result = self.send_raw();
2248        if _result.is_err() {
2249            self.control_handle.shutdown();
2250        }
2251        self.drop_without_shutdown();
2252        _result
2253    }
2254
2255    /// Similar to "send" but does not shutdown the channel if an error occurs.
2256    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2257        let _result = self.send_raw();
2258        self.drop_without_shutdown();
2259        _result
2260    }
2261
2262    fn send_raw(&self) -> Result<(), fidl::Error> {
2263        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2264            (),
2265            self.tx_id,
2266            0x225a5f32436a1b13,
2267            fidl::encoding::DynamicFlags::empty(),
2268        )
2269    }
2270}
2271
2272#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2273pub struct RebootMethodsWatcherRegisterMarker;
2274
2275impl fidl::endpoints::ProtocolMarker for RebootMethodsWatcherRegisterMarker {
2276    type Proxy = RebootMethodsWatcherRegisterProxy;
2277    type RequestStream = RebootMethodsWatcherRegisterRequestStream;
2278    #[cfg(target_os = "fuchsia")]
2279    type SynchronousProxy = RebootMethodsWatcherRegisterSynchronousProxy;
2280
2281    const DEBUG_NAME: &'static str =
2282        "fuchsia.hardware.power.statecontrol.RebootMethodsWatcherRegister";
2283}
2284impl fidl::endpoints::DiscoverableProtocolMarker for RebootMethodsWatcherRegisterMarker {}
2285
2286pub trait RebootMethodsWatcherRegisterProxyInterface: Send + Sync {
2287    fn r#register(
2288        &self,
2289        watcher: fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
2290    ) -> Result<(), fidl::Error>;
2291    type RegisterWithAckResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2292    fn r#register_with_ack(
2293        &self,
2294        watcher: fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
2295    ) -> Self::RegisterWithAckResponseFut;
2296    type RegisterWatcherResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2297    fn r#register_watcher(
2298        &self,
2299        watcher: fidl::endpoints::ClientEnd<RebootWatcherMarker>,
2300    ) -> Self::RegisterWatcherResponseFut;
2301}
2302#[derive(Debug)]
2303#[cfg(target_os = "fuchsia")]
2304pub struct RebootMethodsWatcherRegisterSynchronousProxy {
2305    client: fidl::client::sync::Client,
2306}
2307
2308#[cfg(target_os = "fuchsia")]
2309impl fidl::endpoints::SynchronousProxy for RebootMethodsWatcherRegisterSynchronousProxy {
2310    type Proxy = RebootMethodsWatcherRegisterProxy;
2311    type Protocol = RebootMethodsWatcherRegisterMarker;
2312
2313    fn from_channel(inner: fidl::Channel) -> Self {
2314        Self::new(inner)
2315    }
2316
2317    fn into_channel(self) -> fidl::Channel {
2318        self.client.into_channel()
2319    }
2320
2321    fn as_channel(&self) -> &fidl::Channel {
2322        self.client.as_channel()
2323    }
2324}
2325
2326#[cfg(target_os = "fuchsia")]
2327impl RebootMethodsWatcherRegisterSynchronousProxy {
2328    pub fn new(channel: fidl::Channel) -> Self {
2329        let protocol_name =
2330            <RebootMethodsWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2331        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2332    }
2333
2334    pub fn into_channel(self) -> fidl::Channel {
2335        self.client.into_channel()
2336    }
2337
2338    /// Waits until an event arrives and returns it. It is safe for other
2339    /// threads to make concurrent requests while waiting for an event.
2340    pub fn wait_for_event(
2341        &self,
2342        deadline: zx::MonotonicInstant,
2343    ) -> Result<RebootMethodsWatcherRegisterEvent, fidl::Error> {
2344        RebootMethodsWatcherRegisterEvent::decode(self.client.wait_for_event(deadline)?)
2345    }
2346
2347    /// Register a watcher to be notified when a Reboot method is called. The
2348    /// Register channel will be used at most once to notify the watcher of an
2349    /// impending reboot and allow it the chance to respond.
2350    ///
2351    /// Watchers can unregister by closing the underlying channel.
2352    ///
2353    /// Replaced by `RegisterWatcher`.
2354    pub fn r#register(
2355        &self,
2356        mut watcher: fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
2357    ) -> Result<(), fidl::Error> {
2358        self.client.send::<RebootMethodsWatcherRegisterRegisterRequest>(
2359            (watcher,),
2360            0x1fd793df8385f937,
2361            fidl::encoding::DynamicFlags::empty(),
2362        )
2363    }
2364
2365    /// Registers a watcher to be notified when a Reboot method is called.
2366    ///
2367    /// Once the watcher has been successfully registered with the server, then
2368    /// the request will be completed and the RebootMethodsWatcherRegister
2369    /// channel will be left open (though a client is free to close it at this
2370    /// time).
2371    ///
2372    /// If there is an error in registering the watcher, then the
2373    /// RebootMethodsWatcherRegister channel will be closed without completing
2374    /// the request.
2375    ///
2376    /// The provided `watcher` channel will be used at most once to notify the
2377    /// watcher of an impending reboot and allow it the chance to respond.
2378    ///
2379    /// Watchers can unregister by closing their `RebootMethodsWatcher` channel.
2380    ///
2381    /// Replaced by `RegisterWatcher`.
2382    pub fn r#register_with_ack(
2383        &self,
2384        mut watcher: fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
2385        ___deadline: zx::MonotonicInstant,
2386    ) -> Result<(), fidl::Error> {
2387        let _response = self.client.send_query::<
2388            RebootMethodsWatcherRegisterRegisterWithAckRequest,
2389            fidl::encoding::EmptyPayload,
2390        >(
2391            (watcher,),
2392            0x243cbccabdac17ec,
2393            fidl::encoding::DynamicFlags::empty(),
2394            ___deadline,
2395        )?;
2396        Ok(_response)
2397    }
2398
2399    /// Registers a watcher to be notified when a Reboot method is called.
2400    ///
2401    /// Once the watcher has been successfully registered with the server, then
2402    /// the request will be completed and the RebootMethodsWatcherRegister
2403    /// channel will be left open (though a client is free to close it at this
2404    /// time).
2405    ///
2406    /// If there is an error in registering the watcher, then the
2407    /// RebootMethodsWatcherRegister channel will be closed without completing
2408    /// the request.
2409    ///
2410    /// The provided `watcher` channel will be used at most once to notify the
2411    /// watcher of an impending reboot and allow it the chance to respond.
2412    ///
2413    /// Watchers can unregister by closing their `RebootWatcher` channel.
2414    pub fn r#register_watcher(
2415        &self,
2416        mut watcher: fidl::endpoints::ClientEnd<RebootWatcherMarker>,
2417        ___deadline: zx::MonotonicInstant,
2418    ) -> Result<(), fidl::Error> {
2419        let _response = self.client.send_query::<
2420            RebootMethodsWatcherRegisterRegisterWatcherRequest,
2421            fidl::encoding::EmptyPayload,
2422        >(
2423            (watcher,),
2424            0x3e6610e78471238,
2425            fidl::encoding::DynamicFlags::empty(),
2426            ___deadline,
2427        )?;
2428        Ok(_response)
2429    }
2430}
2431
2432#[cfg(target_os = "fuchsia")]
2433impl From<RebootMethodsWatcherRegisterSynchronousProxy> for zx::NullableHandle {
2434    fn from(value: RebootMethodsWatcherRegisterSynchronousProxy) -> Self {
2435        value.into_channel().into()
2436    }
2437}
2438
2439#[cfg(target_os = "fuchsia")]
2440impl From<fidl::Channel> for RebootMethodsWatcherRegisterSynchronousProxy {
2441    fn from(value: fidl::Channel) -> Self {
2442        Self::new(value)
2443    }
2444}
2445
2446#[cfg(target_os = "fuchsia")]
2447impl fidl::endpoints::FromClient for RebootMethodsWatcherRegisterSynchronousProxy {
2448    type Protocol = RebootMethodsWatcherRegisterMarker;
2449
2450    fn from_client(value: fidl::endpoints::ClientEnd<RebootMethodsWatcherRegisterMarker>) -> Self {
2451        Self::new(value.into_channel())
2452    }
2453}
2454
2455#[derive(Debug, Clone)]
2456pub struct RebootMethodsWatcherRegisterProxy {
2457    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2458}
2459
2460impl fidl::endpoints::Proxy for RebootMethodsWatcherRegisterProxy {
2461    type Protocol = RebootMethodsWatcherRegisterMarker;
2462
2463    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2464        Self::new(inner)
2465    }
2466
2467    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2468        self.client.into_channel().map_err(|client| Self { client })
2469    }
2470
2471    fn as_channel(&self) -> &::fidl::AsyncChannel {
2472        self.client.as_channel()
2473    }
2474}
2475
2476impl RebootMethodsWatcherRegisterProxy {
2477    /// Create a new Proxy for fuchsia.hardware.power.statecontrol/RebootMethodsWatcherRegister.
2478    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2479        let protocol_name =
2480            <RebootMethodsWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2481        Self { client: fidl::client::Client::new(channel, protocol_name) }
2482    }
2483
2484    /// Get a Stream of events from the remote end of the protocol.
2485    ///
2486    /// # Panics
2487    ///
2488    /// Panics if the event stream was already taken.
2489    pub fn take_event_stream(&self) -> RebootMethodsWatcherRegisterEventStream {
2490        RebootMethodsWatcherRegisterEventStream {
2491            event_receiver: self.client.take_event_receiver(),
2492        }
2493    }
2494
2495    /// Register a watcher to be notified when a Reboot method is called. The
2496    /// Register channel will be used at most once to notify the watcher of an
2497    /// impending reboot and allow it the chance to respond.
2498    ///
2499    /// Watchers can unregister by closing the underlying channel.
2500    ///
2501    /// Replaced by `RegisterWatcher`.
2502    pub fn r#register(
2503        &self,
2504        mut watcher: fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
2505    ) -> Result<(), fidl::Error> {
2506        RebootMethodsWatcherRegisterProxyInterface::r#register(self, watcher)
2507    }
2508
2509    /// Registers a watcher to be notified when a Reboot method is called.
2510    ///
2511    /// Once the watcher has been successfully registered with the server, then
2512    /// the request will be completed and the RebootMethodsWatcherRegister
2513    /// channel will be left open (though a client is free to close it at this
2514    /// time).
2515    ///
2516    /// If there is an error in registering the watcher, then the
2517    /// RebootMethodsWatcherRegister channel will be closed without completing
2518    /// the request.
2519    ///
2520    /// The provided `watcher` channel will be used at most once to notify the
2521    /// watcher of an impending reboot and allow it the chance to respond.
2522    ///
2523    /// Watchers can unregister by closing their `RebootMethodsWatcher` channel.
2524    ///
2525    /// Replaced by `RegisterWatcher`.
2526    pub fn r#register_with_ack(
2527        &self,
2528        mut watcher: fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
2529    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2530        RebootMethodsWatcherRegisterProxyInterface::r#register_with_ack(self, watcher)
2531    }
2532
2533    /// Registers a watcher to be notified when a Reboot method is called.
2534    ///
2535    /// Once the watcher has been successfully registered with the server, then
2536    /// the request will be completed and the RebootMethodsWatcherRegister
2537    /// channel will be left open (though a client is free to close it at this
2538    /// time).
2539    ///
2540    /// If there is an error in registering the watcher, then the
2541    /// RebootMethodsWatcherRegister channel will be closed without completing
2542    /// the request.
2543    ///
2544    /// The provided `watcher` channel will be used at most once to notify the
2545    /// watcher of an impending reboot and allow it the chance to respond.
2546    ///
2547    /// Watchers can unregister by closing their `RebootWatcher` channel.
2548    pub fn r#register_watcher(
2549        &self,
2550        mut watcher: fidl::endpoints::ClientEnd<RebootWatcherMarker>,
2551    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2552        RebootMethodsWatcherRegisterProxyInterface::r#register_watcher(self, watcher)
2553    }
2554}
2555
2556impl RebootMethodsWatcherRegisterProxyInterface for RebootMethodsWatcherRegisterProxy {
2557    fn r#register(
2558        &self,
2559        mut watcher: fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
2560    ) -> Result<(), fidl::Error> {
2561        self.client.send::<RebootMethodsWatcherRegisterRegisterRequest>(
2562            (watcher,),
2563            0x1fd793df8385f937,
2564            fidl::encoding::DynamicFlags::empty(),
2565        )
2566    }
2567
2568    type RegisterWithAckResponseFut =
2569        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2570    fn r#register_with_ack(
2571        &self,
2572        mut watcher: fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
2573    ) -> Self::RegisterWithAckResponseFut {
2574        fn _decode(
2575            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2576        ) -> Result<(), fidl::Error> {
2577            let _response = fidl::client::decode_transaction_body::<
2578                fidl::encoding::EmptyPayload,
2579                fidl::encoding::DefaultFuchsiaResourceDialect,
2580                0x243cbccabdac17ec,
2581            >(_buf?)?;
2582            Ok(_response)
2583        }
2584        self.client.send_query_and_decode::<RebootMethodsWatcherRegisterRegisterWithAckRequest, ()>(
2585            (watcher,),
2586            0x243cbccabdac17ec,
2587            fidl::encoding::DynamicFlags::empty(),
2588            _decode,
2589        )
2590    }
2591
2592    type RegisterWatcherResponseFut =
2593        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2594    fn r#register_watcher(
2595        &self,
2596        mut watcher: fidl::endpoints::ClientEnd<RebootWatcherMarker>,
2597    ) -> Self::RegisterWatcherResponseFut {
2598        fn _decode(
2599            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2600        ) -> Result<(), fidl::Error> {
2601            let _response = fidl::client::decode_transaction_body::<
2602                fidl::encoding::EmptyPayload,
2603                fidl::encoding::DefaultFuchsiaResourceDialect,
2604                0x3e6610e78471238,
2605            >(_buf?)?;
2606            Ok(_response)
2607        }
2608        self.client.send_query_and_decode::<RebootMethodsWatcherRegisterRegisterWatcherRequest, ()>(
2609            (watcher,),
2610            0x3e6610e78471238,
2611            fidl::encoding::DynamicFlags::empty(),
2612            _decode,
2613        )
2614    }
2615}
2616
2617pub struct RebootMethodsWatcherRegisterEventStream {
2618    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2619}
2620
2621impl std::marker::Unpin for RebootMethodsWatcherRegisterEventStream {}
2622
2623impl futures::stream::FusedStream for RebootMethodsWatcherRegisterEventStream {
2624    fn is_terminated(&self) -> bool {
2625        self.event_receiver.is_terminated()
2626    }
2627}
2628
2629impl futures::Stream for RebootMethodsWatcherRegisterEventStream {
2630    type Item = Result<RebootMethodsWatcherRegisterEvent, fidl::Error>;
2631
2632    fn poll_next(
2633        mut self: std::pin::Pin<&mut Self>,
2634        cx: &mut std::task::Context<'_>,
2635    ) -> std::task::Poll<Option<Self::Item>> {
2636        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2637            &mut self.event_receiver,
2638            cx
2639        )?) {
2640            Some(buf) => {
2641                std::task::Poll::Ready(Some(RebootMethodsWatcherRegisterEvent::decode(buf)))
2642            }
2643            None => std::task::Poll::Ready(None),
2644        }
2645    }
2646}
2647
2648#[derive(Debug)]
2649pub enum RebootMethodsWatcherRegisterEvent {}
2650
2651impl RebootMethodsWatcherRegisterEvent {
2652    /// Decodes a message buffer as a [`RebootMethodsWatcherRegisterEvent`].
2653    fn decode(
2654        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2655    ) -> Result<RebootMethodsWatcherRegisterEvent, fidl::Error> {
2656        let (bytes, _handles) = buf.split_mut();
2657        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2658        debug_assert_eq!(tx_header.tx_id, 0);
2659        match tx_header.ordinal {
2660            _ => Err(fidl::Error::UnknownOrdinal {
2661                ordinal: tx_header.ordinal,
2662                protocol_name: <RebootMethodsWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2663            })
2664        }
2665    }
2666}
2667
2668/// A Stream of incoming requests for fuchsia.hardware.power.statecontrol/RebootMethodsWatcherRegister.
2669pub struct RebootMethodsWatcherRegisterRequestStream {
2670    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2671    is_terminated: bool,
2672}
2673
2674impl std::marker::Unpin for RebootMethodsWatcherRegisterRequestStream {}
2675
2676impl futures::stream::FusedStream for RebootMethodsWatcherRegisterRequestStream {
2677    fn is_terminated(&self) -> bool {
2678        self.is_terminated
2679    }
2680}
2681
2682impl fidl::endpoints::RequestStream for RebootMethodsWatcherRegisterRequestStream {
2683    type Protocol = RebootMethodsWatcherRegisterMarker;
2684    type ControlHandle = RebootMethodsWatcherRegisterControlHandle;
2685
2686    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2687        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2688    }
2689
2690    fn control_handle(&self) -> Self::ControlHandle {
2691        RebootMethodsWatcherRegisterControlHandle { inner: self.inner.clone() }
2692    }
2693
2694    fn into_inner(
2695        self,
2696    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2697    {
2698        (self.inner, self.is_terminated)
2699    }
2700
2701    fn from_inner(
2702        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2703        is_terminated: bool,
2704    ) -> Self {
2705        Self { inner, is_terminated }
2706    }
2707}
2708
2709impl futures::Stream for RebootMethodsWatcherRegisterRequestStream {
2710    type Item = Result<RebootMethodsWatcherRegisterRequest, fidl::Error>;
2711
2712    fn poll_next(
2713        mut self: std::pin::Pin<&mut Self>,
2714        cx: &mut std::task::Context<'_>,
2715    ) -> std::task::Poll<Option<Self::Item>> {
2716        let this = &mut *self;
2717        if this.inner.check_shutdown(cx) {
2718            this.is_terminated = true;
2719            return std::task::Poll::Ready(None);
2720        }
2721        if this.is_terminated {
2722            panic!("polled RebootMethodsWatcherRegisterRequestStream after completion");
2723        }
2724        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2725            |bytes, handles| {
2726                match this.inner.channel().read_etc(cx, bytes, handles) {
2727                    std::task::Poll::Ready(Ok(())) => {}
2728                    std::task::Poll::Pending => return std::task::Poll::Pending,
2729                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2730                        this.is_terminated = true;
2731                        return std::task::Poll::Ready(None);
2732                    }
2733                    std::task::Poll::Ready(Err(e)) => {
2734                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2735                            e.into(),
2736                        ))));
2737                    }
2738                }
2739
2740                // A message has been received from the channel
2741                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2742
2743                std::task::Poll::Ready(Some(match header.ordinal {
2744                0x1fd793df8385f937 => {
2745                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2746                    let mut req = fidl::new_empty!(RebootMethodsWatcherRegisterRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2747                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RebootMethodsWatcherRegisterRegisterRequest>(&header, _body_bytes, handles, &mut req)?;
2748                    let control_handle = RebootMethodsWatcherRegisterControlHandle {
2749                        inner: this.inner.clone(),
2750                    };
2751                    Ok(RebootMethodsWatcherRegisterRequest::Register {watcher: req.watcher,
2752
2753                        control_handle,
2754                    })
2755                }
2756                0x243cbccabdac17ec => {
2757                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2758                    let mut req = fidl::new_empty!(RebootMethodsWatcherRegisterRegisterWithAckRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2759                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RebootMethodsWatcherRegisterRegisterWithAckRequest>(&header, _body_bytes, handles, &mut req)?;
2760                    let control_handle = RebootMethodsWatcherRegisterControlHandle {
2761                        inner: this.inner.clone(),
2762                    };
2763                    Ok(RebootMethodsWatcherRegisterRequest::RegisterWithAck {watcher: req.watcher,
2764
2765                        responder: RebootMethodsWatcherRegisterRegisterWithAckResponder {
2766                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2767                            tx_id: header.tx_id,
2768                        },
2769                    })
2770                }
2771                0x3e6610e78471238 => {
2772                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2773                    let mut req = fidl::new_empty!(RebootMethodsWatcherRegisterRegisterWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2774                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RebootMethodsWatcherRegisterRegisterWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
2775                    let control_handle = RebootMethodsWatcherRegisterControlHandle {
2776                        inner: this.inner.clone(),
2777                    };
2778                    Ok(RebootMethodsWatcherRegisterRequest::RegisterWatcher {watcher: req.watcher,
2779
2780                        responder: RebootMethodsWatcherRegisterRegisterWatcherResponder {
2781                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2782                            tx_id: header.tx_id,
2783                        },
2784                    })
2785                }
2786                _ => Err(fidl::Error::UnknownOrdinal {
2787                    ordinal: header.ordinal,
2788                    protocol_name: <RebootMethodsWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2789                }),
2790            }))
2791            },
2792        )
2793    }
2794}
2795
2796/// Allows components to register a callback that will be executed when a Reboot
2797/// method is called. The main purpose of this protocol is to be able to track
2798/// reboot reasons. Consider relying on Component Framework's orderly shutdown
2799/// if you're looking at using this protocol.
2800#[derive(Debug)]
2801pub enum RebootMethodsWatcherRegisterRequest {
2802    /// Register a watcher to be notified when a Reboot method is called. The
2803    /// Register channel will be used at most once to notify the watcher of an
2804    /// impending reboot and allow it the chance to respond.
2805    ///
2806    /// Watchers can unregister by closing the underlying channel.
2807    ///
2808    /// Replaced by `RegisterWatcher`.
2809    Register {
2810        watcher: fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
2811        control_handle: RebootMethodsWatcherRegisterControlHandle,
2812    },
2813    /// Registers a watcher to be notified when a Reboot method is called.
2814    ///
2815    /// Once the watcher has been successfully registered with the server, then
2816    /// the request will be completed and the RebootMethodsWatcherRegister
2817    /// channel will be left open (though a client is free to close it at this
2818    /// time).
2819    ///
2820    /// If there is an error in registering the watcher, then the
2821    /// RebootMethodsWatcherRegister channel will be closed without completing
2822    /// the request.
2823    ///
2824    /// The provided `watcher` channel will be used at most once to notify the
2825    /// watcher of an impending reboot and allow it the chance to respond.
2826    ///
2827    /// Watchers can unregister by closing their `RebootMethodsWatcher` channel.
2828    ///
2829    /// Replaced by `RegisterWatcher`.
2830    RegisterWithAck {
2831        watcher: fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
2832        responder: RebootMethodsWatcherRegisterRegisterWithAckResponder,
2833    },
2834    /// Registers a watcher to be notified when a Reboot method is called.
2835    ///
2836    /// Once the watcher has been successfully registered with the server, then
2837    /// the request will be completed and the RebootMethodsWatcherRegister
2838    /// channel will be left open (though a client is free to close it at this
2839    /// time).
2840    ///
2841    /// If there is an error in registering the watcher, then the
2842    /// RebootMethodsWatcherRegister channel will be closed without completing
2843    /// the request.
2844    ///
2845    /// The provided `watcher` channel will be used at most once to notify the
2846    /// watcher of an impending reboot and allow it the chance to respond.
2847    ///
2848    /// Watchers can unregister by closing their `RebootWatcher` channel.
2849    RegisterWatcher {
2850        watcher: fidl::endpoints::ClientEnd<RebootWatcherMarker>,
2851        responder: RebootMethodsWatcherRegisterRegisterWatcherResponder,
2852    },
2853}
2854
2855impl RebootMethodsWatcherRegisterRequest {
2856    #[allow(irrefutable_let_patterns)]
2857    pub fn into_register(
2858        self,
2859    ) -> Option<(
2860        fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
2861        RebootMethodsWatcherRegisterControlHandle,
2862    )> {
2863        if let RebootMethodsWatcherRegisterRequest::Register { watcher, control_handle } = self {
2864            Some((watcher, control_handle))
2865        } else {
2866            None
2867        }
2868    }
2869
2870    #[allow(irrefutable_let_patterns)]
2871    pub fn into_register_with_ack(
2872        self,
2873    ) -> Option<(
2874        fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
2875        RebootMethodsWatcherRegisterRegisterWithAckResponder,
2876    )> {
2877        if let RebootMethodsWatcherRegisterRequest::RegisterWithAck { watcher, responder } = self {
2878            Some((watcher, responder))
2879        } else {
2880            None
2881        }
2882    }
2883
2884    #[allow(irrefutable_let_patterns)]
2885    pub fn into_register_watcher(
2886        self,
2887    ) -> Option<(
2888        fidl::endpoints::ClientEnd<RebootWatcherMarker>,
2889        RebootMethodsWatcherRegisterRegisterWatcherResponder,
2890    )> {
2891        if let RebootMethodsWatcherRegisterRequest::RegisterWatcher { watcher, responder } = self {
2892            Some((watcher, responder))
2893        } else {
2894            None
2895        }
2896    }
2897
2898    /// Name of the method defined in FIDL
2899    pub fn method_name(&self) -> &'static str {
2900        match *self {
2901            RebootMethodsWatcherRegisterRequest::Register { .. } => "register",
2902            RebootMethodsWatcherRegisterRequest::RegisterWithAck { .. } => "register_with_ack",
2903            RebootMethodsWatcherRegisterRequest::RegisterWatcher { .. } => "register_watcher",
2904        }
2905    }
2906}
2907
2908#[derive(Debug, Clone)]
2909pub struct RebootMethodsWatcherRegisterControlHandle {
2910    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2911}
2912
2913impl fidl::endpoints::ControlHandle for RebootMethodsWatcherRegisterControlHandle {
2914    fn shutdown(&self) {
2915        self.inner.shutdown()
2916    }
2917
2918    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2919        self.inner.shutdown_with_epitaph(status)
2920    }
2921
2922    fn is_closed(&self) -> bool {
2923        self.inner.channel().is_closed()
2924    }
2925    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2926        self.inner.channel().on_closed()
2927    }
2928
2929    #[cfg(target_os = "fuchsia")]
2930    fn signal_peer(
2931        &self,
2932        clear_mask: zx::Signals,
2933        set_mask: zx::Signals,
2934    ) -> Result<(), zx_status::Status> {
2935        use fidl::Peered;
2936        self.inner.channel().signal_peer(clear_mask, set_mask)
2937    }
2938}
2939
2940impl RebootMethodsWatcherRegisterControlHandle {}
2941
2942#[must_use = "FIDL methods require a response to be sent"]
2943#[derive(Debug)]
2944pub struct RebootMethodsWatcherRegisterRegisterWithAckResponder {
2945    control_handle: std::mem::ManuallyDrop<RebootMethodsWatcherRegisterControlHandle>,
2946    tx_id: u32,
2947}
2948
2949/// Set the the channel to be shutdown (see [`RebootMethodsWatcherRegisterControlHandle::shutdown`])
2950/// if the responder is dropped without sending a response, so that the client
2951/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2952impl std::ops::Drop for RebootMethodsWatcherRegisterRegisterWithAckResponder {
2953    fn drop(&mut self) {
2954        self.control_handle.shutdown();
2955        // Safety: drops once, never accessed again
2956        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2957    }
2958}
2959
2960impl fidl::endpoints::Responder for RebootMethodsWatcherRegisterRegisterWithAckResponder {
2961    type ControlHandle = RebootMethodsWatcherRegisterControlHandle;
2962
2963    fn control_handle(&self) -> &RebootMethodsWatcherRegisterControlHandle {
2964        &self.control_handle
2965    }
2966
2967    fn drop_without_shutdown(mut self) {
2968        // Safety: drops once, never accessed again due to mem::forget
2969        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2970        // Prevent Drop from running (which would shut down the channel)
2971        std::mem::forget(self);
2972    }
2973}
2974
2975impl RebootMethodsWatcherRegisterRegisterWithAckResponder {
2976    /// Sends a response to the FIDL transaction.
2977    ///
2978    /// Sets the channel to shutdown if an error occurs.
2979    pub fn send(self) -> Result<(), fidl::Error> {
2980        let _result = self.send_raw();
2981        if _result.is_err() {
2982            self.control_handle.shutdown();
2983        }
2984        self.drop_without_shutdown();
2985        _result
2986    }
2987
2988    /// Similar to "send" but does not shutdown the channel if an error occurs.
2989    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2990        let _result = self.send_raw();
2991        self.drop_without_shutdown();
2992        _result
2993    }
2994
2995    fn send_raw(&self) -> Result<(), fidl::Error> {
2996        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2997            (),
2998            self.tx_id,
2999            0x243cbccabdac17ec,
3000            fidl::encoding::DynamicFlags::empty(),
3001        )
3002    }
3003}
3004
3005#[must_use = "FIDL methods require a response to be sent"]
3006#[derive(Debug)]
3007pub struct RebootMethodsWatcherRegisterRegisterWatcherResponder {
3008    control_handle: std::mem::ManuallyDrop<RebootMethodsWatcherRegisterControlHandle>,
3009    tx_id: u32,
3010}
3011
3012/// Set the the channel to be shutdown (see [`RebootMethodsWatcherRegisterControlHandle::shutdown`])
3013/// if the responder is dropped without sending a response, so that the client
3014/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3015impl std::ops::Drop for RebootMethodsWatcherRegisterRegisterWatcherResponder {
3016    fn drop(&mut self) {
3017        self.control_handle.shutdown();
3018        // Safety: drops once, never accessed again
3019        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3020    }
3021}
3022
3023impl fidl::endpoints::Responder for RebootMethodsWatcherRegisterRegisterWatcherResponder {
3024    type ControlHandle = RebootMethodsWatcherRegisterControlHandle;
3025
3026    fn control_handle(&self) -> &RebootMethodsWatcherRegisterControlHandle {
3027        &self.control_handle
3028    }
3029
3030    fn drop_without_shutdown(mut self) {
3031        // Safety: drops once, never accessed again due to mem::forget
3032        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3033        // Prevent Drop from running (which would shut down the channel)
3034        std::mem::forget(self);
3035    }
3036}
3037
3038impl RebootMethodsWatcherRegisterRegisterWatcherResponder {
3039    /// Sends a response to the FIDL transaction.
3040    ///
3041    /// Sets the channel to shutdown if an error occurs.
3042    pub fn send(self) -> Result<(), fidl::Error> {
3043        let _result = self.send_raw();
3044        if _result.is_err() {
3045            self.control_handle.shutdown();
3046        }
3047        self.drop_without_shutdown();
3048        _result
3049    }
3050
3051    /// Similar to "send" but does not shutdown the channel if an error occurs.
3052    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3053        let _result = self.send_raw();
3054        self.drop_without_shutdown();
3055        _result
3056    }
3057
3058    fn send_raw(&self) -> Result<(), fidl::Error> {
3059        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3060            (),
3061            self.tx_id,
3062            0x3e6610e78471238,
3063            fidl::encoding::DynamicFlags::empty(),
3064        )
3065    }
3066}
3067
3068#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3069pub struct RebootWatcherMarker;
3070
3071impl fidl::endpoints::ProtocolMarker for RebootWatcherMarker {
3072    type Proxy = RebootWatcherProxy;
3073    type RequestStream = RebootWatcherRequestStream;
3074    #[cfg(target_os = "fuchsia")]
3075    type SynchronousProxy = RebootWatcherSynchronousProxy;
3076
3077    const DEBUG_NAME: &'static str = "(anonymous) RebootWatcher";
3078}
3079
3080pub trait RebootWatcherProxyInterface: Send + Sync {
3081    type OnRebootResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3082    fn r#on_reboot(&self, options: &RebootOptions) -> Self::OnRebootResponseFut;
3083}
3084#[derive(Debug)]
3085#[cfg(target_os = "fuchsia")]
3086pub struct RebootWatcherSynchronousProxy {
3087    client: fidl::client::sync::Client,
3088}
3089
3090#[cfg(target_os = "fuchsia")]
3091impl fidl::endpoints::SynchronousProxy for RebootWatcherSynchronousProxy {
3092    type Proxy = RebootWatcherProxy;
3093    type Protocol = RebootWatcherMarker;
3094
3095    fn from_channel(inner: fidl::Channel) -> Self {
3096        Self::new(inner)
3097    }
3098
3099    fn into_channel(self) -> fidl::Channel {
3100        self.client.into_channel()
3101    }
3102
3103    fn as_channel(&self) -> &fidl::Channel {
3104        self.client.as_channel()
3105    }
3106}
3107
3108#[cfg(target_os = "fuchsia")]
3109impl RebootWatcherSynchronousProxy {
3110    pub fn new(channel: fidl::Channel) -> Self {
3111        let protocol_name = <RebootWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3112        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3113    }
3114
3115    pub fn into_channel(self) -> fidl::Channel {
3116        self.client.into_channel()
3117    }
3118
3119    /// Waits until an event arrives and returns it. It is safe for other
3120    /// threads to make concurrent requests while waiting for an event.
3121    pub fn wait_for_event(
3122        &self,
3123        deadline: zx::MonotonicInstant,
3124    ) -> Result<RebootWatcherEvent, fidl::Error> {
3125        RebootWatcherEvent::decode(self.client.wait_for_event(deadline)?)
3126    }
3127
3128    pub fn r#on_reboot(
3129        &self,
3130        mut options: &RebootOptions,
3131        ___deadline: zx::MonotonicInstant,
3132    ) -> Result<(), fidl::Error> {
3133        let _response =
3134            self.client.send_query::<RebootWatcherOnRebootRequest, fidl::encoding::EmptyPayload>(
3135                (options,),
3136                0x5334bbbe774f13c3,
3137                fidl::encoding::DynamicFlags::empty(),
3138                ___deadline,
3139            )?;
3140        Ok(_response)
3141    }
3142}
3143
3144#[cfg(target_os = "fuchsia")]
3145impl From<RebootWatcherSynchronousProxy> for zx::NullableHandle {
3146    fn from(value: RebootWatcherSynchronousProxy) -> Self {
3147        value.into_channel().into()
3148    }
3149}
3150
3151#[cfg(target_os = "fuchsia")]
3152impl From<fidl::Channel> for RebootWatcherSynchronousProxy {
3153    fn from(value: fidl::Channel) -> Self {
3154        Self::new(value)
3155    }
3156}
3157
3158#[cfg(target_os = "fuchsia")]
3159impl fidl::endpoints::FromClient for RebootWatcherSynchronousProxy {
3160    type Protocol = RebootWatcherMarker;
3161
3162    fn from_client(value: fidl::endpoints::ClientEnd<RebootWatcherMarker>) -> Self {
3163        Self::new(value.into_channel())
3164    }
3165}
3166
3167#[derive(Debug, Clone)]
3168pub struct RebootWatcherProxy {
3169    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3170}
3171
3172impl fidl::endpoints::Proxy for RebootWatcherProxy {
3173    type Protocol = RebootWatcherMarker;
3174
3175    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3176        Self::new(inner)
3177    }
3178
3179    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3180        self.client.into_channel().map_err(|client| Self { client })
3181    }
3182
3183    fn as_channel(&self) -> &::fidl::AsyncChannel {
3184        self.client.as_channel()
3185    }
3186}
3187
3188impl RebootWatcherProxy {
3189    /// Create a new Proxy for fuchsia.hardware.power.statecontrol/RebootWatcher.
3190    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3191        let protocol_name = <RebootWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3192        Self { client: fidl::client::Client::new(channel, protocol_name) }
3193    }
3194
3195    /// Get a Stream of events from the remote end of the protocol.
3196    ///
3197    /// # Panics
3198    ///
3199    /// Panics if the event stream was already taken.
3200    pub fn take_event_stream(&self) -> RebootWatcherEventStream {
3201        RebootWatcherEventStream { event_receiver: self.client.take_event_receiver() }
3202    }
3203
3204    pub fn r#on_reboot(
3205        &self,
3206        mut options: &RebootOptions,
3207    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3208        RebootWatcherProxyInterface::r#on_reboot(self, options)
3209    }
3210}
3211
3212impl RebootWatcherProxyInterface for RebootWatcherProxy {
3213    type OnRebootResponseFut =
3214        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3215    fn r#on_reboot(&self, mut options: &RebootOptions) -> Self::OnRebootResponseFut {
3216        fn _decode(
3217            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3218        ) -> Result<(), fidl::Error> {
3219            let _response = fidl::client::decode_transaction_body::<
3220                fidl::encoding::EmptyPayload,
3221                fidl::encoding::DefaultFuchsiaResourceDialect,
3222                0x5334bbbe774f13c3,
3223            >(_buf?)?;
3224            Ok(_response)
3225        }
3226        self.client.send_query_and_decode::<RebootWatcherOnRebootRequest, ()>(
3227            (options,),
3228            0x5334bbbe774f13c3,
3229            fidl::encoding::DynamicFlags::empty(),
3230            _decode,
3231        )
3232    }
3233}
3234
3235pub struct RebootWatcherEventStream {
3236    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3237}
3238
3239impl std::marker::Unpin for RebootWatcherEventStream {}
3240
3241impl futures::stream::FusedStream for RebootWatcherEventStream {
3242    fn is_terminated(&self) -> bool {
3243        self.event_receiver.is_terminated()
3244    }
3245}
3246
3247impl futures::Stream for RebootWatcherEventStream {
3248    type Item = Result<RebootWatcherEvent, fidl::Error>;
3249
3250    fn poll_next(
3251        mut self: std::pin::Pin<&mut Self>,
3252        cx: &mut std::task::Context<'_>,
3253    ) -> std::task::Poll<Option<Self::Item>> {
3254        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3255            &mut self.event_receiver,
3256            cx
3257        )?) {
3258            Some(buf) => std::task::Poll::Ready(Some(RebootWatcherEvent::decode(buf))),
3259            None => std::task::Poll::Ready(None),
3260        }
3261    }
3262}
3263
3264#[derive(Debug)]
3265pub enum RebootWatcherEvent {}
3266
3267impl RebootWatcherEvent {
3268    /// Decodes a message buffer as a [`RebootWatcherEvent`].
3269    fn decode(
3270        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3271    ) -> Result<RebootWatcherEvent, fidl::Error> {
3272        let (bytes, _handles) = buf.split_mut();
3273        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3274        debug_assert_eq!(tx_header.tx_id, 0);
3275        match tx_header.ordinal {
3276            _ => Err(fidl::Error::UnknownOrdinal {
3277                ordinal: tx_header.ordinal,
3278                protocol_name: <RebootWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3279            }),
3280        }
3281    }
3282}
3283
3284/// A Stream of incoming requests for fuchsia.hardware.power.statecontrol/RebootWatcher.
3285pub struct RebootWatcherRequestStream {
3286    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3287    is_terminated: bool,
3288}
3289
3290impl std::marker::Unpin for RebootWatcherRequestStream {}
3291
3292impl futures::stream::FusedStream for RebootWatcherRequestStream {
3293    fn is_terminated(&self) -> bool {
3294        self.is_terminated
3295    }
3296}
3297
3298impl fidl::endpoints::RequestStream for RebootWatcherRequestStream {
3299    type Protocol = RebootWatcherMarker;
3300    type ControlHandle = RebootWatcherControlHandle;
3301
3302    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3303        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3304    }
3305
3306    fn control_handle(&self) -> Self::ControlHandle {
3307        RebootWatcherControlHandle { inner: self.inner.clone() }
3308    }
3309
3310    fn into_inner(
3311        self,
3312    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3313    {
3314        (self.inner, self.is_terminated)
3315    }
3316
3317    fn from_inner(
3318        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3319        is_terminated: bool,
3320    ) -> Self {
3321        Self { inner, is_terminated }
3322    }
3323}
3324
3325impl futures::Stream for RebootWatcherRequestStream {
3326    type Item = Result<RebootWatcherRequest, fidl::Error>;
3327
3328    fn poll_next(
3329        mut self: std::pin::Pin<&mut Self>,
3330        cx: &mut std::task::Context<'_>,
3331    ) -> std::task::Poll<Option<Self::Item>> {
3332        let this = &mut *self;
3333        if this.inner.check_shutdown(cx) {
3334            this.is_terminated = true;
3335            return std::task::Poll::Ready(None);
3336        }
3337        if this.is_terminated {
3338            panic!("polled RebootWatcherRequestStream after completion");
3339        }
3340        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3341            |bytes, handles| {
3342                match this.inner.channel().read_etc(cx, bytes, handles) {
3343                    std::task::Poll::Ready(Ok(())) => {}
3344                    std::task::Poll::Pending => return std::task::Poll::Pending,
3345                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3346                        this.is_terminated = true;
3347                        return std::task::Poll::Ready(None);
3348                    }
3349                    std::task::Poll::Ready(Err(e)) => {
3350                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3351                            e.into(),
3352                        ))));
3353                    }
3354                }
3355
3356                // A message has been received from the channel
3357                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3358
3359                std::task::Poll::Ready(Some(match header.ordinal {
3360                    0x5334bbbe774f13c3 => {
3361                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3362                        let mut req = fidl::new_empty!(
3363                            RebootWatcherOnRebootRequest,
3364                            fidl::encoding::DefaultFuchsiaResourceDialect
3365                        );
3366                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RebootWatcherOnRebootRequest>(&header, _body_bytes, handles, &mut req)?;
3367                        let control_handle =
3368                            RebootWatcherControlHandle { inner: this.inner.clone() };
3369                        Ok(RebootWatcherRequest::OnReboot {
3370                            options: req.options,
3371
3372                            responder: RebootWatcherOnRebootResponder {
3373                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3374                                tx_id: header.tx_id,
3375                            },
3376                        })
3377                    }
3378                    _ => Err(fidl::Error::UnknownOrdinal {
3379                        ordinal: header.ordinal,
3380                        protocol_name:
3381                            <RebootWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3382                    }),
3383                }))
3384            },
3385        )
3386    }
3387}
3388
3389/// Allows components to be notified when Reboot related methods are called.
3390/// Watchers will be given 'MAX_REBOOT_WATCHER_RESPONSE_TIME_SECONDS' to return
3391/// before the system power state is changed. The channel will be used once to
3392/// send a notification to the watcher. Once the watcher responds or the timeout
3393/// expires, the channel will be closed by the client of RebootWatcher.
3394#[derive(Debug)]
3395pub enum RebootWatcherRequest {
3396    OnReboot { options: RebootOptions, responder: RebootWatcherOnRebootResponder },
3397}
3398
3399impl RebootWatcherRequest {
3400    #[allow(irrefutable_let_patterns)]
3401    pub fn into_on_reboot(self) -> Option<(RebootOptions, RebootWatcherOnRebootResponder)> {
3402        if let RebootWatcherRequest::OnReboot { options, responder } = self {
3403            Some((options, responder))
3404        } else {
3405            None
3406        }
3407    }
3408
3409    /// Name of the method defined in FIDL
3410    pub fn method_name(&self) -> &'static str {
3411        match *self {
3412            RebootWatcherRequest::OnReboot { .. } => "on_reboot",
3413        }
3414    }
3415}
3416
3417#[derive(Debug, Clone)]
3418pub struct RebootWatcherControlHandle {
3419    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3420}
3421
3422impl fidl::endpoints::ControlHandle for RebootWatcherControlHandle {
3423    fn shutdown(&self) {
3424        self.inner.shutdown()
3425    }
3426
3427    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3428        self.inner.shutdown_with_epitaph(status)
3429    }
3430
3431    fn is_closed(&self) -> bool {
3432        self.inner.channel().is_closed()
3433    }
3434    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3435        self.inner.channel().on_closed()
3436    }
3437
3438    #[cfg(target_os = "fuchsia")]
3439    fn signal_peer(
3440        &self,
3441        clear_mask: zx::Signals,
3442        set_mask: zx::Signals,
3443    ) -> Result<(), zx_status::Status> {
3444        use fidl::Peered;
3445        self.inner.channel().signal_peer(clear_mask, set_mask)
3446    }
3447}
3448
3449impl RebootWatcherControlHandle {}
3450
3451#[must_use = "FIDL methods require a response to be sent"]
3452#[derive(Debug)]
3453pub struct RebootWatcherOnRebootResponder {
3454    control_handle: std::mem::ManuallyDrop<RebootWatcherControlHandle>,
3455    tx_id: u32,
3456}
3457
3458/// Set the the channel to be shutdown (see [`RebootWatcherControlHandle::shutdown`])
3459/// if the responder is dropped without sending a response, so that the client
3460/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3461impl std::ops::Drop for RebootWatcherOnRebootResponder {
3462    fn drop(&mut self) {
3463        self.control_handle.shutdown();
3464        // Safety: drops once, never accessed again
3465        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3466    }
3467}
3468
3469impl fidl::endpoints::Responder for RebootWatcherOnRebootResponder {
3470    type ControlHandle = RebootWatcherControlHandle;
3471
3472    fn control_handle(&self) -> &RebootWatcherControlHandle {
3473        &self.control_handle
3474    }
3475
3476    fn drop_without_shutdown(mut self) {
3477        // Safety: drops once, never accessed again due to mem::forget
3478        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3479        // Prevent Drop from running (which would shut down the channel)
3480        std::mem::forget(self);
3481    }
3482}
3483
3484impl RebootWatcherOnRebootResponder {
3485    /// Sends a response to the FIDL transaction.
3486    ///
3487    /// Sets the channel to shutdown if an error occurs.
3488    pub fn send(self) -> Result<(), fidl::Error> {
3489        let _result = self.send_raw();
3490        if _result.is_err() {
3491            self.control_handle.shutdown();
3492        }
3493        self.drop_without_shutdown();
3494        _result
3495    }
3496
3497    /// Similar to "send" but does not shutdown the channel if an error occurs.
3498    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3499        let _result = self.send_raw();
3500        self.drop_without_shutdown();
3501        _result
3502    }
3503
3504    fn send_raw(&self) -> Result<(), fidl::Error> {
3505        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3506            (),
3507            self.tx_id,
3508            0x5334bbbe774f13c3,
3509            fidl::encoding::DynamicFlags::empty(),
3510        )
3511    }
3512}
3513
3514#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3515pub struct ShutdownWatcherMarker;
3516
3517impl fidl::endpoints::ProtocolMarker for ShutdownWatcherMarker {
3518    type Proxy = ShutdownWatcherProxy;
3519    type RequestStream = ShutdownWatcherRequestStream;
3520    #[cfg(target_os = "fuchsia")]
3521    type SynchronousProxy = ShutdownWatcherSynchronousProxy;
3522
3523    const DEBUG_NAME: &'static str = "(anonymous) ShutdownWatcher";
3524}
3525
3526pub trait ShutdownWatcherProxyInterface: Send + Sync {
3527    type OnShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3528    fn r#on_shutdown(&self, options: &ShutdownOptions) -> Self::OnShutdownResponseFut;
3529}
3530#[derive(Debug)]
3531#[cfg(target_os = "fuchsia")]
3532pub struct ShutdownWatcherSynchronousProxy {
3533    client: fidl::client::sync::Client,
3534}
3535
3536#[cfg(target_os = "fuchsia")]
3537impl fidl::endpoints::SynchronousProxy for ShutdownWatcherSynchronousProxy {
3538    type Proxy = ShutdownWatcherProxy;
3539    type Protocol = ShutdownWatcherMarker;
3540
3541    fn from_channel(inner: fidl::Channel) -> Self {
3542        Self::new(inner)
3543    }
3544
3545    fn into_channel(self) -> fidl::Channel {
3546        self.client.into_channel()
3547    }
3548
3549    fn as_channel(&self) -> &fidl::Channel {
3550        self.client.as_channel()
3551    }
3552}
3553
3554#[cfg(target_os = "fuchsia")]
3555impl ShutdownWatcherSynchronousProxy {
3556    pub fn new(channel: fidl::Channel) -> Self {
3557        let protocol_name = <ShutdownWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3558        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3559    }
3560
3561    pub fn into_channel(self) -> fidl::Channel {
3562        self.client.into_channel()
3563    }
3564
3565    /// Waits until an event arrives and returns it. It is safe for other
3566    /// threads to make concurrent requests while waiting for an event.
3567    pub fn wait_for_event(
3568        &self,
3569        deadline: zx::MonotonicInstant,
3570    ) -> Result<ShutdownWatcherEvent, fidl::Error> {
3571        ShutdownWatcherEvent::decode(self.client.wait_for_event(deadline)?)
3572    }
3573
3574    pub fn r#on_shutdown(
3575        &self,
3576        mut options: &ShutdownOptions,
3577        ___deadline: zx::MonotonicInstant,
3578    ) -> Result<(), fidl::Error> {
3579        let _response = self.client.send_query::<
3580            ShutdownWatcherOnShutdownRequest,
3581            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3582        >(
3583            (options,),
3584            0x1d9467990d7dc6db,
3585            fidl::encoding::DynamicFlags::FLEXIBLE,
3586            ___deadline,
3587        )?
3588        .into_result::<ShutdownWatcherMarker>("on_shutdown")?;
3589        Ok(_response)
3590    }
3591}
3592
3593#[cfg(target_os = "fuchsia")]
3594impl From<ShutdownWatcherSynchronousProxy> for zx::NullableHandle {
3595    fn from(value: ShutdownWatcherSynchronousProxy) -> Self {
3596        value.into_channel().into()
3597    }
3598}
3599
3600#[cfg(target_os = "fuchsia")]
3601impl From<fidl::Channel> for ShutdownWatcherSynchronousProxy {
3602    fn from(value: fidl::Channel) -> Self {
3603        Self::new(value)
3604    }
3605}
3606
3607#[cfg(target_os = "fuchsia")]
3608impl fidl::endpoints::FromClient for ShutdownWatcherSynchronousProxy {
3609    type Protocol = ShutdownWatcherMarker;
3610
3611    fn from_client(value: fidl::endpoints::ClientEnd<ShutdownWatcherMarker>) -> Self {
3612        Self::new(value.into_channel())
3613    }
3614}
3615
3616#[derive(Debug, Clone)]
3617pub struct ShutdownWatcherProxy {
3618    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3619}
3620
3621impl fidl::endpoints::Proxy for ShutdownWatcherProxy {
3622    type Protocol = ShutdownWatcherMarker;
3623
3624    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3625        Self::new(inner)
3626    }
3627
3628    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3629        self.client.into_channel().map_err(|client| Self { client })
3630    }
3631
3632    fn as_channel(&self) -> &::fidl::AsyncChannel {
3633        self.client.as_channel()
3634    }
3635}
3636
3637impl ShutdownWatcherProxy {
3638    /// Create a new Proxy for fuchsia.hardware.power.statecontrol/ShutdownWatcher.
3639    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3640        let protocol_name = <ShutdownWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3641        Self { client: fidl::client::Client::new(channel, protocol_name) }
3642    }
3643
3644    /// Get a Stream of events from the remote end of the protocol.
3645    ///
3646    /// # Panics
3647    ///
3648    /// Panics if the event stream was already taken.
3649    pub fn take_event_stream(&self) -> ShutdownWatcherEventStream {
3650        ShutdownWatcherEventStream { event_receiver: self.client.take_event_receiver() }
3651    }
3652
3653    pub fn r#on_shutdown(
3654        &self,
3655        mut options: &ShutdownOptions,
3656    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3657        ShutdownWatcherProxyInterface::r#on_shutdown(self, options)
3658    }
3659}
3660
3661impl ShutdownWatcherProxyInterface for ShutdownWatcherProxy {
3662    type OnShutdownResponseFut =
3663        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3664    fn r#on_shutdown(&self, mut options: &ShutdownOptions) -> Self::OnShutdownResponseFut {
3665        fn _decode(
3666            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3667        ) -> Result<(), fidl::Error> {
3668            let _response = fidl::client::decode_transaction_body::<
3669                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3670                fidl::encoding::DefaultFuchsiaResourceDialect,
3671                0x1d9467990d7dc6db,
3672            >(_buf?)?
3673            .into_result::<ShutdownWatcherMarker>("on_shutdown")?;
3674            Ok(_response)
3675        }
3676        self.client.send_query_and_decode::<ShutdownWatcherOnShutdownRequest, ()>(
3677            (options,),
3678            0x1d9467990d7dc6db,
3679            fidl::encoding::DynamicFlags::FLEXIBLE,
3680            _decode,
3681        )
3682    }
3683}
3684
3685pub struct ShutdownWatcherEventStream {
3686    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3687}
3688
3689impl std::marker::Unpin for ShutdownWatcherEventStream {}
3690
3691impl futures::stream::FusedStream for ShutdownWatcherEventStream {
3692    fn is_terminated(&self) -> bool {
3693        self.event_receiver.is_terminated()
3694    }
3695}
3696
3697impl futures::Stream for ShutdownWatcherEventStream {
3698    type Item = Result<ShutdownWatcherEvent, fidl::Error>;
3699
3700    fn poll_next(
3701        mut self: std::pin::Pin<&mut Self>,
3702        cx: &mut std::task::Context<'_>,
3703    ) -> std::task::Poll<Option<Self::Item>> {
3704        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3705            &mut self.event_receiver,
3706            cx
3707        )?) {
3708            Some(buf) => std::task::Poll::Ready(Some(ShutdownWatcherEvent::decode(buf))),
3709            None => std::task::Poll::Ready(None),
3710        }
3711    }
3712}
3713
3714#[derive(Debug)]
3715pub enum ShutdownWatcherEvent {
3716    #[non_exhaustive]
3717    _UnknownEvent {
3718        /// Ordinal of the event that was sent.
3719        ordinal: u64,
3720    },
3721}
3722
3723impl ShutdownWatcherEvent {
3724    /// Decodes a message buffer as a [`ShutdownWatcherEvent`].
3725    fn decode(
3726        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3727    ) -> Result<ShutdownWatcherEvent, fidl::Error> {
3728        let (bytes, _handles) = buf.split_mut();
3729        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3730        debug_assert_eq!(tx_header.tx_id, 0);
3731        match tx_header.ordinal {
3732            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3733                Ok(ShutdownWatcherEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3734            }
3735            _ => Err(fidl::Error::UnknownOrdinal {
3736                ordinal: tx_header.ordinal,
3737                protocol_name:
3738                    <ShutdownWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3739            }),
3740        }
3741    }
3742}
3743
3744/// A Stream of incoming requests for fuchsia.hardware.power.statecontrol/ShutdownWatcher.
3745pub struct ShutdownWatcherRequestStream {
3746    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3747    is_terminated: bool,
3748}
3749
3750impl std::marker::Unpin for ShutdownWatcherRequestStream {}
3751
3752impl futures::stream::FusedStream for ShutdownWatcherRequestStream {
3753    fn is_terminated(&self) -> bool {
3754        self.is_terminated
3755    }
3756}
3757
3758impl fidl::endpoints::RequestStream for ShutdownWatcherRequestStream {
3759    type Protocol = ShutdownWatcherMarker;
3760    type ControlHandle = ShutdownWatcherControlHandle;
3761
3762    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3763        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3764    }
3765
3766    fn control_handle(&self) -> Self::ControlHandle {
3767        ShutdownWatcherControlHandle { inner: self.inner.clone() }
3768    }
3769
3770    fn into_inner(
3771        self,
3772    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3773    {
3774        (self.inner, self.is_terminated)
3775    }
3776
3777    fn from_inner(
3778        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3779        is_terminated: bool,
3780    ) -> Self {
3781        Self { inner, is_terminated }
3782    }
3783}
3784
3785impl futures::Stream for ShutdownWatcherRequestStream {
3786    type Item = Result<ShutdownWatcherRequest, fidl::Error>;
3787
3788    fn poll_next(
3789        mut self: std::pin::Pin<&mut Self>,
3790        cx: &mut std::task::Context<'_>,
3791    ) -> std::task::Poll<Option<Self::Item>> {
3792        let this = &mut *self;
3793        if this.inner.check_shutdown(cx) {
3794            this.is_terminated = true;
3795            return std::task::Poll::Ready(None);
3796        }
3797        if this.is_terminated {
3798            panic!("polled ShutdownWatcherRequestStream after completion");
3799        }
3800        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3801            |bytes, handles| {
3802                match this.inner.channel().read_etc(cx, bytes, handles) {
3803                    std::task::Poll::Ready(Ok(())) => {}
3804                    std::task::Poll::Pending => return std::task::Poll::Pending,
3805                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3806                        this.is_terminated = true;
3807                        return std::task::Poll::Ready(None);
3808                    }
3809                    std::task::Poll::Ready(Err(e)) => {
3810                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3811                            e.into(),
3812                        ))));
3813                    }
3814                }
3815
3816                // A message has been received from the channel
3817                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3818
3819                std::task::Poll::Ready(Some(match header.ordinal {
3820                    0x1d9467990d7dc6db => {
3821                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3822                        let mut req = fidl::new_empty!(
3823                            ShutdownWatcherOnShutdownRequest,
3824                            fidl::encoding::DefaultFuchsiaResourceDialect
3825                        );
3826                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ShutdownWatcherOnShutdownRequest>(&header, _body_bytes, handles, &mut req)?;
3827                        let control_handle =
3828                            ShutdownWatcherControlHandle { inner: this.inner.clone() };
3829                        Ok(ShutdownWatcherRequest::OnShutdown {
3830                            options: req.options,
3831
3832                            responder: ShutdownWatcherOnShutdownResponder {
3833                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3834                                tx_id: header.tx_id,
3835                            },
3836                        })
3837                    }
3838                    _ if header.tx_id == 0
3839                        && header
3840                            .dynamic_flags()
3841                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3842                    {
3843                        Ok(ShutdownWatcherRequest::_UnknownMethod {
3844                            ordinal: header.ordinal,
3845                            control_handle: ShutdownWatcherControlHandle {
3846                                inner: this.inner.clone(),
3847                            },
3848                            method_type: fidl::MethodType::OneWay,
3849                        })
3850                    }
3851                    _ if header
3852                        .dynamic_flags()
3853                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3854                    {
3855                        this.inner.send_framework_err(
3856                            fidl::encoding::FrameworkErr::UnknownMethod,
3857                            header.tx_id,
3858                            header.ordinal,
3859                            header.dynamic_flags(),
3860                            (bytes, handles),
3861                        )?;
3862                        Ok(ShutdownWatcherRequest::_UnknownMethod {
3863                            ordinal: header.ordinal,
3864                            control_handle: ShutdownWatcherControlHandle {
3865                                inner: this.inner.clone(),
3866                            },
3867                            method_type: fidl::MethodType::TwoWay,
3868                        })
3869                    }
3870                    _ => Err(fidl::Error::UnknownOrdinal {
3871                        ordinal: header.ordinal,
3872                        protocol_name:
3873                            <ShutdownWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3874                    }),
3875                }))
3876            },
3877        )
3878    }
3879}
3880
3881/// Allows components to be notified when the Shutdown method is called.
3882/// Watchers will be given 'MAX_SHUTDOWN_WATCHER_RESPONSE_TIME_SECONDS' to return
3883/// before the system power state is changed. The channel will be used once to
3884/// send a notification to the watcher. Once the watcher responds or the timeout
3885/// expires, the channel will be closed by the client of ShutdownWatcher.
3886#[derive(Debug)]
3887pub enum ShutdownWatcherRequest {
3888    OnShutdown {
3889        options: ShutdownOptions,
3890        responder: ShutdownWatcherOnShutdownResponder,
3891    },
3892    /// An interaction was received which does not match any known method.
3893    #[non_exhaustive]
3894    _UnknownMethod {
3895        /// Ordinal of the method that was called.
3896        ordinal: u64,
3897        control_handle: ShutdownWatcherControlHandle,
3898        method_type: fidl::MethodType,
3899    },
3900}
3901
3902impl ShutdownWatcherRequest {
3903    #[allow(irrefutable_let_patterns)]
3904    pub fn into_on_shutdown(self) -> Option<(ShutdownOptions, ShutdownWatcherOnShutdownResponder)> {
3905        if let ShutdownWatcherRequest::OnShutdown { options, responder } = self {
3906            Some((options, responder))
3907        } else {
3908            None
3909        }
3910    }
3911
3912    /// Name of the method defined in FIDL
3913    pub fn method_name(&self) -> &'static str {
3914        match *self {
3915            ShutdownWatcherRequest::OnShutdown { .. } => "on_shutdown",
3916            ShutdownWatcherRequest::_UnknownMethod {
3917                method_type: fidl::MethodType::OneWay,
3918                ..
3919            } => "unknown one-way method",
3920            ShutdownWatcherRequest::_UnknownMethod {
3921                method_type: fidl::MethodType::TwoWay,
3922                ..
3923            } => "unknown two-way method",
3924        }
3925    }
3926}
3927
3928#[derive(Debug, Clone)]
3929pub struct ShutdownWatcherControlHandle {
3930    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3931}
3932
3933impl fidl::endpoints::ControlHandle for ShutdownWatcherControlHandle {
3934    fn shutdown(&self) {
3935        self.inner.shutdown()
3936    }
3937
3938    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3939        self.inner.shutdown_with_epitaph(status)
3940    }
3941
3942    fn is_closed(&self) -> bool {
3943        self.inner.channel().is_closed()
3944    }
3945    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3946        self.inner.channel().on_closed()
3947    }
3948
3949    #[cfg(target_os = "fuchsia")]
3950    fn signal_peer(
3951        &self,
3952        clear_mask: zx::Signals,
3953        set_mask: zx::Signals,
3954    ) -> Result<(), zx_status::Status> {
3955        use fidl::Peered;
3956        self.inner.channel().signal_peer(clear_mask, set_mask)
3957    }
3958}
3959
3960impl ShutdownWatcherControlHandle {}
3961
3962#[must_use = "FIDL methods require a response to be sent"]
3963#[derive(Debug)]
3964pub struct ShutdownWatcherOnShutdownResponder {
3965    control_handle: std::mem::ManuallyDrop<ShutdownWatcherControlHandle>,
3966    tx_id: u32,
3967}
3968
3969/// Set the the channel to be shutdown (see [`ShutdownWatcherControlHandle::shutdown`])
3970/// if the responder is dropped without sending a response, so that the client
3971/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3972impl std::ops::Drop for ShutdownWatcherOnShutdownResponder {
3973    fn drop(&mut self) {
3974        self.control_handle.shutdown();
3975        // Safety: drops once, never accessed again
3976        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3977    }
3978}
3979
3980impl fidl::endpoints::Responder for ShutdownWatcherOnShutdownResponder {
3981    type ControlHandle = ShutdownWatcherControlHandle;
3982
3983    fn control_handle(&self) -> &ShutdownWatcherControlHandle {
3984        &self.control_handle
3985    }
3986
3987    fn drop_without_shutdown(mut self) {
3988        // Safety: drops once, never accessed again due to mem::forget
3989        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3990        // Prevent Drop from running (which would shut down the channel)
3991        std::mem::forget(self);
3992    }
3993}
3994
3995impl ShutdownWatcherOnShutdownResponder {
3996    /// Sends a response to the FIDL transaction.
3997    ///
3998    /// Sets the channel to shutdown if an error occurs.
3999    pub fn send(self) -> Result<(), fidl::Error> {
4000        let _result = self.send_raw();
4001        if _result.is_err() {
4002            self.control_handle.shutdown();
4003        }
4004        self.drop_without_shutdown();
4005        _result
4006    }
4007
4008    /// Similar to "send" but does not shutdown the channel if an error occurs.
4009    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4010        let _result = self.send_raw();
4011        self.drop_without_shutdown();
4012        _result
4013    }
4014
4015    fn send_raw(&self) -> Result<(), fidl::Error> {
4016        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4017            fidl::encoding::Flexible::new(()),
4018            self.tx_id,
4019            0x1d9467990d7dc6db,
4020            fidl::encoding::DynamicFlags::FLEXIBLE,
4021        )
4022    }
4023}
4024
4025#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4026pub struct ShutdownWatcherRegisterMarker;
4027
4028impl fidl::endpoints::ProtocolMarker for ShutdownWatcherRegisterMarker {
4029    type Proxy = ShutdownWatcherRegisterProxy;
4030    type RequestStream = ShutdownWatcherRegisterRequestStream;
4031    #[cfg(target_os = "fuchsia")]
4032    type SynchronousProxy = ShutdownWatcherRegisterSynchronousProxy;
4033
4034    const DEBUG_NAME: &'static str = "fuchsia.hardware.power.statecontrol.ShutdownWatcherRegister";
4035}
4036impl fidl::endpoints::DiscoverableProtocolMarker for ShutdownWatcherRegisterMarker {}
4037
4038pub trait ShutdownWatcherRegisterProxyInterface: Send + Sync {
4039    type RegisterWatcherResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4040    fn r#register_watcher(
4041        &self,
4042        watcher: fidl::endpoints::ClientEnd<ShutdownWatcherMarker>,
4043    ) -> Self::RegisterWatcherResponseFut;
4044}
4045#[derive(Debug)]
4046#[cfg(target_os = "fuchsia")]
4047pub struct ShutdownWatcherRegisterSynchronousProxy {
4048    client: fidl::client::sync::Client,
4049}
4050
4051#[cfg(target_os = "fuchsia")]
4052impl fidl::endpoints::SynchronousProxy for ShutdownWatcherRegisterSynchronousProxy {
4053    type Proxy = ShutdownWatcherRegisterProxy;
4054    type Protocol = ShutdownWatcherRegisterMarker;
4055
4056    fn from_channel(inner: fidl::Channel) -> Self {
4057        Self::new(inner)
4058    }
4059
4060    fn into_channel(self) -> fidl::Channel {
4061        self.client.into_channel()
4062    }
4063
4064    fn as_channel(&self) -> &fidl::Channel {
4065        self.client.as_channel()
4066    }
4067}
4068
4069#[cfg(target_os = "fuchsia")]
4070impl ShutdownWatcherRegisterSynchronousProxy {
4071    pub fn new(channel: fidl::Channel) -> Self {
4072        let protocol_name =
4073            <ShutdownWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4074        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4075    }
4076
4077    pub fn into_channel(self) -> fidl::Channel {
4078        self.client.into_channel()
4079    }
4080
4081    /// Waits until an event arrives and returns it. It is safe for other
4082    /// threads to make concurrent requests while waiting for an event.
4083    pub fn wait_for_event(
4084        &self,
4085        deadline: zx::MonotonicInstant,
4086    ) -> Result<ShutdownWatcherRegisterEvent, fidl::Error> {
4087        ShutdownWatcherRegisterEvent::decode(self.client.wait_for_event(deadline)?)
4088    }
4089
4090    /// Registers a watcher to be notified when the Shutdown method is called.
4091    ///
4092    /// Once the watcher has been successfully registered with the server, then
4093    /// the request will be completed and the ShutdownWatcherRegister
4094    /// channel will be left open (though a client is free to close it at this
4095    /// time).
4096    ///
4097    /// If there is an error in registering the watcher, then the
4098    /// ShutdownWatcherRegister channel will be closed without completing
4099    /// the request.
4100    ///
4101    /// The provided `watcher` channel will be used at most once to notify the
4102    /// watcher of an impending shutdown and allow it the chance to respond.
4103    ///
4104    /// Watchers can unregister by closing their `ShutdownWatcher` channel.
4105    pub fn r#register_watcher(
4106        &self,
4107        mut watcher: fidl::endpoints::ClientEnd<ShutdownWatcherMarker>,
4108        ___deadline: zx::MonotonicInstant,
4109    ) -> Result<(), fidl::Error> {
4110        let _response = self.client.send_query::<
4111            ShutdownWatcherRegisterRegisterWatcherRequest,
4112            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
4113        >(
4114            (watcher,),
4115            0x3db6ce5d34810aff,
4116            fidl::encoding::DynamicFlags::FLEXIBLE,
4117            ___deadline,
4118        )?
4119        .into_result::<ShutdownWatcherRegisterMarker>("register_watcher")?;
4120        Ok(_response)
4121    }
4122}
4123
4124#[cfg(target_os = "fuchsia")]
4125impl From<ShutdownWatcherRegisterSynchronousProxy> for zx::NullableHandle {
4126    fn from(value: ShutdownWatcherRegisterSynchronousProxy) -> Self {
4127        value.into_channel().into()
4128    }
4129}
4130
4131#[cfg(target_os = "fuchsia")]
4132impl From<fidl::Channel> for ShutdownWatcherRegisterSynchronousProxy {
4133    fn from(value: fidl::Channel) -> Self {
4134        Self::new(value)
4135    }
4136}
4137
4138#[cfg(target_os = "fuchsia")]
4139impl fidl::endpoints::FromClient for ShutdownWatcherRegisterSynchronousProxy {
4140    type Protocol = ShutdownWatcherRegisterMarker;
4141
4142    fn from_client(value: fidl::endpoints::ClientEnd<ShutdownWatcherRegisterMarker>) -> Self {
4143        Self::new(value.into_channel())
4144    }
4145}
4146
4147#[derive(Debug, Clone)]
4148pub struct ShutdownWatcherRegisterProxy {
4149    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4150}
4151
4152impl fidl::endpoints::Proxy for ShutdownWatcherRegisterProxy {
4153    type Protocol = ShutdownWatcherRegisterMarker;
4154
4155    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4156        Self::new(inner)
4157    }
4158
4159    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4160        self.client.into_channel().map_err(|client| Self { client })
4161    }
4162
4163    fn as_channel(&self) -> &::fidl::AsyncChannel {
4164        self.client.as_channel()
4165    }
4166}
4167
4168impl ShutdownWatcherRegisterProxy {
4169    /// Create a new Proxy for fuchsia.hardware.power.statecontrol/ShutdownWatcherRegister.
4170    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4171        let protocol_name =
4172            <ShutdownWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4173        Self { client: fidl::client::Client::new(channel, protocol_name) }
4174    }
4175
4176    /// Get a Stream of events from the remote end of the protocol.
4177    ///
4178    /// # Panics
4179    ///
4180    /// Panics if the event stream was already taken.
4181    pub fn take_event_stream(&self) -> ShutdownWatcherRegisterEventStream {
4182        ShutdownWatcherRegisterEventStream { event_receiver: self.client.take_event_receiver() }
4183    }
4184
4185    /// Registers a watcher to be notified when the Shutdown method is called.
4186    ///
4187    /// Once the watcher has been successfully registered with the server, then
4188    /// the request will be completed and the ShutdownWatcherRegister
4189    /// channel will be left open (though a client is free to close it at this
4190    /// time).
4191    ///
4192    /// If there is an error in registering the watcher, then the
4193    /// ShutdownWatcherRegister channel will be closed without completing
4194    /// the request.
4195    ///
4196    /// The provided `watcher` channel will be used at most once to notify the
4197    /// watcher of an impending shutdown and allow it the chance to respond.
4198    ///
4199    /// Watchers can unregister by closing their `ShutdownWatcher` channel.
4200    pub fn r#register_watcher(
4201        &self,
4202        mut watcher: fidl::endpoints::ClientEnd<ShutdownWatcherMarker>,
4203    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4204        ShutdownWatcherRegisterProxyInterface::r#register_watcher(self, watcher)
4205    }
4206}
4207
4208impl ShutdownWatcherRegisterProxyInterface for ShutdownWatcherRegisterProxy {
4209    type RegisterWatcherResponseFut =
4210        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4211    fn r#register_watcher(
4212        &self,
4213        mut watcher: fidl::endpoints::ClientEnd<ShutdownWatcherMarker>,
4214    ) -> Self::RegisterWatcherResponseFut {
4215        fn _decode(
4216            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4217        ) -> Result<(), fidl::Error> {
4218            let _response = fidl::client::decode_transaction_body::<
4219                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
4220                fidl::encoding::DefaultFuchsiaResourceDialect,
4221                0x3db6ce5d34810aff,
4222            >(_buf?)?
4223            .into_result::<ShutdownWatcherRegisterMarker>("register_watcher")?;
4224            Ok(_response)
4225        }
4226        self.client.send_query_and_decode::<ShutdownWatcherRegisterRegisterWatcherRequest, ()>(
4227            (watcher,),
4228            0x3db6ce5d34810aff,
4229            fidl::encoding::DynamicFlags::FLEXIBLE,
4230            _decode,
4231        )
4232    }
4233}
4234
4235pub struct ShutdownWatcherRegisterEventStream {
4236    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4237}
4238
4239impl std::marker::Unpin for ShutdownWatcherRegisterEventStream {}
4240
4241impl futures::stream::FusedStream for ShutdownWatcherRegisterEventStream {
4242    fn is_terminated(&self) -> bool {
4243        self.event_receiver.is_terminated()
4244    }
4245}
4246
4247impl futures::Stream for ShutdownWatcherRegisterEventStream {
4248    type Item = Result<ShutdownWatcherRegisterEvent, fidl::Error>;
4249
4250    fn poll_next(
4251        mut self: std::pin::Pin<&mut Self>,
4252        cx: &mut std::task::Context<'_>,
4253    ) -> std::task::Poll<Option<Self::Item>> {
4254        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4255            &mut self.event_receiver,
4256            cx
4257        )?) {
4258            Some(buf) => std::task::Poll::Ready(Some(ShutdownWatcherRegisterEvent::decode(buf))),
4259            None => std::task::Poll::Ready(None),
4260        }
4261    }
4262}
4263
4264#[derive(Debug)]
4265pub enum ShutdownWatcherRegisterEvent {
4266    #[non_exhaustive]
4267    _UnknownEvent {
4268        /// Ordinal of the event that was sent.
4269        ordinal: u64,
4270    },
4271}
4272
4273impl ShutdownWatcherRegisterEvent {
4274    /// Decodes a message buffer as a [`ShutdownWatcherRegisterEvent`].
4275    fn decode(
4276        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4277    ) -> Result<ShutdownWatcherRegisterEvent, fidl::Error> {
4278        let (bytes, _handles) = buf.split_mut();
4279        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4280        debug_assert_eq!(tx_header.tx_id, 0);
4281        match tx_header.ordinal {
4282            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4283                Ok(ShutdownWatcherRegisterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4284            }
4285            _ => Err(fidl::Error::UnknownOrdinal {
4286                ordinal: tx_header.ordinal,
4287                protocol_name:
4288                    <ShutdownWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4289            }),
4290        }
4291    }
4292}
4293
4294/// A Stream of incoming requests for fuchsia.hardware.power.statecontrol/ShutdownWatcherRegister.
4295pub struct ShutdownWatcherRegisterRequestStream {
4296    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4297    is_terminated: bool,
4298}
4299
4300impl std::marker::Unpin for ShutdownWatcherRegisterRequestStream {}
4301
4302impl futures::stream::FusedStream for ShutdownWatcherRegisterRequestStream {
4303    fn is_terminated(&self) -> bool {
4304        self.is_terminated
4305    }
4306}
4307
4308impl fidl::endpoints::RequestStream for ShutdownWatcherRegisterRequestStream {
4309    type Protocol = ShutdownWatcherRegisterMarker;
4310    type ControlHandle = ShutdownWatcherRegisterControlHandle;
4311
4312    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4313        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4314    }
4315
4316    fn control_handle(&self) -> Self::ControlHandle {
4317        ShutdownWatcherRegisterControlHandle { inner: self.inner.clone() }
4318    }
4319
4320    fn into_inner(
4321        self,
4322    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4323    {
4324        (self.inner, self.is_terminated)
4325    }
4326
4327    fn from_inner(
4328        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4329        is_terminated: bool,
4330    ) -> Self {
4331        Self { inner, is_terminated }
4332    }
4333}
4334
4335impl futures::Stream for ShutdownWatcherRegisterRequestStream {
4336    type Item = Result<ShutdownWatcherRegisterRequest, fidl::Error>;
4337
4338    fn poll_next(
4339        mut self: std::pin::Pin<&mut Self>,
4340        cx: &mut std::task::Context<'_>,
4341    ) -> std::task::Poll<Option<Self::Item>> {
4342        let this = &mut *self;
4343        if this.inner.check_shutdown(cx) {
4344            this.is_terminated = true;
4345            return std::task::Poll::Ready(None);
4346        }
4347        if this.is_terminated {
4348            panic!("polled ShutdownWatcherRegisterRequestStream after completion");
4349        }
4350        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4351            |bytes, handles| {
4352                match this.inner.channel().read_etc(cx, bytes, handles) {
4353                    std::task::Poll::Ready(Ok(())) => {}
4354                    std::task::Poll::Pending => return std::task::Poll::Pending,
4355                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4356                        this.is_terminated = true;
4357                        return std::task::Poll::Ready(None);
4358                    }
4359                    std::task::Poll::Ready(Err(e)) => {
4360                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4361                            e.into(),
4362                        ))));
4363                    }
4364                }
4365
4366                // A message has been received from the channel
4367                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4368
4369                std::task::Poll::Ready(Some(match header.ordinal {
4370                0x3db6ce5d34810aff => {
4371                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4372                    let mut req = fidl::new_empty!(ShutdownWatcherRegisterRegisterWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4373                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ShutdownWatcherRegisterRegisterWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
4374                    let control_handle = ShutdownWatcherRegisterControlHandle {
4375                        inner: this.inner.clone(),
4376                    };
4377                    Ok(ShutdownWatcherRegisterRequest::RegisterWatcher {watcher: req.watcher,
4378
4379                        responder: ShutdownWatcherRegisterRegisterWatcherResponder {
4380                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4381                            tx_id: header.tx_id,
4382                        },
4383                    })
4384                }
4385                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4386                    Ok(ShutdownWatcherRegisterRequest::_UnknownMethod {
4387                        ordinal: header.ordinal,
4388                        control_handle: ShutdownWatcherRegisterControlHandle { inner: this.inner.clone() },
4389                        method_type: fidl::MethodType::OneWay,
4390                    })
4391                }
4392                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4393                    this.inner.send_framework_err(
4394                        fidl::encoding::FrameworkErr::UnknownMethod,
4395                        header.tx_id,
4396                        header.ordinal,
4397                        header.dynamic_flags(),
4398                        (bytes, handles),
4399                    )?;
4400                    Ok(ShutdownWatcherRegisterRequest::_UnknownMethod {
4401                        ordinal: header.ordinal,
4402                        control_handle: ShutdownWatcherRegisterControlHandle { inner: this.inner.clone() },
4403                        method_type: fidl::MethodType::TwoWay,
4404                    })
4405                }
4406                _ => Err(fidl::Error::UnknownOrdinal {
4407                    ordinal: header.ordinal,
4408                    protocol_name: <ShutdownWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4409                }),
4410            }))
4411            },
4412        )
4413    }
4414}
4415
4416/// Allows components to register a callback that will be executed when the Shutdown
4417/// method is called. The main purpose of this protocol is to be able to track
4418/// shutdown reasons. Consider relying on Component Framework's orderly shutdown
4419/// if you're looking at using this protocol.
4420#[derive(Debug)]
4421pub enum ShutdownWatcherRegisterRequest {
4422    /// Registers a watcher to be notified when the Shutdown method is called.
4423    ///
4424    /// Once the watcher has been successfully registered with the server, then
4425    /// the request will be completed and the ShutdownWatcherRegister
4426    /// channel will be left open (though a client is free to close it at this
4427    /// time).
4428    ///
4429    /// If there is an error in registering the watcher, then the
4430    /// ShutdownWatcherRegister channel will be closed without completing
4431    /// the request.
4432    ///
4433    /// The provided `watcher` channel will be used at most once to notify the
4434    /// watcher of an impending shutdown and allow it the chance to respond.
4435    ///
4436    /// Watchers can unregister by closing their `ShutdownWatcher` channel.
4437    RegisterWatcher {
4438        watcher: fidl::endpoints::ClientEnd<ShutdownWatcherMarker>,
4439        responder: ShutdownWatcherRegisterRegisterWatcherResponder,
4440    },
4441    /// An interaction was received which does not match any known method.
4442    #[non_exhaustive]
4443    _UnknownMethod {
4444        /// Ordinal of the method that was called.
4445        ordinal: u64,
4446        control_handle: ShutdownWatcherRegisterControlHandle,
4447        method_type: fidl::MethodType,
4448    },
4449}
4450
4451impl ShutdownWatcherRegisterRequest {
4452    #[allow(irrefutable_let_patterns)]
4453    pub fn into_register_watcher(
4454        self,
4455    ) -> Option<(
4456        fidl::endpoints::ClientEnd<ShutdownWatcherMarker>,
4457        ShutdownWatcherRegisterRegisterWatcherResponder,
4458    )> {
4459        if let ShutdownWatcherRegisterRequest::RegisterWatcher { watcher, responder } = self {
4460            Some((watcher, responder))
4461        } else {
4462            None
4463        }
4464    }
4465
4466    /// Name of the method defined in FIDL
4467    pub fn method_name(&self) -> &'static str {
4468        match *self {
4469            ShutdownWatcherRegisterRequest::RegisterWatcher { .. } => "register_watcher",
4470            ShutdownWatcherRegisterRequest::_UnknownMethod {
4471                method_type: fidl::MethodType::OneWay,
4472                ..
4473            } => "unknown one-way method",
4474            ShutdownWatcherRegisterRequest::_UnknownMethod {
4475                method_type: fidl::MethodType::TwoWay,
4476                ..
4477            } => "unknown two-way method",
4478        }
4479    }
4480}
4481
4482#[derive(Debug, Clone)]
4483pub struct ShutdownWatcherRegisterControlHandle {
4484    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4485}
4486
4487impl fidl::endpoints::ControlHandle for ShutdownWatcherRegisterControlHandle {
4488    fn shutdown(&self) {
4489        self.inner.shutdown()
4490    }
4491
4492    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4493        self.inner.shutdown_with_epitaph(status)
4494    }
4495
4496    fn is_closed(&self) -> bool {
4497        self.inner.channel().is_closed()
4498    }
4499    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4500        self.inner.channel().on_closed()
4501    }
4502
4503    #[cfg(target_os = "fuchsia")]
4504    fn signal_peer(
4505        &self,
4506        clear_mask: zx::Signals,
4507        set_mask: zx::Signals,
4508    ) -> Result<(), zx_status::Status> {
4509        use fidl::Peered;
4510        self.inner.channel().signal_peer(clear_mask, set_mask)
4511    }
4512}
4513
4514impl ShutdownWatcherRegisterControlHandle {}
4515
4516#[must_use = "FIDL methods require a response to be sent"]
4517#[derive(Debug)]
4518pub struct ShutdownWatcherRegisterRegisterWatcherResponder {
4519    control_handle: std::mem::ManuallyDrop<ShutdownWatcherRegisterControlHandle>,
4520    tx_id: u32,
4521}
4522
4523/// Set the the channel to be shutdown (see [`ShutdownWatcherRegisterControlHandle::shutdown`])
4524/// if the responder is dropped without sending a response, so that the client
4525/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4526impl std::ops::Drop for ShutdownWatcherRegisterRegisterWatcherResponder {
4527    fn drop(&mut self) {
4528        self.control_handle.shutdown();
4529        // Safety: drops once, never accessed again
4530        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4531    }
4532}
4533
4534impl fidl::endpoints::Responder for ShutdownWatcherRegisterRegisterWatcherResponder {
4535    type ControlHandle = ShutdownWatcherRegisterControlHandle;
4536
4537    fn control_handle(&self) -> &ShutdownWatcherRegisterControlHandle {
4538        &self.control_handle
4539    }
4540
4541    fn drop_without_shutdown(mut self) {
4542        // Safety: drops once, never accessed again due to mem::forget
4543        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4544        // Prevent Drop from running (which would shut down the channel)
4545        std::mem::forget(self);
4546    }
4547}
4548
4549impl ShutdownWatcherRegisterRegisterWatcherResponder {
4550    /// Sends a response to the FIDL transaction.
4551    ///
4552    /// Sets the channel to shutdown if an error occurs.
4553    pub fn send(self) -> Result<(), fidl::Error> {
4554        let _result = self.send_raw();
4555        if _result.is_err() {
4556            self.control_handle.shutdown();
4557        }
4558        self.drop_without_shutdown();
4559        _result
4560    }
4561
4562    /// Similar to "send" but does not shutdown the channel if an error occurs.
4563    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4564        let _result = self.send_raw();
4565        self.drop_without_shutdown();
4566        _result
4567    }
4568
4569    fn send_raw(&self) -> Result<(), fidl::Error> {
4570        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4571            fidl::encoding::Flexible::new(()),
4572            self.tx_id,
4573            0x3db6ce5d34810aff,
4574            fidl::encoding::DynamicFlags::FLEXIBLE,
4575        )
4576    }
4577}
4578
4579mod internal {
4580    use super::*;
4581
4582    impl fidl::encoding::ResourceTypeMarker for AdminMexecRequest {
4583        type Borrowed<'a> = &'a mut Self;
4584        fn take_or_borrow<'a>(
4585            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4586        ) -> Self::Borrowed<'a> {
4587            value
4588        }
4589    }
4590
4591    unsafe impl fidl::encoding::TypeMarker for AdminMexecRequest {
4592        type Owned = Self;
4593
4594        #[inline(always)]
4595        fn inline_align(_context: fidl::encoding::Context) -> usize {
4596            4
4597        }
4598
4599        #[inline(always)]
4600        fn inline_size(_context: fidl::encoding::Context) -> usize {
4601            8
4602        }
4603    }
4604
4605    unsafe impl
4606        fidl::encoding::Encode<AdminMexecRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4607        for &mut AdminMexecRequest
4608    {
4609        #[inline]
4610        unsafe fn encode(
4611            self,
4612            encoder: &mut fidl::encoding::Encoder<
4613                '_,
4614                fidl::encoding::DefaultFuchsiaResourceDialect,
4615            >,
4616            offset: usize,
4617            _depth: fidl::encoding::Depth,
4618        ) -> fidl::Result<()> {
4619            encoder.debug_check_bounds::<AdminMexecRequest>(offset);
4620            // Delegate to tuple encoding.
4621            fidl::encoding::Encode::<AdminMexecRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4622                (
4623                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.kernel_zbi),
4624                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.data_zbi),
4625                ),
4626                encoder, offset, _depth
4627            )
4628        }
4629    }
4630    unsafe impl<
4631        T0: fidl::encoding::Encode<
4632                fidl::encoding::HandleType<
4633                    fidl::Vmo,
4634                    { fidl::ObjectType::VMO.into_raw() },
4635                    2147483648,
4636                >,
4637                fidl::encoding::DefaultFuchsiaResourceDialect,
4638            >,
4639        T1: fidl::encoding::Encode<
4640                fidl::encoding::HandleType<
4641                    fidl::Vmo,
4642                    { fidl::ObjectType::VMO.into_raw() },
4643                    2147483648,
4644                >,
4645                fidl::encoding::DefaultFuchsiaResourceDialect,
4646            >,
4647    > fidl::encoding::Encode<AdminMexecRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4648        for (T0, T1)
4649    {
4650        #[inline]
4651        unsafe fn encode(
4652            self,
4653            encoder: &mut fidl::encoding::Encoder<
4654                '_,
4655                fidl::encoding::DefaultFuchsiaResourceDialect,
4656            >,
4657            offset: usize,
4658            depth: fidl::encoding::Depth,
4659        ) -> fidl::Result<()> {
4660            encoder.debug_check_bounds::<AdminMexecRequest>(offset);
4661            // Zero out padding regions. There's no need to apply masks
4662            // because the unmasked parts will be overwritten by fields.
4663            // Write the fields.
4664            self.0.encode(encoder, offset + 0, depth)?;
4665            self.1.encode(encoder, offset + 4, depth)?;
4666            Ok(())
4667        }
4668    }
4669
4670    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4671        for AdminMexecRequest
4672    {
4673        #[inline(always)]
4674        fn new_empty() -> Self {
4675            Self {
4676                kernel_zbi: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
4677                data_zbi: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
4678            }
4679        }
4680
4681        #[inline]
4682        unsafe fn decode(
4683            &mut self,
4684            decoder: &mut fidl::encoding::Decoder<
4685                '_,
4686                fidl::encoding::DefaultFuchsiaResourceDialect,
4687            >,
4688            offset: usize,
4689            _depth: fidl::encoding::Depth,
4690        ) -> fidl::Result<()> {
4691            decoder.debug_check_bounds::<Self>(offset);
4692            // Verify that padding bytes are zero.
4693            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.kernel_zbi, decoder, offset + 0, _depth)?;
4694            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.data_zbi, decoder, offset + 4, _depth)?;
4695            Ok(())
4696        }
4697    }
4698
4699    impl fidl::encoding::ResourceTypeMarker for RebootMethodsWatcherRegisterRegisterRequest {
4700        type Borrowed<'a> = &'a mut Self;
4701        fn take_or_borrow<'a>(
4702            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4703        ) -> Self::Borrowed<'a> {
4704            value
4705        }
4706    }
4707
4708    unsafe impl fidl::encoding::TypeMarker for RebootMethodsWatcherRegisterRegisterRequest {
4709        type Owned = Self;
4710
4711        #[inline(always)]
4712        fn inline_align(_context: fidl::encoding::Context) -> usize {
4713            4
4714        }
4715
4716        #[inline(always)]
4717        fn inline_size(_context: fidl::encoding::Context) -> usize {
4718            4
4719        }
4720    }
4721
4722    unsafe impl
4723        fidl::encoding::Encode<
4724            RebootMethodsWatcherRegisterRegisterRequest,
4725            fidl::encoding::DefaultFuchsiaResourceDialect,
4726        > for &mut RebootMethodsWatcherRegisterRegisterRequest
4727    {
4728        #[inline]
4729        unsafe fn encode(
4730            self,
4731            encoder: &mut fidl::encoding::Encoder<
4732                '_,
4733                fidl::encoding::DefaultFuchsiaResourceDialect,
4734            >,
4735            offset: usize,
4736            _depth: fidl::encoding::Depth,
4737        ) -> fidl::Result<()> {
4738            encoder.debug_check_bounds::<RebootMethodsWatcherRegisterRegisterRequest>(offset);
4739            // Delegate to tuple encoding.
4740            fidl::encoding::Encode::<
4741                RebootMethodsWatcherRegisterRegisterRequest,
4742                fidl::encoding::DefaultFuchsiaResourceDialect,
4743            >::encode(
4744                (
4745                    <fidl::encoding::Endpoint<
4746                        fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
4747                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4748                        &mut self.watcher
4749                    ),
4750                ),
4751                encoder,
4752                offset,
4753                _depth,
4754            )
4755        }
4756    }
4757    unsafe impl<
4758        T0: fidl::encoding::Encode<
4759                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>>,
4760                fidl::encoding::DefaultFuchsiaResourceDialect,
4761            >,
4762    >
4763        fidl::encoding::Encode<
4764            RebootMethodsWatcherRegisterRegisterRequest,
4765            fidl::encoding::DefaultFuchsiaResourceDialect,
4766        > for (T0,)
4767    {
4768        #[inline]
4769        unsafe fn encode(
4770            self,
4771            encoder: &mut fidl::encoding::Encoder<
4772                '_,
4773                fidl::encoding::DefaultFuchsiaResourceDialect,
4774            >,
4775            offset: usize,
4776            depth: fidl::encoding::Depth,
4777        ) -> fidl::Result<()> {
4778            encoder.debug_check_bounds::<RebootMethodsWatcherRegisterRegisterRequest>(offset);
4779            // Zero out padding regions. There's no need to apply masks
4780            // because the unmasked parts will be overwritten by fields.
4781            // Write the fields.
4782            self.0.encode(encoder, offset + 0, depth)?;
4783            Ok(())
4784        }
4785    }
4786
4787    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4788        for RebootMethodsWatcherRegisterRegisterRequest
4789    {
4790        #[inline(always)]
4791        fn new_empty() -> Self {
4792            Self {
4793                watcher: fidl::new_empty!(
4794                    fidl::encoding::Endpoint<
4795                        fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
4796                    >,
4797                    fidl::encoding::DefaultFuchsiaResourceDialect
4798                ),
4799            }
4800        }
4801
4802        #[inline]
4803        unsafe fn decode(
4804            &mut self,
4805            decoder: &mut fidl::encoding::Decoder<
4806                '_,
4807                fidl::encoding::DefaultFuchsiaResourceDialect,
4808            >,
4809            offset: usize,
4810            _depth: fidl::encoding::Depth,
4811        ) -> fidl::Result<()> {
4812            decoder.debug_check_bounds::<Self>(offset);
4813            // Verify that padding bytes are zero.
4814            fidl::decode!(
4815                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>>,
4816                fidl::encoding::DefaultFuchsiaResourceDialect,
4817                &mut self.watcher,
4818                decoder,
4819                offset + 0,
4820                _depth
4821            )?;
4822            Ok(())
4823        }
4824    }
4825
4826    impl fidl::encoding::ResourceTypeMarker for RebootMethodsWatcherRegisterRegisterWatcherRequest {
4827        type Borrowed<'a> = &'a mut Self;
4828        fn take_or_borrow<'a>(
4829            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4830        ) -> Self::Borrowed<'a> {
4831            value
4832        }
4833    }
4834
4835    unsafe impl fidl::encoding::TypeMarker for RebootMethodsWatcherRegisterRegisterWatcherRequest {
4836        type Owned = Self;
4837
4838        #[inline(always)]
4839        fn inline_align(_context: fidl::encoding::Context) -> usize {
4840            4
4841        }
4842
4843        #[inline(always)]
4844        fn inline_size(_context: fidl::encoding::Context) -> usize {
4845            4
4846        }
4847    }
4848
4849    unsafe impl
4850        fidl::encoding::Encode<
4851            RebootMethodsWatcherRegisterRegisterWatcherRequest,
4852            fidl::encoding::DefaultFuchsiaResourceDialect,
4853        > for &mut RebootMethodsWatcherRegisterRegisterWatcherRequest
4854    {
4855        #[inline]
4856        unsafe fn encode(
4857            self,
4858            encoder: &mut fidl::encoding::Encoder<
4859                '_,
4860                fidl::encoding::DefaultFuchsiaResourceDialect,
4861            >,
4862            offset: usize,
4863            _depth: fidl::encoding::Depth,
4864        ) -> fidl::Result<()> {
4865            encoder
4866                .debug_check_bounds::<RebootMethodsWatcherRegisterRegisterWatcherRequest>(offset);
4867            // Delegate to tuple encoding.
4868            fidl::encoding::Encode::<RebootMethodsWatcherRegisterRegisterWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4869                (
4870                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RebootWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
4871                ),
4872                encoder, offset, _depth
4873            )
4874        }
4875    }
4876    unsafe impl<
4877        T0: fidl::encoding::Encode<
4878                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RebootWatcherMarker>>,
4879                fidl::encoding::DefaultFuchsiaResourceDialect,
4880            >,
4881    >
4882        fidl::encoding::Encode<
4883            RebootMethodsWatcherRegisterRegisterWatcherRequest,
4884            fidl::encoding::DefaultFuchsiaResourceDialect,
4885        > for (T0,)
4886    {
4887        #[inline]
4888        unsafe fn encode(
4889            self,
4890            encoder: &mut fidl::encoding::Encoder<
4891                '_,
4892                fidl::encoding::DefaultFuchsiaResourceDialect,
4893            >,
4894            offset: usize,
4895            depth: fidl::encoding::Depth,
4896        ) -> fidl::Result<()> {
4897            encoder
4898                .debug_check_bounds::<RebootMethodsWatcherRegisterRegisterWatcherRequest>(offset);
4899            // Zero out padding regions. There's no need to apply masks
4900            // because the unmasked parts will be overwritten by fields.
4901            // Write the fields.
4902            self.0.encode(encoder, offset + 0, depth)?;
4903            Ok(())
4904        }
4905    }
4906
4907    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4908        for RebootMethodsWatcherRegisterRegisterWatcherRequest
4909    {
4910        #[inline(always)]
4911        fn new_empty() -> Self {
4912            Self {
4913                watcher: fidl::new_empty!(
4914                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RebootWatcherMarker>>,
4915                    fidl::encoding::DefaultFuchsiaResourceDialect
4916                ),
4917            }
4918        }
4919
4920        #[inline]
4921        unsafe fn decode(
4922            &mut self,
4923            decoder: &mut fidl::encoding::Decoder<
4924                '_,
4925                fidl::encoding::DefaultFuchsiaResourceDialect,
4926            >,
4927            offset: usize,
4928            _depth: fidl::encoding::Depth,
4929        ) -> fidl::Result<()> {
4930            decoder.debug_check_bounds::<Self>(offset);
4931            // Verify that padding bytes are zero.
4932            fidl::decode!(
4933                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RebootWatcherMarker>>,
4934                fidl::encoding::DefaultFuchsiaResourceDialect,
4935                &mut self.watcher,
4936                decoder,
4937                offset + 0,
4938                _depth
4939            )?;
4940            Ok(())
4941        }
4942    }
4943
4944    impl fidl::encoding::ResourceTypeMarker for RebootMethodsWatcherRegisterRegisterWithAckRequest {
4945        type Borrowed<'a> = &'a mut Self;
4946        fn take_or_borrow<'a>(
4947            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4948        ) -> Self::Borrowed<'a> {
4949            value
4950        }
4951    }
4952
4953    unsafe impl fidl::encoding::TypeMarker for RebootMethodsWatcherRegisterRegisterWithAckRequest {
4954        type Owned = Self;
4955
4956        #[inline(always)]
4957        fn inline_align(_context: fidl::encoding::Context) -> usize {
4958            4
4959        }
4960
4961        #[inline(always)]
4962        fn inline_size(_context: fidl::encoding::Context) -> usize {
4963            4
4964        }
4965    }
4966
4967    unsafe impl
4968        fidl::encoding::Encode<
4969            RebootMethodsWatcherRegisterRegisterWithAckRequest,
4970            fidl::encoding::DefaultFuchsiaResourceDialect,
4971        > for &mut RebootMethodsWatcherRegisterRegisterWithAckRequest
4972    {
4973        #[inline]
4974        unsafe fn encode(
4975            self,
4976            encoder: &mut fidl::encoding::Encoder<
4977                '_,
4978                fidl::encoding::DefaultFuchsiaResourceDialect,
4979            >,
4980            offset: usize,
4981            _depth: fidl::encoding::Depth,
4982        ) -> fidl::Result<()> {
4983            encoder
4984                .debug_check_bounds::<RebootMethodsWatcherRegisterRegisterWithAckRequest>(offset);
4985            // Delegate to tuple encoding.
4986            fidl::encoding::Encode::<
4987                RebootMethodsWatcherRegisterRegisterWithAckRequest,
4988                fidl::encoding::DefaultFuchsiaResourceDialect,
4989            >::encode(
4990                (
4991                    <fidl::encoding::Endpoint<
4992                        fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
4993                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4994                        &mut self.watcher
4995                    ),
4996                ),
4997                encoder,
4998                offset,
4999                _depth,
5000            )
5001        }
5002    }
5003    unsafe impl<
5004        T0: fidl::encoding::Encode<
5005                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>>,
5006                fidl::encoding::DefaultFuchsiaResourceDialect,
5007            >,
5008    >
5009        fidl::encoding::Encode<
5010            RebootMethodsWatcherRegisterRegisterWithAckRequest,
5011            fidl::encoding::DefaultFuchsiaResourceDialect,
5012        > for (T0,)
5013    {
5014        #[inline]
5015        unsafe fn encode(
5016            self,
5017            encoder: &mut fidl::encoding::Encoder<
5018                '_,
5019                fidl::encoding::DefaultFuchsiaResourceDialect,
5020            >,
5021            offset: usize,
5022            depth: fidl::encoding::Depth,
5023        ) -> fidl::Result<()> {
5024            encoder
5025                .debug_check_bounds::<RebootMethodsWatcherRegisterRegisterWithAckRequest>(offset);
5026            // Zero out padding regions. There's no need to apply masks
5027            // because the unmasked parts will be overwritten by fields.
5028            // Write the fields.
5029            self.0.encode(encoder, offset + 0, depth)?;
5030            Ok(())
5031        }
5032    }
5033
5034    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5035        for RebootMethodsWatcherRegisterRegisterWithAckRequest
5036    {
5037        #[inline(always)]
5038        fn new_empty() -> Self {
5039            Self {
5040                watcher: fidl::new_empty!(
5041                    fidl::encoding::Endpoint<
5042                        fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>,
5043                    >,
5044                    fidl::encoding::DefaultFuchsiaResourceDialect
5045                ),
5046            }
5047        }
5048
5049        #[inline]
5050        unsafe fn decode(
5051            &mut self,
5052            decoder: &mut fidl::encoding::Decoder<
5053                '_,
5054                fidl::encoding::DefaultFuchsiaResourceDialect,
5055            >,
5056            offset: usize,
5057            _depth: fidl::encoding::Depth,
5058        ) -> fidl::Result<()> {
5059            decoder.debug_check_bounds::<Self>(offset);
5060            // Verify that padding bytes are zero.
5061            fidl::decode!(
5062                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RebootMethodsWatcherMarker>>,
5063                fidl::encoding::DefaultFuchsiaResourceDialect,
5064                &mut self.watcher,
5065                decoder,
5066                offset + 0,
5067                _depth
5068            )?;
5069            Ok(())
5070        }
5071    }
5072
5073    impl fidl::encoding::ResourceTypeMarker for ShutdownWatcherRegisterRegisterWatcherRequest {
5074        type Borrowed<'a> = &'a mut Self;
5075        fn take_or_borrow<'a>(
5076            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5077        ) -> Self::Borrowed<'a> {
5078            value
5079        }
5080    }
5081
5082    unsafe impl fidl::encoding::TypeMarker for ShutdownWatcherRegisterRegisterWatcherRequest {
5083        type Owned = Self;
5084
5085        #[inline(always)]
5086        fn inline_align(_context: fidl::encoding::Context) -> usize {
5087            4
5088        }
5089
5090        #[inline(always)]
5091        fn inline_size(_context: fidl::encoding::Context) -> usize {
5092            4
5093        }
5094    }
5095
5096    unsafe impl
5097        fidl::encoding::Encode<
5098            ShutdownWatcherRegisterRegisterWatcherRequest,
5099            fidl::encoding::DefaultFuchsiaResourceDialect,
5100        > for &mut ShutdownWatcherRegisterRegisterWatcherRequest
5101    {
5102        #[inline]
5103        unsafe fn encode(
5104            self,
5105            encoder: &mut fidl::encoding::Encoder<
5106                '_,
5107                fidl::encoding::DefaultFuchsiaResourceDialect,
5108            >,
5109            offset: usize,
5110            _depth: fidl::encoding::Depth,
5111        ) -> fidl::Result<()> {
5112            encoder.debug_check_bounds::<ShutdownWatcherRegisterRegisterWatcherRequest>(offset);
5113            // Delegate to tuple encoding.
5114            fidl::encoding::Encode::<ShutdownWatcherRegisterRegisterWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5115                (
5116                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ShutdownWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
5117                ),
5118                encoder, offset, _depth
5119            )
5120        }
5121    }
5122    unsafe impl<
5123        T0: fidl::encoding::Encode<
5124                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ShutdownWatcherMarker>>,
5125                fidl::encoding::DefaultFuchsiaResourceDialect,
5126            >,
5127    >
5128        fidl::encoding::Encode<
5129            ShutdownWatcherRegisterRegisterWatcherRequest,
5130            fidl::encoding::DefaultFuchsiaResourceDialect,
5131        > for (T0,)
5132    {
5133        #[inline]
5134        unsafe fn encode(
5135            self,
5136            encoder: &mut fidl::encoding::Encoder<
5137                '_,
5138                fidl::encoding::DefaultFuchsiaResourceDialect,
5139            >,
5140            offset: usize,
5141            depth: fidl::encoding::Depth,
5142        ) -> fidl::Result<()> {
5143            encoder.debug_check_bounds::<ShutdownWatcherRegisterRegisterWatcherRequest>(offset);
5144            // Zero out padding regions. There's no need to apply masks
5145            // because the unmasked parts will be overwritten by fields.
5146            // Write the fields.
5147            self.0.encode(encoder, offset + 0, depth)?;
5148            Ok(())
5149        }
5150    }
5151
5152    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5153        for ShutdownWatcherRegisterRegisterWatcherRequest
5154    {
5155        #[inline(always)]
5156        fn new_empty() -> Self {
5157            Self {
5158                watcher: fidl::new_empty!(
5159                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ShutdownWatcherMarker>>,
5160                    fidl::encoding::DefaultFuchsiaResourceDialect
5161                ),
5162            }
5163        }
5164
5165        #[inline]
5166        unsafe fn decode(
5167            &mut self,
5168            decoder: &mut fidl::encoding::Decoder<
5169                '_,
5170                fidl::encoding::DefaultFuchsiaResourceDialect,
5171            >,
5172            offset: usize,
5173            _depth: fidl::encoding::Depth,
5174        ) -> fidl::Result<()> {
5175            decoder.debug_check_bounds::<Self>(offset);
5176            // Verify that padding bytes are zero.
5177            fidl::decode!(
5178                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ShutdownWatcherMarker>>,
5179                fidl::encoding::DefaultFuchsiaResourceDialect,
5180                &mut self.watcher,
5181                decoder,
5182                offset + 0,
5183                _depth
5184            )?;
5185            Ok(())
5186        }
5187    }
5188}