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 RebootMethodsWatcherRegisterRegisterWatcherRequest {
24    pub watcher: fidl::endpoints::ClientEnd<RebootWatcherMarker>,
25}
26
27impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
28    for RebootMethodsWatcherRegisterRegisterWatcherRequest
29{
30}
31
32#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
33pub struct ShutdownWatcherRegisterRegisterWatcherRequest {
34    pub watcher: fidl::endpoints::ClientEnd<ShutdownWatcherMarker>,
35}
36
37impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
38    for ShutdownWatcherRegisterRegisterWatcherRequest
39{
40}
41
42#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
43pub struct AdminMarker;
44
45impl fidl::endpoints::ProtocolMarker for AdminMarker {
46    type Proxy = AdminProxy;
47    type RequestStream = AdminRequestStream;
48    #[cfg(target_os = "fuchsia")]
49    type SynchronousProxy = AdminSynchronousProxy;
50
51    const DEBUG_NAME: &'static str = "fuchsia.hardware.power.statecontrol.Admin";
52}
53impl fidl::endpoints::DiscoverableProtocolMarker for AdminMarker {}
54pub type AdminPowerFullyOnResult = Result<(), i32>;
55pub type AdminShutdownResult = Result<(), i32>;
56pub type AdminPerformRebootResult = Result<(), i32>;
57pub type AdminRebootToBootloaderResult = Result<(), i32>;
58pub type AdminRebootToRecoveryResult = Result<(), i32>;
59pub type AdminPoweroffResult = Result<(), i32>;
60pub type AdminMexecResult = Result<(), i32>;
61pub type AdminSuspendToRamResult = Result<(), i32>;
62
63pub trait AdminProxyInterface: Send + Sync {
64    type PowerFullyOnResponseFut: std::future::Future<Output = Result<AdminPowerFullyOnResult, fidl::Error>>
65        + Send;
66    fn r#power_fully_on(&self) -> Self::PowerFullyOnResponseFut;
67    type ShutdownResponseFut: std::future::Future<Output = Result<AdminShutdownResult, fidl::Error>>
68        + Send;
69    fn r#shutdown(&self, options: &ShutdownOptions) -> Self::ShutdownResponseFut;
70    type PerformRebootResponseFut: std::future::Future<Output = Result<AdminPerformRebootResult, fidl::Error>>
71        + Send;
72    fn r#perform_reboot(&self, options: &RebootOptions) -> Self::PerformRebootResponseFut;
73    type RebootToBootloaderResponseFut: std::future::Future<Output = Result<AdminRebootToBootloaderResult, fidl::Error>>
74        + Send;
75    fn r#reboot_to_bootloader(&self) -> Self::RebootToBootloaderResponseFut;
76    type RebootToRecoveryResponseFut: std::future::Future<Output = Result<AdminRebootToRecoveryResult, fidl::Error>>
77        + Send;
78    fn r#reboot_to_recovery(&self) -> Self::RebootToRecoveryResponseFut;
79    type PoweroffResponseFut: std::future::Future<Output = Result<AdminPoweroffResult, fidl::Error>>
80        + Send;
81    fn r#poweroff(&self) -> Self::PoweroffResponseFut;
82    type MexecResponseFut: std::future::Future<Output = Result<AdminMexecResult, fidl::Error>>
83        + Send;
84    fn r#mexec(&self, kernel_zbi: fidl::Vmo, data_zbi: fidl::Vmo) -> Self::MexecResponseFut;
85    type SuspendToRamResponseFut: std::future::Future<Output = Result<AdminSuspendToRamResult, fidl::Error>>
86        + Send;
87    fn r#suspend_to_ram(&self) -> Self::SuspendToRamResponseFut;
88}
89#[derive(Debug)]
90#[cfg(target_os = "fuchsia")]
91pub struct AdminSynchronousProxy {
92    client: fidl::client::sync::Client,
93}
94
95#[cfg(target_os = "fuchsia")]
96impl fidl::endpoints::SynchronousProxy for AdminSynchronousProxy {
97    type Proxy = AdminProxy;
98    type Protocol = AdminMarker;
99
100    fn from_channel(inner: fidl::Channel) -> Self {
101        Self::new(inner)
102    }
103
104    fn into_channel(self) -> fidl::Channel {
105        self.client.into_channel()
106    }
107
108    fn as_channel(&self) -> &fidl::Channel {
109        self.client.as_channel()
110    }
111}
112
113#[cfg(target_os = "fuchsia")]
114impl AdminSynchronousProxy {
115    pub fn new(channel: fidl::Channel) -> Self {
116        let protocol_name = <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
117        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
118    }
119
120    pub fn into_channel(self) -> fidl::Channel {
121        self.client.into_channel()
122    }
123
124    /// Waits until an event arrives and returns it. It is safe for other
125    /// threads to make concurrent requests while waiting for an event.
126    pub fn wait_for_event(
127        &self,
128        deadline: zx::MonotonicInstant,
129    ) -> Result<AdminEvent, fidl::Error> {
130        AdminEvent::decode(self.client.wait_for_event(deadline)?)
131    }
132
133    /// Asks the device to enter a fully on state.
134    pub fn r#power_fully_on(
135        &self,
136        ___deadline: zx::MonotonicInstant,
137    ) -> Result<AdminPowerFullyOnResult, fidl::Error> {
138        let _response = self.client.send_query::<
139            fidl::encoding::EmptyPayload,
140            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
141        >(
142            (),
143            0xb3272d15e00712f,
144            fidl::encoding::DynamicFlags::empty(),
145            ___deadline,
146        )?;
147        Ok(_response.map(|x| x))
148    }
149
150    /// Asks the device to enter the state specified by `options.action`.
151    ///
152    /// Arguments:
153    ///   - options: The options with which to perform this request.
154    ///              `ZX_ERR_INVALID_ARGS` is returned if `action` is absent.
155    ///              `reasons` may be omitted, but adding a new enum value
156    ///              instead is strongly encouraged.
157    pub fn r#shutdown(
158        &self,
159        mut options: &ShutdownOptions,
160        ___deadline: zx::MonotonicInstant,
161    ) -> Result<AdminShutdownResult, fidl::Error> {
162        let _response = self.client.send_query::<
163            AdminShutdownRequest,
164            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
165        >(
166            (options,),
167            0x3722c53e45dc022f,
168            fidl::encoding::DynamicFlags::empty(),
169            ___deadline,
170        )?;
171        Ok(_response.map(|x| x))
172    }
173
174    /// Asks the device to reboot.
175    ///
176    /// Arguments:
177    ///   - options: The options with which to perform this requests.
178    ///              `ZX_ERR_INVALID_ARGS` is returned if the options are
179    ///              malformed (i.e. `reasons` is absent or empty).
180    ///
181    /// # Deprecation
182    ///
183    /// Use Shutdown, which allows callers to specify the intended action and reasons for the
184    /// action.
185    pub fn r#perform_reboot(
186        &self,
187        mut options: &RebootOptions,
188        ___deadline: zx::MonotonicInstant,
189    ) -> Result<AdminPerformRebootResult, fidl::Error> {
190        let _response = self.client.send_query::<
191            AdminPerformRebootRequest,
192            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
193        >(
194            (options,),
195            0x9416b4d36a80b4,
196            fidl::encoding::DynamicFlags::empty(),
197            ___deadline,
198        )?;
199        Ok(_response.map(|x| x))
200    }
201
202    /// Asks the device to reboot into the bootloader.
203    ///
204    /// # Deprecation
205    ///
206    /// Use Shutdown, which allows callers to specify reasons why they are requesting a reboot to
207    /// bootloader.
208    pub fn r#reboot_to_bootloader(
209        &self,
210        ___deadline: zx::MonotonicInstant,
211    ) -> Result<AdminRebootToBootloaderResult, fidl::Error> {
212        let _response = self.client.send_query::<
213            fidl::encoding::EmptyPayload,
214            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
215        >(
216            (),
217            0x6dce331b33786aa,
218            fidl::encoding::DynamicFlags::empty(),
219            ___deadline,
220        )?;
221        Ok(_response.map(|x| x))
222    }
223
224    /// Asks the device to reboot into the recovery partition.
225    ///
226    /// # Deprecation
227    ///
228    /// Use Shutdown, which allows callers to specify reasons why they are requesting a reboot to
229    /// recovery.
230    pub fn r#reboot_to_recovery(
231        &self,
232        ___deadline: zx::MonotonicInstant,
233    ) -> Result<AdminRebootToRecoveryResult, fidl::Error> {
234        let _response = self.client.send_query::<
235            fidl::encoding::EmptyPayload,
236            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
237        >(
238            (),
239            0x1575c566be54f505,
240            fidl::encoding::DynamicFlags::empty(),
241            ___deadline,
242        )?;
243        Ok(_response.map(|x| x))
244    }
245
246    /// Asks all devices to enter a powered off state.
247    ///
248    /// # Deprecation
249    ///
250    /// Use Shutdown, which allows callers to specify reasons why they are requesting a poweroff.
251    pub fn r#poweroff(
252        &self,
253        ___deadline: zx::MonotonicInstant,
254    ) -> Result<AdminPoweroffResult, fidl::Error> {
255        let _response = self.client.send_query::<
256            fidl::encoding::EmptyPayload,
257            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
258        >(
259            (),
260            0x24101c5d0b439748,
261            fidl::encoding::DynamicFlags::empty(),
262            ___deadline,
263        )?;
264        Ok(_response.map(|x| x))
265    }
266
267    /// Performs a kernel mexec.
268    ///
269    /// It is expected that the ZBI items specified by
270    /// `zx_system_mexec_payload_get()` have not yet been appended to the
271    /// provided data ZBI.
272    pub fn r#mexec(
273        &self,
274        mut kernel_zbi: fidl::Vmo,
275        mut data_zbi: fidl::Vmo,
276        ___deadline: zx::MonotonicInstant,
277    ) -> Result<AdminMexecResult, fidl::Error> {
278        let _response = self.client.send_query::<
279            AdminMexecRequest,
280            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
281        >(
282            (kernel_zbi, data_zbi,),
283            0x1f91e77ec781a4c6,
284            fidl::encoding::DynamicFlags::empty(),
285            ___deadline,
286        )?;
287        Ok(_response.map(|x| x))
288    }
289
290    /// Asks the device to enter the suspend to RAM (S3) power state. Currently only supported on
291    /// x64. If a system state transition is already in progress then ZX_ERR_ALREADY_EXISTS is
292    /// returned. If the device fails to reach the suspend power state then ZX_ERR_INTERNAL is
293    /// returned. If the device successfully suspends, ZX_OK is returned when the device resumes.
294    pub fn r#suspend_to_ram(
295        &self,
296        ___deadline: zx::MonotonicInstant,
297    ) -> Result<AdminSuspendToRamResult, fidl::Error> {
298        let _response = self.client.send_query::<
299            fidl::encoding::EmptyPayload,
300            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
301        >(
302            (),
303            0x3b0e356782e7620e,
304            fidl::encoding::DynamicFlags::empty(),
305            ___deadline,
306        )?;
307        Ok(_response.map(|x| x))
308    }
309}
310
311#[cfg(target_os = "fuchsia")]
312impl From<AdminSynchronousProxy> for zx::NullableHandle {
313    fn from(value: AdminSynchronousProxy) -> Self {
314        value.into_channel().into()
315    }
316}
317
318#[cfg(target_os = "fuchsia")]
319impl From<fidl::Channel> for AdminSynchronousProxy {
320    fn from(value: fidl::Channel) -> Self {
321        Self::new(value)
322    }
323}
324
325#[cfg(target_os = "fuchsia")]
326impl fidl::endpoints::FromClient for AdminSynchronousProxy {
327    type Protocol = AdminMarker;
328
329    fn from_client(value: fidl::endpoints::ClientEnd<AdminMarker>) -> Self {
330        Self::new(value.into_channel())
331    }
332}
333
334#[derive(Debug, Clone)]
335pub struct AdminProxy {
336    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
337}
338
339impl fidl::endpoints::Proxy for AdminProxy {
340    type Protocol = AdminMarker;
341
342    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
343        Self::new(inner)
344    }
345
346    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
347        self.client.into_channel().map_err(|client| Self { client })
348    }
349
350    fn as_channel(&self) -> &::fidl::AsyncChannel {
351        self.client.as_channel()
352    }
353}
354
355impl AdminProxy {
356    /// Create a new Proxy for fuchsia.hardware.power.statecontrol/Admin.
357    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
358        let protocol_name = <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
359        Self { client: fidl::client::Client::new(channel, protocol_name) }
360    }
361
362    /// Get a Stream of events from the remote end of the protocol.
363    ///
364    /// # Panics
365    ///
366    /// Panics if the event stream was already taken.
367    pub fn take_event_stream(&self) -> AdminEventStream {
368        AdminEventStream { event_receiver: self.client.take_event_receiver() }
369    }
370
371    /// Asks the device to enter a fully on state.
372    pub fn r#power_fully_on(
373        &self,
374    ) -> fidl::client::QueryResponseFut<
375        AdminPowerFullyOnResult,
376        fidl::encoding::DefaultFuchsiaResourceDialect,
377    > {
378        AdminProxyInterface::r#power_fully_on(self)
379    }
380
381    /// Asks the device to enter the state specified by `options.action`.
382    ///
383    /// Arguments:
384    ///   - options: The options with which to perform this request.
385    ///              `ZX_ERR_INVALID_ARGS` is returned if `action` is absent.
386    ///              `reasons` may be omitted, but adding a new enum value
387    ///              instead is strongly encouraged.
388    pub fn r#shutdown(
389        &self,
390        mut options: &ShutdownOptions,
391    ) -> fidl::client::QueryResponseFut<
392        AdminShutdownResult,
393        fidl::encoding::DefaultFuchsiaResourceDialect,
394    > {
395        AdminProxyInterface::r#shutdown(self, options)
396    }
397
398    /// Asks the device to reboot.
399    ///
400    /// Arguments:
401    ///   - options: The options with which to perform this requests.
402    ///              `ZX_ERR_INVALID_ARGS` is returned if the options are
403    ///              malformed (i.e. `reasons` is absent or empty).
404    ///
405    /// # Deprecation
406    ///
407    /// Use Shutdown, which allows callers to specify the intended action and reasons for the
408    /// action.
409    pub fn r#perform_reboot(
410        &self,
411        mut options: &RebootOptions,
412    ) -> fidl::client::QueryResponseFut<
413        AdminPerformRebootResult,
414        fidl::encoding::DefaultFuchsiaResourceDialect,
415    > {
416        AdminProxyInterface::r#perform_reboot(self, options)
417    }
418
419    /// Asks the device to reboot into the bootloader.
420    ///
421    /// # Deprecation
422    ///
423    /// Use Shutdown, which allows callers to specify reasons why they are requesting a reboot to
424    /// bootloader.
425    pub fn r#reboot_to_bootloader(
426        &self,
427    ) -> fidl::client::QueryResponseFut<
428        AdminRebootToBootloaderResult,
429        fidl::encoding::DefaultFuchsiaResourceDialect,
430    > {
431        AdminProxyInterface::r#reboot_to_bootloader(self)
432    }
433
434    /// Asks the device to reboot into the recovery partition.
435    ///
436    /// # Deprecation
437    ///
438    /// Use Shutdown, which allows callers to specify reasons why they are requesting a reboot to
439    /// recovery.
440    pub fn r#reboot_to_recovery(
441        &self,
442    ) -> fidl::client::QueryResponseFut<
443        AdminRebootToRecoveryResult,
444        fidl::encoding::DefaultFuchsiaResourceDialect,
445    > {
446        AdminProxyInterface::r#reboot_to_recovery(self)
447    }
448
449    /// Asks all devices to enter a powered off state.
450    ///
451    /// # Deprecation
452    ///
453    /// Use Shutdown, which allows callers to specify reasons why they are requesting a poweroff.
454    pub fn r#poweroff(
455        &self,
456    ) -> fidl::client::QueryResponseFut<
457        AdminPoweroffResult,
458        fidl::encoding::DefaultFuchsiaResourceDialect,
459    > {
460        AdminProxyInterface::r#poweroff(self)
461    }
462
463    /// Performs a kernel mexec.
464    ///
465    /// It is expected that the ZBI items specified by
466    /// `zx_system_mexec_payload_get()` have not yet been appended to the
467    /// provided data ZBI.
468    pub fn r#mexec(
469        &self,
470        mut kernel_zbi: fidl::Vmo,
471        mut data_zbi: fidl::Vmo,
472    ) -> fidl::client::QueryResponseFut<
473        AdminMexecResult,
474        fidl::encoding::DefaultFuchsiaResourceDialect,
475    > {
476        AdminProxyInterface::r#mexec(self, kernel_zbi, data_zbi)
477    }
478
479    /// Asks the device to enter the suspend to RAM (S3) power state. Currently only supported on
480    /// x64. If a system state transition is already in progress then ZX_ERR_ALREADY_EXISTS is
481    /// returned. If the device fails to reach the suspend power state then ZX_ERR_INTERNAL is
482    /// returned. If the device successfully suspends, ZX_OK is returned when the device resumes.
483    pub fn r#suspend_to_ram(
484        &self,
485    ) -> fidl::client::QueryResponseFut<
486        AdminSuspendToRamResult,
487        fidl::encoding::DefaultFuchsiaResourceDialect,
488    > {
489        AdminProxyInterface::r#suspend_to_ram(self)
490    }
491}
492
493impl AdminProxyInterface for AdminProxy {
494    type PowerFullyOnResponseFut = fidl::client::QueryResponseFut<
495        AdminPowerFullyOnResult,
496        fidl::encoding::DefaultFuchsiaResourceDialect,
497    >;
498    fn r#power_fully_on(&self) -> Self::PowerFullyOnResponseFut {
499        fn _decode(
500            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
501        ) -> Result<AdminPowerFullyOnResult, fidl::Error> {
502            let _response = fidl::client::decode_transaction_body::<
503                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
504                fidl::encoding::DefaultFuchsiaResourceDialect,
505                0xb3272d15e00712f,
506            >(_buf?)?;
507            Ok(_response.map(|x| x))
508        }
509        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AdminPowerFullyOnResult>(
510            (),
511            0xb3272d15e00712f,
512            fidl::encoding::DynamicFlags::empty(),
513            _decode,
514        )
515    }
516
517    type ShutdownResponseFut = fidl::client::QueryResponseFut<
518        AdminShutdownResult,
519        fidl::encoding::DefaultFuchsiaResourceDialect,
520    >;
521    fn r#shutdown(&self, mut options: &ShutdownOptions) -> Self::ShutdownResponseFut {
522        fn _decode(
523            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
524        ) -> Result<AdminShutdownResult, fidl::Error> {
525            let _response = fidl::client::decode_transaction_body::<
526                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
527                fidl::encoding::DefaultFuchsiaResourceDialect,
528                0x3722c53e45dc022f,
529            >(_buf?)?;
530            Ok(_response.map(|x| x))
531        }
532        self.client.send_query_and_decode::<AdminShutdownRequest, AdminShutdownResult>(
533            (options,),
534            0x3722c53e45dc022f,
535            fidl::encoding::DynamicFlags::empty(),
536            _decode,
537        )
538    }
539
540    type PerformRebootResponseFut = fidl::client::QueryResponseFut<
541        AdminPerformRebootResult,
542        fidl::encoding::DefaultFuchsiaResourceDialect,
543    >;
544    fn r#perform_reboot(&self, mut options: &RebootOptions) -> Self::PerformRebootResponseFut {
545        fn _decode(
546            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
547        ) -> Result<AdminPerformRebootResult, fidl::Error> {
548            let _response = fidl::client::decode_transaction_body::<
549                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
550                fidl::encoding::DefaultFuchsiaResourceDialect,
551                0x9416b4d36a80b4,
552            >(_buf?)?;
553            Ok(_response.map(|x| x))
554        }
555        self.client.send_query_and_decode::<AdminPerformRebootRequest, AdminPerformRebootResult>(
556            (options,),
557            0x9416b4d36a80b4,
558            fidl::encoding::DynamicFlags::empty(),
559            _decode,
560        )
561    }
562
563    type RebootToBootloaderResponseFut = fidl::client::QueryResponseFut<
564        AdminRebootToBootloaderResult,
565        fidl::encoding::DefaultFuchsiaResourceDialect,
566    >;
567    fn r#reboot_to_bootloader(&self) -> Self::RebootToBootloaderResponseFut {
568        fn _decode(
569            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
570        ) -> Result<AdminRebootToBootloaderResult, fidl::Error> {
571            let _response = fidl::client::decode_transaction_body::<
572                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
573                fidl::encoding::DefaultFuchsiaResourceDialect,
574                0x6dce331b33786aa,
575            >(_buf?)?;
576            Ok(_response.map(|x| x))
577        }
578        self.client
579            .send_query_and_decode::<fidl::encoding::EmptyPayload, AdminRebootToBootloaderResult>(
580                (),
581                0x6dce331b33786aa,
582                fidl::encoding::DynamicFlags::empty(),
583                _decode,
584            )
585    }
586
587    type RebootToRecoveryResponseFut = fidl::client::QueryResponseFut<
588        AdminRebootToRecoveryResult,
589        fidl::encoding::DefaultFuchsiaResourceDialect,
590    >;
591    fn r#reboot_to_recovery(&self) -> Self::RebootToRecoveryResponseFut {
592        fn _decode(
593            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
594        ) -> Result<AdminRebootToRecoveryResult, fidl::Error> {
595            let _response = fidl::client::decode_transaction_body::<
596                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
597                fidl::encoding::DefaultFuchsiaResourceDialect,
598                0x1575c566be54f505,
599            >(_buf?)?;
600            Ok(_response.map(|x| x))
601        }
602        self.client
603            .send_query_and_decode::<fidl::encoding::EmptyPayload, AdminRebootToRecoveryResult>(
604                (),
605                0x1575c566be54f505,
606                fidl::encoding::DynamicFlags::empty(),
607                _decode,
608            )
609    }
610
611    type PoweroffResponseFut = fidl::client::QueryResponseFut<
612        AdminPoweroffResult,
613        fidl::encoding::DefaultFuchsiaResourceDialect,
614    >;
615    fn r#poweroff(&self) -> Self::PoweroffResponseFut {
616        fn _decode(
617            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
618        ) -> Result<AdminPoweroffResult, fidl::Error> {
619            let _response = fidl::client::decode_transaction_body::<
620                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
621                fidl::encoding::DefaultFuchsiaResourceDialect,
622                0x24101c5d0b439748,
623            >(_buf?)?;
624            Ok(_response.map(|x| x))
625        }
626        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AdminPoweroffResult>(
627            (),
628            0x24101c5d0b439748,
629            fidl::encoding::DynamicFlags::empty(),
630            _decode,
631        )
632    }
633
634    type MexecResponseFut = fidl::client::QueryResponseFut<
635        AdminMexecResult,
636        fidl::encoding::DefaultFuchsiaResourceDialect,
637    >;
638    fn r#mexec(
639        &self,
640        mut kernel_zbi: fidl::Vmo,
641        mut data_zbi: fidl::Vmo,
642    ) -> Self::MexecResponseFut {
643        fn _decode(
644            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
645        ) -> Result<AdminMexecResult, fidl::Error> {
646            let _response = fidl::client::decode_transaction_body::<
647                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
648                fidl::encoding::DefaultFuchsiaResourceDialect,
649                0x1f91e77ec781a4c6,
650            >(_buf?)?;
651            Ok(_response.map(|x| x))
652        }
653        self.client.send_query_and_decode::<AdminMexecRequest, AdminMexecResult>(
654            (kernel_zbi, data_zbi),
655            0x1f91e77ec781a4c6,
656            fidl::encoding::DynamicFlags::empty(),
657            _decode,
658        )
659    }
660
661    type SuspendToRamResponseFut = fidl::client::QueryResponseFut<
662        AdminSuspendToRamResult,
663        fidl::encoding::DefaultFuchsiaResourceDialect,
664    >;
665    fn r#suspend_to_ram(&self) -> Self::SuspendToRamResponseFut {
666        fn _decode(
667            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
668        ) -> Result<AdminSuspendToRamResult, fidl::Error> {
669            let _response = fidl::client::decode_transaction_body::<
670                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
671                fidl::encoding::DefaultFuchsiaResourceDialect,
672                0x3b0e356782e7620e,
673            >(_buf?)?;
674            Ok(_response.map(|x| x))
675        }
676        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AdminSuspendToRamResult>(
677            (),
678            0x3b0e356782e7620e,
679            fidl::encoding::DynamicFlags::empty(),
680            _decode,
681        )
682    }
683}
684
685pub struct AdminEventStream {
686    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
687}
688
689impl std::marker::Unpin for AdminEventStream {}
690
691impl futures::stream::FusedStream for AdminEventStream {
692    fn is_terminated(&self) -> bool {
693        self.event_receiver.is_terminated()
694    }
695}
696
697impl futures::Stream for AdminEventStream {
698    type Item = Result<AdminEvent, fidl::Error>;
699
700    fn poll_next(
701        mut self: std::pin::Pin<&mut Self>,
702        cx: &mut std::task::Context<'_>,
703    ) -> std::task::Poll<Option<Self::Item>> {
704        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
705            &mut self.event_receiver,
706            cx
707        )?) {
708            Some(buf) => std::task::Poll::Ready(Some(AdminEvent::decode(buf))),
709            None => std::task::Poll::Ready(None),
710        }
711    }
712}
713
714#[derive(Debug)]
715pub enum AdminEvent {}
716
717impl AdminEvent {
718    /// Decodes a message buffer as a [`AdminEvent`].
719    fn decode(
720        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
721    ) -> Result<AdminEvent, fidl::Error> {
722        let (bytes, _handles) = buf.split_mut();
723        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
724        debug_assert_eq!(tx_header.tx_id, 0);
725        match tx_header.ordinal {
726            _ => Err(fidl::Error::UnknownOrdinal {
727                ordinal: tx_header.ordinal,
728                protocol_name: <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
729            }),
730        }
731    }
732}
733
734/// A Stream of incoming requests for fuchsia.hardware.power.statecontrol/Admin.
735pub struct AdminRequestStream {
736    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
737    is_terminated: bool,
738}
739
740impl std::marker::Unpin for AdminRequestStream {}
741
742impl futures::stream::FusedStream for AdminRequestStream {
743    fn is_terminated(&self) -> bool {
744        self.is_terminated
745    }
746}
747
748impl fidl::endpoints::RequestStream for AdminRequestStream {
749    type Protocol = AdminMarker;
750    type ControlHandle = AdminControlHandle;
751
752    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
753        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
754    }
755
756    fn control_handle(&self) -> Self::ControlHandle {
757        AdminControlHandle { inner: self.inner.clone() }
758    }
759
760    fn into_inner(
761        self,
762    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
763    {
764        (self.inner, self.is_terminated)
765    }
766
767    fn from_inner(
768        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
769        is_terminated: bool,
770    ) -> Self {
771        Self { inner, is_terminated }
772    }
773}
774
775impl futures::Stream for AdminRequestStream {
776    type Item = Result<AdminRequest, fidl::Error>;
777
778    fn poll_next(
779        mut self: std::pin::Pin<&mut Self>,
780        cx: &mut std::task::Context<'_>,
781    ) -> std::task::Poll<Option<Self::Item>> {
782        let this = &mut *self;
783        if this.inner.check_shutdown(cx) {
784            this.is_terminated = true;
785            return std::task::Poll::Ready(None);
786        }
787        if this.is_terminated {
788            panic!("polled AdminRequestStream after completion");
789        }
790        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
791            |bytes, handles| {
792                match this.inner.channel().read_etc(cx, bytes, handles) {
793                    std::task::Poll::Ready(Ok(())) => {}
794                    std::task::Poll::Pending => return std::task::Poll::Pending,
795                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
796                        this.is_terminated = true;
797                        return std::task::Poll::Ready(None);
798                    }
799                    std::task::Poll::Ready(Err(e)) => {
800                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
801                            e.into(),
802                        ))));
803                    }
804                }
805
806                // A message has been received from the channel
807                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
808
809                std::task::Poll::Ready(Some(match header.ordinal {
810                    0xb3272d15e00712f => {
811                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
812                        let mut req = fidl::new_empty!(
813                            fidl::encoding::EmptyPayload,
814                            fidl::encoding::DefaultFuchsiaResourceDialect
815                        );
816                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
817                        let control_handle = AdminControlHandle { inner: this.inner.clone() };
818                        Ok(AdminRequest::PowerFullyOn {
819                            responder: AdminPowerFullyOnResponder {
820                                control_handle: std::mem::ManuallyDrop::new(control_handle),
821                                tx_id: header.tx_id,
822                            },
823                        })
824                    }
825                    0x3722c53e45dc022f => {
826                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
827                        let mut req = fidl::new_empty!(
828                            AdminShutdownRequest,
829                            fidl::encoding::DefaultFuchsiaResourceDialect
830                        );
831                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AdminShutdownRequest>(&header, _body_bytes, handles, &mut req)?;
832                        let control_handle = AdminControlHandle { inner: this.inner.clone() };
833                        Ok(AdminRequest::Shutdown {
834                            options: req.options,
835
836                            responder: AdminShutdownResponder {
837                                control_handle: std::mem::ManuallyDrop::new(control_handle),
838                                tx_id: header.tx_id,
839                            },
840                        })
841                    }
842                    0x9416b4d36a80b4 => {
843                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
844                        let mut req = fidl::new_empty!(
845                            AdminPerformRebootRequest,
846                            fidl::encoding::DefaultFuchsiaResourceDialect
847                        );
848                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AdminPerformRebootRequest>(&header, _body_bytes, handles, &mut req)?;
849                        let control_handle = AdminControlHandle { inner: this.inner.clone() };
850                        Ok(AdminRequest::PerformReboot {
851                            options: req.options,
852
853                            responder: AdminPerformRebootResponder {
854                                control_handle: std::mem::ManuallyDrop::new(control_handle),
855                                tx_id: header.tx_id,
856                            },
857                        })
858                    }
859                    0x6dce331b33786aa => {
860                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
861                        let mut req = fidl::new_empty!(
862                            fidl::encoding::EmptyPayload,
863                            fidl::encoding::DefaultFuchsiaResourceDialect
864                        );
865                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
866                        let control_handle = AdminControlHandle { inner: this.inner.clone() };
867                        Ok(AdminRequest::RebootToBootloader {
868                            responder: AdminRebootToBootloaderResponder {
869                                control_handle: std::mem::ManuallyDrop::new(control_handle),
870                                tx_id: header.tx_id,
871                            },
872                        })
873                    }
874                    0x1575c566be54f505 => {
875                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
876                        let mut req = fidl::new_empty!(
877                            fidl::encoding::EmptyPayload,
878                            fidl::encoding::DefaultFuchsiaResourceDialect
879                        );
880                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
881                        let control_handle = AdminControlHandle { inner: this.inner.clone() };
882                        Ok(AdminRequest::RebootToRecovery {
883                            responder: AdminRebootToRecoveryResponder {
884                                control_handle: std::mem::ManuallyDrop::new(control_handle),
885                                tx_id: header.tx_id,
886                            },
887                        })
888                    }
889                    0x24101c5d0b439748 => {
890                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
891                        let mut req = fidl::new_empty!(
892                            fidl::encoding::EmptyPayload,
893                            fidl::encoding::DefaultFuchsiaResourceDialect
894                        );
895                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
896                        let control_handle = AdminControlHandle { inner: this.inner.clone() };
897                        Ok(AdminRequest::Poweroff {
898                            responder: AdminPoweroffResponder {
899                                control_handle: std::mem::ManuallyDrop::new(control_handle),
900                                tx_id: header.tx_id,
901                            },
902                        })
903                    }
904                    0x1f91e77ec781a4c6 => {
905                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
906                        let mut req = fidl::new_empty!(
907                            AdminMexecRequest,
908                            fidl::encoding::DefaultFuchsiaResourceDialect
909                        );
910                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AdminMexecRequest>(&header, _body_bytes, handles, &mut req)?;
911                        let control_handle = AdminControlHandle { inner: this.inner.clone() };
912                        Ok(AdminRequest::Mexec {
913                            kernel_zbi: req.kernel_zbi,
914                            data_zbi: req.data_zbi,
915
916                            responder: AdminMexecResponder {
917                                control_handle: std::mem::ManuallyDrop::new(control_handle),
918                                tx_id: header.tx_id,
919                            },
920                        })
921                    }
922                    0x3b0e356782e7620e => {
923                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
924                        let mut req = fidl::new_empty!(
925                            fidl::encoding::EmptyPayload,
926                            fidl::encoding::DefaultFuchsiaResourceDialect
927                        );
928                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
929                        let control_handle = AdminControlHandle { inner: this.inner.clone() };
930                        Ok(AdminRequest::SuspendToRam {
931                            responder: AdminSuspendToRamResponder {
932                                control_handle: std::mem::ManuallyDrop::new(control_handle),
933                                tx_id: header.tx_id,
934                            },
935                        })
936                    }
937                    _ => Err(fidl::Error::UnknownOrdinal {
938                        ordinal: header.ordinal,
939                        protocol_name: <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
940                    }),
941                }))
942            },
943        )
944    }
945}
946
947/// Provides methods to request that the system be transitioned into a supported power state.
948///
949/// Note (see https://fxbug.dev/42136295):
950/// These methods do not return until after the state transition has been completed. In most cases
951/// (e.g. Reboot), a successful transition means that the caller does not actually observe the
952/// completion because the system will be rebooted before the call is completed. The implication is
953/// that using a synchronous FIDL client with these methods will result in a blocked thread for the
954/// duration of the call, or even for the remainder of the component's life (in the case of Reboot).
955/// Therefore, if a synchronous FIDL client is to be used with this protocol then care should be
956/// taken to avoid handling any shutdown-induced callbacks on the same thread that was used to
957/// initiate the transition. Example callbacks include [`fuchsia.process.lifecycle/Lifecycle.Stop`]
958/// and [`fuchsia.hardware.power.statecontrol/RebootMethodsWatcher.OnReboot`].
959/// Alternatively, the caller could choose to use an asynchronous FIDL client with this protocol to
960/// avoid blocking their calling thread.
961#[derive(Debug)]
962pub enum AdminRequest {
963    /// Asks the device to enter a fully on state.
964    PowerFullyOn { responder: AdminPowerFullyOnResponder },
965    /// Asks the device to enter the state specified by `options.action`.
966    ///
967    /// Arguments:
968    ///   - options: The options with which to perform this request.
969    ///              `ZX_ERR_INVALID_ARGS` is returned if `action` is absent.
970    ///              `reasons` may be omitted, but adding a new enum value
971    ///              instead is strongly encouraged.
972    Shutdown { options: ShutdownOptions, responder: AdminShutdownResponder },
973    /// Asks the device to reboot.
974    ///
975    /// Arguments:
976    ///   - options: The options with which to perform this requests.
977    ///              `ZX_ERR_INVALID_ARGS` is returned if the options are
978    ///              malformed (i.e. `reasons` is absent or empty).
979    ///
980    /// # Deprecation
981    ///
982    /// Use Shutdown, which allows callers to specify the intended action and reasons for the
983    /// action.
984    PerformReboot { options: RebootOptions, responder: AdminPerformRebootResponder },
985    /// Asks the device to reboot into the bootloader.
986    ///
987    /// # Deprecation
988    ///
989    /// Use Shutdown, which allows callers to specify reasons why they are requesting a reboot to
990    /// bootloader.
991    RebootToBootloader { responder: AdminRebootToBootloaderResponder },
992    /// Asks the device to reboot into the recovery partition.
993    ///
994    /// # Deprecation
995    ///
996    /// Use Shutdown, which allows callers to specify reasons why they are requesting a reboot to
997    /// recovery.
998    RebootToRecovery { responder: AdminRebootToRecoveryResponder },
999    /// Asks all devices to enter a powered off state.
1000    ///
1001    /// # Deprecation
1002    ///
1003    /// Use Shutdown, which allows callers to specify reasons why they are requesting a poweroff.
1004    Poweroff { responder: AdminPoweroffResponder },
1005    /// Performs a kernel mexec.
1006    ///
1007    /// It is expected that the ZBI items specified by
1008    /// `zx_system_mexec_payload_get()` have not yet been appended to the
1009    /// provided data ZBI.
1010    Mexec { kernel_zbi: fidl::Vmo, data_zbi: fidl::Vmo, responder: AdminMexecResponder },
1011    /// Asks the device to enter the suspend to RAM (S3) power state. Currently only supported on
1012    /// x64. If a system state transition is already in progress then ZX_ERR_ALREADY_EXISTS is
1013    /// returned. If the device fails to reach the suspend power state then ZX_ERR_INTERNAL is
1014    /// returned. If the device successfully suspends, ZX_OK is returned when the device resumes.
1015    SuspendToRam { responder: AdminSuspendToRamResponder },
1016}
1017
1018impl AdminRequest {
1019    #[allow(irrefutable_let_patterns)]
1020    pub fn into_power_fully_on(self) -> Option<(AdminPowerFullyOnResponder)> {
1021        if let AdminRequest::PowerFullyOn { responder } = self { Some((responder)) } else { None }
1022    }
1023
1024    #[allow(irrefutable_let_patterns)]
1025    pub fn into_shutdown(self) -> Option<(ShutdownOptions, AdminShutdownResponder)> {
1026        if let AdminRequest::Shutdown { options, responder } = self {
1027            Some((options, responder))
1028        } else {
1029            None
1030        }
1031    }
1032
1033    #[allow(irrefutable_let_patterns)]
1034    pub fn into_perform_reboot(self) -> Option<(RebootOptions, AdminPerformRebootResponder)> {
1035        if let AdminRequest::PerformReboot { options, responder } = self {
1036            Some((options, responder))
1037        } else {
1038            None
1039        }
1040    }
1041
1042    #[allow(irrefutable_let_patterns)]
1043    pub fn into_reboot_to_bootloader(self) -> Option<(AdminRebootToBootloaderResponder)> {
1044        if let AdminRequest::RebootToBootloader { responder } = self {
1045            Some((responder))
1046        } else {
1047            None
1048        }
1049    }
1050
1051    #[allow(irrefutable_let_patterns)]
1052    pub fn into_reboot_to_recovery(self) -> Option<(AdminRebootToRecoveryResponder)> {
1053        if let AdminRequest::RebootToRecovery { responder } = self {
1054            Some((responder))
1055        } else {
1056            None
1057        }
1058    }
1059
1060    #[allow(irrefutable_let_patterns)]
1061    pub fn into_poweroff(self) -> Option<(AdminPoweroffResponder)> {
1062        if let AdminRequest::Poweroff { responder } = self { Some((responder)) } else { None }
1063    }
1064
1065    #[allow(irrefutable_let_patterns)]
1066    pub fn into_mexec(self) -> Option<(fidl::Vmo, fidl::Vmo, AdminMexecResponder)> {
1067        if let AdminRequest::Mexec { kernel_zbi, data_zbi, responder } = self {
1068            Some((kernel_zbi, data_zbi, responder))
1069        } else {
1070            None
1071        }
1072    }
1073
1074    #[allow(irrefutable_let_patterns)]
1075    pub fn into_suspend_to_ram(self) -> Option<(AdminSuspendToRamResponder)> {
1076        if let AdminRequest::SuspendToRam { responder } = self { Some((responder)) } else { None }
1077    }
1078
1079    /// Name of the method defined in FIDL
1080    pub fn method_name(&self) -> &'static str {
1081        match *self {
1082            AdminRequest::PowerFullyOn { .. } => "power_fully_on",
1083            AdminRequest::Shutdown { .. } => "shutdown",
1084            AdminRequest::PerformReboot { .. } => "perform_reboot",
1085            AdminRequest::RebootToBootloader { .. } => "reboot_to_bootloader",
1086            AdminRequest::RebootToRecovery { .. } => "reboot_to_recovery",
1087            AdminRequest::Poweroff { .. } => "poweroff",
1088            AdminRequest::Mexec { .. } => "mexec",
1089            AdminRequest::SuspendToRam { .. } => "suspend_to_ram",
1090        }
1091    }
1092}
1093
1094#[derive(Debug, Clone)]
1095pub struct AdminControlHandle {
1096    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1097}
1098
1099impl fidl::endpoints::ControlHandle for AdminControlHandle {
1100    fn shutdown(&self) {
1101        self.inner.shutdown()
1102    }
1103
1104    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1105        self.inner.shutdown_with_epitaph(status)
1106    }
1107
1108    fn is_closed(&self) -> bool {
1109        self.inner.channel().is_closed()
1110    }
1111    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1112        self.inner.channel().on_closed()
1113    }
1114
1115    #[cfg(target_os = "fuchsia")]
1116    fn signal_peer(
1117        &self,
1118        clear_mask: zx::Signals,
1119        set_mask: zx::Signals,
1120    ) -> Result<(), zx_status::Status> {
1121        use fidl::Peered;
1122        self.inner.channel().signal_peer(clear_mask, set_mask)
1123    }
1124}
1125
1126impl AdminControlHandle {}
1127
1128#[must_use = "FIDL methods require a response to be sent"]
1129#[derive(Debug)]
1130pub struct AdminPowerFullyOnResponder {
1131    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1132    tx_id: u32,
1133}
1134
1135/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1136/// if the responder is dropped without sending a response, so that the client
1137/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1138impl std::ops::Drop for AdminPowerFullyOnResponder {
1139    fn drop(&mut self) {
1140        self.control_handle.shutdown();
1141        // Safety: drops once, never accessed again
1142        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1143    }
1144}
1145
1146impl fidl::endpoints::Responder for AdminPowerFullyOnResponder {
1147    type ControlHandle = AdminControlHandle;
1148
1149    fn control_handle(&self) -> &AdminControlHandle {
1150        &self.control_handle
1151    }
1152
1153    fn drop_without_shutdown(mut self) {
1154        // Safety: drops once, never accessed again due to mem::forget
1155        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1156        // Prevent Drop from running (which would shut down the channel)
1157        std::mem::forget(self);
1158    }
1159}
1160
1161impl AdminPowerFullyOnResponder {
1162    /// Sends a response to the FIDL transaction.
1163    ///
1164    /// Sets the channel to shutdown if an error occurs.
1165    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1166        let _result = self.send_raw(result);
1167        if _result.is_err() {
1168            self.control_handle.shutdown();
1169        }
1170        self.drop_without_shutdown();
1171        _result
1172    }
1173
1174    /// Similar to "send" but does not shutdown the channel if an error occurs.
1175    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1176        let _result = self.send_raw(result);
1177        self.drop_without_shutdown();
1178        _result
1179    }
1180
1181    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1182        self.control_handle
1183            .inner
1184            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1185                result,
1186                self.tx_id,
1187                0xb3272d15e00712f,
1188                fidl::encoding::DynamicFlags::empty(),
1189            )
1190    }
1191}
1192
1193#[must_use = "FIDL methods require a response to be sent"]
1194#[derive(Debug)]
1195pub struct AdminShutdownResponder {
1196    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1197    tx_id: u32,
1198}
1199
1200/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1201/// if the responder is dropped without sending a response, so that the client
1202/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1203impl std::ops::Drop for AdminShutdownResponder {
1204    fn drop(&mut self) {
1205        self.control_handle.shutdown();
1206        // Safety: drops once, never accessed again
1207        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1208    }
1209}
1210
1211impl fidl::endpoints::Responder for AdminShutdownResponder {
1212    type ControlHandle = AdminControlHandle;
1213
1214    fn control_handle(&self) -> &AdminControlHandle {
1215        &self.control_handle
1216    }
1217
1218    fn drop_without_shutdown(mut self) {
1219        // Safety: drops once, never accessed again due to mem::forget
1220        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1221        // Prevent Drop from running (which would shut down the channel)
1222        std::mem::forget(self);
1223    }
1224}
1225
1226impl AdminShutdownResponder {
1227    /// Sends a response to the FIDL transaction.
1228    ///
1229    /// Sets the channel to shutdown if an error occurs.
1230    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1231        let _result = self.send_raw(result);
1232        if _result.is_err() {
1233            self.control_handle.shutdown();
1234        }
1235        self.drop_without_shutdown();
1236        _result
1237    }
1238
1239    /// Similar to "send" but does not shutdown the channel if an error occurs.
1240    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1241        let _result = self.send_raw(result);
1242        self.drop_without_shutdown();
1243        _result
1244    }
1245
1246    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1247        self.control_handle
1248            .inner
1249            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1250                result,
1251                self.tx_id,
1252                0x3722c53e45dc022f,
1253                fidl::encoding::DynamicFlags::empty(),
1254            )
1255    }
1256}
1257
1258#[must_use = "FIDL methods require a response to be sent"]
1259#[derive(Debug)]
1260pub struct AdminPerformRebootResponder {
1261    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1262    tx_id: u32,
1263}
1264
1265/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1266/// if the responder is dropped without sending a response, so that the client
1267/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1268impl std::ops::Drop for AdminPerformRebootResponder {
1269    fn drop(&mut self) {
1270        self.control_handle.shutdown();
1271        // Safety: drops once, never accessed again
1272        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1273    }
1274}
1275
1276impl fidl::endpoints::Responder for AdminPerformRebootResponder {
1277    type ControlHandle = AdminControlHandle;
1278
1279    fn control_handle(&self) -> &AdminControlHandle {
1280        &self.control_handle
1281    }
1282
1283    fn drop_without_shutdown(mut self) {
1284        // Safety: drops once, never accessed again due to mem::forget
1285        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1286        // Prevent Drop from running (which would shut down the channel)
1287        std::mem::forget(self);
1288    }
1289}
1290
1291impl AdminPerformRebootResponder {
1292    /// Sends a response to the FIDL transaction.
1293    ///
1294    /// Sets the channel to shutdown if an error occurs.
1295    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1296        let _result = self.send_raw(result);
1297        if _result.is_err() {
1298            self.control_handle.shutdown();
1299        }
1300        self.drop_without_shutdown();
1301        _result
1302    }
1303
1304    /// Similar to "send" but does not shutdown the channel if an error occurs.
1305    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1306        let _result = self.send_raw(result);
1307        self.drop_without_shutdown();
1308        _result
1309    }
1310
1311    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1312        self.control_handle
1313            .inner
1314            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1315                result,
1316                self.tx_id,
1317                0x9416b4d36a80b4,
1318                fidl::encoding::DynamicFlags::empty(),
1319            )
1320    }
1321}
1322
1323#[must_use = "FIDL methods require a response to be sent"]
1324#[derive(Debug)]
1325pub struct AdminRebootToBootloaderResponder {
1326    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1327    tx_id: u32,
1328}
1329
1330/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1331/// if the responder is dropped without sending a response, so that the client
1332/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1333impl std::ops::Drop for AdminRebootToBootloaderResponder {
1334    fn drop(&mut self) {
1335        self.control_handle.shutdown();
1336        // Safety: drops once, never accessed again
1337        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1338    }
1339}
1340
1341impl fidl::endpoints::Responder for AdminRebootToBootloaderResponder {
1342    type ControlHandle = AdminControlHandle;
1343
1344    fn control_handle(&self) -> &AdminControlHandle {
1345        &self.control_handle
1346    }
1347
1348    fn drop_without_shutdown(mut self) {
1349        // Safety: drops once, never accessed again due to mem::forget
1350        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1351        // Prevent Drop from running (which would shut down the channel)
1352        std::mem::forget(self);
1353    }
1354}
1355
1356impl AdminRebootToBootloaderResponder {
1357    /// Sends a response to the FIDL transaction.
1358    ///
1359    /// Sets the channel to shutdown if an error occurs.
1360    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1361        let _result = self.send_raw(result);
1362        if _result.is_err() {
1363            self.control_handle.shutdown();
1364        }
1365        self.drop_without_shutdown();
1366        _result
1367    }
1368
1369    /// Similar to "send" but does not shutdown the channel if an error occurs.
1370    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1371        let _result = self.send_raw(result);
1372        self.drop_without_shutdown();
1373        _result
1374    }
1375
1376    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1377        self.control_handle
1378            .inner
1379            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1380                result,
1381                self.tx_id,
1382                0x6dce331b33786aa,
1383                fidl::encoding::DynamicFlags::empty(),
1384            )
1385    }
1386}
1387
1388#[must_use = "FIDL methods require a response to be sent"]
1389#[derive(Debug)]
1390pub struct AdminRebootToRecoveryResponder {
1391    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1392    tx_id: u32,
1393}
1394
1395/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1396/// if the responder is dropped without sending a response, so that the client
1397/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1398impl std::ops::Drop for AdminRebootToRecoveryResponder {
1399    fn drop(&mut self) {
1400        self.control_handle.shutdown();
1401        // Safety: drops once, never accessed again
1402        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1403    }
1404}
1405
1406impl fidl::endpoints::Responder for AdminRebootToRecoveryResponder {
1407    type ControlHandle = AdminControlHandle;
1408
1409    fn control_handle(&self) -> &AdminControlHandle {
1410        &self.control_handle
1411    }
1412
1413    fn drop_without_shutdown(mut self) {
1414        // Safety: drops once, never accessed again due to mem::forget
1415        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1416        // Prevent Drop from running (which would shut down the channel)
1417        std::mem::forget(self);
1418    }
1419}
1420
1421impl AdminRebootToRecoveryResponder {
1422    /// Sends a response to the FIDL transaction.
1423    ///
1424    /// Sets the channel to shutdown if an error occurs.
1425    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1426        let _result = self.send_raw(result);
1427        if _result.is_err() {
1428            self.control_handle.shutdown();
1429        }
1430        self.drop_without_shutdown();
1431        _result
1432    }
1433
1434    /// Similar to "send" but does not shutdown the channel if an error occurs.
1435    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1436        let _result = self.send_raw(result);
1437        self.drop_without_shutdown();
1438        _result
1439    }
1440
1441    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1442        self.control_handle
1443            .inner
1444            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1445                result,
1446                self.tx_id,
1447                0x1575c566be54f505,
1448                fidl::encoding::DynamicFlags::empty(),
1449            )
1450    }
1451}
1452
1453#[must_use = "FIDL methods require a response to be sent"]
1454#[derive(Debug)]
1455pub struct AdminPoweroffResponder {
1456    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1457    tx_id: u32,
1458}
1459
1460/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1461/// if the responder is dropped without sending a response, so that the client
1462/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1463impl std::ops::Drop for AdminPoweroffResponder {
1464    fn drop(&mut self) {
1465        self.control_handle.shutdown();
1466        // Safety: drops once, never accessed again
1467        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1468    }
1469}
1470
1471impl fidl::endpoints::Responder for AdminPoweroffResponder {
1472    type ControlHandle = AdminControlHandle;
1473
1474    fn control_handle(&self) -> &AdminControlHandle {
1475        &self.control_handle
1476    }
1477
1478    fn drop_without_shutdown(mut self) {
1479        // Safety: drops once, never accessed again due to mem::forget
1480        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1481        // Prevent Drop from running (which would shut down the channel)
1482        std::mem::forget(self);
1483    }
1484}
1485
1486impl AdminPoweroffResponder {
1487    /// Sends a response to the FIDL transaction.
1488    ///
1489    /// Sets the channel to shutdown if an error occurs.
1490    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1491        let _result = self.send_raw(result);
1492        if _result.is_err() {
1493            self.control_handle.shutdown();
1494        }
1495        self.drop_without_shutdown();
1496        _result
1497    }
1498
1499    /// Similar to "send" but does not shutdown the channel if an error occurs.
1500    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1501        let _result = self.send_raw(result);
1502        self.drop_without_shutdown();
1503        _result
1504    }
1505
1506    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1507        self.control_handle
1508            .inner
1509            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1510                result,
1511                self.tx_id,
1512                0x24101c5d0b439748,
1513                fidl::encoding::DynamicFlags::empty(),
1514            )
1515    }
1516}
1517
1518#[must_use = "FIDL methods require a response to be sent"]
1519#[derive(Debug)]
1520pub struct AdminMexecResponder {
1521    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1522    tx_id: u32,
1523}
1524
1525/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1526/// if the responder is dropped without sending a response, so that the client
1527/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1528impl std::ops::Drop for AdminMexecResponder {
1529    fn drop(&mut self) {
1530        self.control_handle.shutdown();
1531        // Safety: drops once, never accessed again
1532        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1533    }
1534}
1535
1536impl fidl::endpoints::Responder for AdminMexecResponder {
1537    type ControlHandle = AdminControlHandle;
1538
1539    fn control_handle(&self) -> &AdminControlHandle {
1540        &self.control_handle
1541    }
1542
1543    fn drop_without_shutdown(mut self) {
1544        // Safety: drops once, never accessed again due to mem::forget
1545        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1546        // Prevent Drop from running (which would shut down the channel)
1547        std::mem::forget(self);
1548    }
1549}
1550
1551impl AdminMexecResponder {
1552    /// Sends a response to the FIDL transaction.
1553    ///
1554    /// Sets the channel to shutdown if an error occurs.
1555    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1556        let _result = self.send_raw(result);
1557        if _result.is_err() {
1558            self.control_handle.shutdown();
1559        }
1560        self.drop_without_shutdown();
1561        _result
1562    }
1563
1564    /// Similar to "send" but does not shutdown the channel if an error occurs.
1565    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1566        let _result = self.send_raw(result);
1567        self.drop_without_shutdown();
1568        _result
1569    }
1570
1571    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1572        self.control_handle
1573            .inner
1574            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1575                result,
1576                self.tx_id,
1577                0x1f91e77ec781a4c6,
1578                fidl::encoding::DynamicFlags::empty(),
1579            )
1580    }
1581}
1582
1583#[must_use = "FIDL methods require a response to be sent"]
1584#[derive(Debug)]
1585pub struct AdminSuspendToRamResponder {
1586    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
1587    tx_id: u32,
1588}
1589
1590/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
1591/// if the responder is dropped without sending a response, so that the client
1592/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1593impl std::ops::Drop for AdminSuspendToRamResponder {
1594    fn drop(&mut self) {
1595        self.control_handle.shutdown();
1596        // Safety: drops once, never accessed again
1597        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1598    }
1599}
1600
1601impl fidl::endpoints::Responder for AdminSuspendToRamResponder {
1602    type ControlHandle = AdminControlHandle;
1603
1604    fn control_handle(&self) -> &AdminControlHandle {
1605        &self.control_handle
1606    }
1607
1608    fn drop_without_shutdown(mut self) {
1609        // Safety: drops once, never accessed again due to mem::forget
1610        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1611        // Prevent Drop from running (which would shut down the channel)
1612        std::mem::forget(self);
1613    }
1614}
1615
1616impl AdminSuspendToRamResponder {
1617    /// Sends a response to the FIDL transaction.
1618    ///
1619    /// Sets the channel to shutdown if an error occurs.
1620    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1621        let _result = self.send_raw(result);
1622        if _result.is_err() {
1623            self.control_handle.shutdown();
1624        }
1625        self.drop_without_shutdown();
1626        _result
1627    }
1628
1629    /// Similar to "send" but does not shutdown the channel if an error occurs.
1630    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1631        let _result = self.send_raw(result);
1632        self.drop_without_shutdown();
1633        _result
1634    }
1635
1636    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1637        self.control_handle
1638            .inner
1639            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1640                result,
1641                self.tx_id,
1642                0x3b0e356782e7620e,
1643                fidl::encoding::DynamicFlags::empty(),
1644            )
1645    }
1646}
1647
1648#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1649pub struct RebootMethodsWatcherRegisterMarker;
1650
1651impl fidl::endpoints::ProtocolMarker for RebootMethodsWatcherRegisterMarker {
1652    type Proxy = RebootMethodsWatcherRegisterProxy;
1653    type RequestStream = RebootMethodsWatcherRegisterRequestStream;
1654    #[cfg(target_os = "fuchsia")]
1655    type SynchronousProxy = RebootMethodsWatcherRegisterSynchronousProxy;
1656
1657    const DEBUG_NAME: &'static str =
1658        "fuchsia.hardware.power.statecontrol.RebootMethodsWatcherRegister";
1659}
1660impl fidl::endpoints::DiscoverableProtocolMarker for RebootMethodsWatcherRegisterMarker {}
1661
1662pub trait RebootMethodsWatcherRegisterProxyInterface: Send + Sync {
1663    type RegisterWatcherResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1664    fn r#register_watcher(
1665        &self,
1666        watcher: fidl::endpoints::ClientEnd<RebootWatcherMarker>,
1667    ) -> Self::RegisterWatcherResponseFut;
1668}
1669#[derive(Debug)]
1670#[cfg(target_os = "fuchsia")]
1671pub struct RebootMethodsWatcherRegisterSynchronousProxy {
1672    client: fidl::client::sync::Client,
1673}
1674
1675#[cfg(target_os = "fuchsia")]
1676impl fidl::endpoints::SynchronousProxy for RebootMethodsWatcherRegisterSynchronousProxy {
1677    type Proxy = RebootMethodsWatcherRegisterProxy;
1678    type Protocol = RebootMethodsWatcherRegisterMarker;
1679
1680    fn from_channel(inner: fidl::Channel) -> Self {
1681        Self::new(inner)
1682    }
1683
1684    fn into_channel(self) -> fidl::Channel {
1685        self.client.into_channel()
1686    }
1687
1688    fn as_channel(&self) -> &fidl::Channel {
1689        self.client.as_channel()
1690    }
1691}
1692
1693#[cfg(target_os = "fuchsia")]
1694impl RebootMethodsWatcherRegisterSynchronousProxy {
1695    pub fn new(channel: fidl::Channel) -> Self {
1696        let protocol_name =
1697            <RebootMethodsWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1698        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1699    }
1700
1701    pub fn into_channel(self) -> fidl::Channel {
1702        self.client.into_channel()
1703    }
1704
1705    /// Waits until an event arrives and returns it. It is safe for other
1706    /// threads to make concurrent requests while waiting for an event.
1707    pub fn wait_for_event(
1708        &self,
1709        deadline: zx::MonotonicInstant,
1710    ) -> Result<RebootMethodsWatcherRegisterEvent, fidl::Error> {
1711        RebootMethodsWatcherRegisterEvent::decode(self.client.wait_for_event(deadline)?)
1712    }
1713
1714    /// Registers a watcher to be notified when a Reboot method is called.
1715    ///
1716    /// Once the watcher has been successfully registered with the server, then
1717    /// the request will be completed and the RebootMethodsWatcherRegister
1718    /// channel will be left open (though a client is free to close it at this
1719    /// time).
1720    ///
1721    /// If there is an error in registering the watcher, then the
1722    /// RebootMethodsWatcherRegister channel will be closed without completing
1723    /// the request.
1724    ///
1725    /// The provided `watcher` channel will be used at most once to notify the
1726    /// watcher of an impending reboot and allow it the chance to respond.
1727    ///
1728    /// Watchers can unregister by closing their `RebootWatcher` channel.
1729    pub fn r#register_watcher(
1730        &self,
1731        mut watcher: fidl::endpoints::ClientEnd<RebootWatcherMarker>,
1732        ___deadline: zx::MonotonicInstant,
1733    ) -> Result<(), fidl::Error> {
1734        let _response = self.client.send_query::<
1735            RebootMethodsWatcherRegisterRegisterWatcherRequest,
1736            fidl::encoding::EmptyPayload,
1737        >(
1738            (watcher,),
1739            0x3e6610e78471238,
1740            fidl::encoding::DynamicFlags::empty(),
1741            ___deadline,
1742        )?;
1743        Ok(_response)
1744    }
1745}
1746
1747#[cfg(target_os = "fuchsia")]
1748impl From<RebootMethodsWatcherRegisterSynchronousProxy> for zx::NullableHandle {
1749    fn from(value: RebootMethodsWatcherRegisterSynchronousProxy) -> Self {
1750        value.into_channel().into()
1751    }
1752}
1753
1754#[cfg(target_os = "fuchsia")]
1755impl From<fidl::Channel> for RebootMethodsWatcherRegisterSynchronousProxy {
1756    fn from(value: fidl::Channel) -> Self {
1757        Self::new(value)
1758    }
1759}
1760
1761#[cfg(target_os = "fuchsia")]
1762impl fidl::endpoints::FromClient for RebootMethodsWatcherRegisterSynchronousProxy {
1763    type Protocol = RebootMethodsWatcherRegisterMarker;
1764
1765    fn from_client(value: fidl::endpoints::ClientEnd<RebootMethodsWatcherRegisterMarker>) -> Self {
1766        Self::new(value.into_channel())
1767    }
1768}
1769
1770#[derive(Debug, Clone)]
1771pub struct RebootMethodsWatcherRegisterProxy {
1772    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1773}
1774
1775impl fidl::endpoints::Proxy for RebootMethodsWatcherRegisterProxy {
1776    type Protocol = RebootMethodsWatcherRegisterMarker;
1777
1778    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1779        Self::new(inner)
1780    }
1781
1782    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1783        self.client.into_channel().map_err(|client| Self { client })
1784    }
1785
1786    fn as_channel(&self) -> &::fidl::AsyncChannel {
1787        self.client.as_channel()
1788    }
1789}
1790
1791impl RebootMethodsWatcherRegisterProxy {
1792    /// Create a new Proxy for fuchsia.hardware.power.statecontrol/RebootMethodsWatcherRegister.
1793    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1794        let protocol_name =
1795            <RebootMethodsWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1796        Self { client: fidl::client::Client::new(channel, protocol_name) }
1797    }
1798
1799    /// Get a Stream of events from the remote end of the protocol.
1800    ///
1801    /// # Panics
1802    ///
1803    /// Panics if the event stream was already taken.
1804    pub fn take_event_stream(&self) -> RebootMethodsWatcherRegisterEventStream {
1805        RebootMethodsWatcherRegisterEventStream {
1806            event_receiver: self.client.take_event_receiver(),
1807        }
1808    }
1809
1810    /// Registers a watcher to be notified when a Reboot method is called.
1811    ///
1812    /// Once the watcher has been successfully registered with the server, then
1813    /// the request will be completed and the RebootMethodsWatcherRegister
1814    /// channel will be left open (though a client is free to close it at this
1815    /// time).
1816    ///
1817    /// If there is an error in registering the watcher, then the
1818    /// RebootMethodsWatcherRegister channel will be closed without completing
1819    /// the request.
1820    ///
1821    /// The provided `watcher` channel will be used at most once to notify the
1822    /// watcher of an impending reboot and allow it the chance to respond.
1823    ///
1824    /// Watchers can unregister by closing their `RebootWatcher` channel.
1825    pub fn r#register_watcher(
1826        &self,
1827        mut watcher: fidl::endpoints::ClientEnd<RebootWatcherMarker>,
1828    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1829        RebootMethodsWatcherRegisterProxyInterface::r#register_watcher(self, watcher)
1830    }
1831}
1832
1833impl RebootMethodsWatcherRegisterProxyInterface for RebootMethodsWatcherRegisterProxy {
1834    type RegisterWatcherResponseFut =
1835        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1836    fn r#register_watcher(
1837        &self,
1838        mut watcher: fidl::endpoints::ClientEnd<RebootWatcherMarker>,
1839    ) -> Self::RegisterWatcherResponseFut {
1840        fn _decode(
1841            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1842        ) -> Result<(), fidl::Error> {
1843            let _response = fidl::client::decode_transaction_body::<
1844                fidl::encoding::EmptyPayload,
1845                fidl::encoding::DefaultFuchsiaResourceDialect,
1846                0x3e6610e78471238,
1847            >(_buf?)?;
1848            Ok(_response)
1849        }
1850        self.client.send_query_and_decode::<RebootMethodsWatcherRegisterRegisterWatcherRequest, ()>(
1851            (watcher,),
1852            0x3e6610e78471238,
1853            fidl::encoding::DynamicFlags::empty(),
1854            _decode,
1855        )
1856    }
1857}
1858
1859pub struct RebootMethodsWatcherRegisterEventStream {
1860    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1861}
1862
1863impl std::marker::Unpin for RebootMethodsWatcherRegisterEventStream {}
1864
1865impl futures::stream::FusedStream for RebootMethodsWatcherRegisterEventStream {
1866    fn is_terminated(&self) -> bool {
1867        self.event_receiver.is_terminated()
1868    }
1869}
1870
1871impl futures::Stream for RebootMethodsWatcherRegisterEventStream {
1872    type Item = Result<RebootMethodsWatcherRegisterEvent, fidl::Error>;
1873
1874    fn poll_next(
1875        mut self: std::pin::Pin<&mut Self>,
1876        cx: &mut std::task::Context<'_>,
1877    ) -> std::task::Poll<Option<Self::Item>> {
1878        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1879            &mut self.event_receiver,
1880            cx
1881        )?) {
1882            Some(buf) => {
1883                std::task::Poll::Ready(Some(RebootMethodsWatcherRegisterEvent::decode(buf)))
1884            }
1885            None => std::task::Poll::Ready(None),
1886        }
1887    }
1888}
1889
1890#[derive(Debug)]
1891pub enum RebootMethodsWatcherRegisterEvent {}
1892
1893impl RebootMethodsWatcherRegisterEvent {
1894    /// Decodes a message buffer as a [`RebootMethodsWatcherRegisterEvent`].
1895    fn decode(
1896        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1897    ) -> Result<RebootMethodsWatcherRegisterEvent, fidl::Error> {
1898        let (bytes, _handles) = buf.split_mut();
1899        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1900        debug_assert_eq!(tx_header.tx_id, 0);
1901        match tx_header.ordinal {
1902            _ => Err(fidl::Error::UnknownOrdinal {
1903                ordinal: tx_header.ordinal,
1904                protocol_name: <RebootMethodsWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1905            })
1906        }
1907    }
1908}
1909
1910/// A Stream of incoming requests for fuchsia.hardware.power.statecontrol/RebootMethodsWatcherRegister.
1911pub struct RebootMethodsWatcherRegisterRequestStream {
1912    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1913    is_terminated: bool,
1914}
1915
1916impl std::marker::Unpin for RebootMethodsWatcherRegisterRequestStream {}
1917
1918impl futures::stream::FusedStream for RebootMethodsWatcherRegisterRequestStream {
1919    fn is_terminated(&self) -> bool {
1920        self.is_terminated
1921    }
1922}
1923
1924impl fidl::endpoints::RequestStream for RebootMethodsWatcherRegisterRequestStream {
1925    type Protocol = RebootMethodsWatcherRegisterMarker;
1926    type ControlHandle = RebootMethodsWatcherRegisterControlHandle;
1927
1928    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1929        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1930    }
1931
1932    fn control_handle(&self) -> Self::ControlHandle {
1933        RebootMethodsWatcherRegisterControlHandle { inner: self.inner.clone() }
1934    }
1935
1936    fn into_inner(
1937        self,
1938    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1939    {
1940        (self.inner, self.is_terminated)
1941    }
1942
1943    fn from_inner(
1944        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1945        is_terminated: bool,
1946    ) -> Self {
1947        Self { inner, is_terminated }
1948    }
1949}
1950
1951impl futures::Stream for RebootMethodsWatcherRegisterRequestStream {
1952    type Item = Result<RebootMethodsWatcherRegisterRequest, fidl::Error>;
1953
1954    fn poll_next(
1955        mut self: std::pin::Pin<&mut Self>,
1956        cx: &mut std::task::Context<'_>,
1957    ) -> std::task::Poll<Option<Self::Item>> {
1958        let this = &mut *self;
1959        if this.inner.check_shutdown(cx) {
1960            this.is_terminated = true;
1961            return std::task::Poll::Ready(None);
1962        }
1963        if this.is_terminated {
1964            panic!("polled RebootMethodsWatcherRegisterRequestStream after completion");
1965        }
1966        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1967            |bytes, handles| {
1968                match this.inner.channel().read_etc(cx, bytes, handles) {
1969                    std::task::Poll::Ready(Ok(())) => {}
1970                    std::task::Poll::Pending => return std::task::Poll::Pending,
1971                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1972                        this.is_terminated = true;
1973                        return std::task::Poll::Ready(None);
1974                    }
1975                    std::task::Poll::Ready(Err(e)) => {
1976                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1977                            e.into(),
1978                        ))));
1979                    }
1980                }
1981
1982                // A message has been received from the channel
1983                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1984
1985                std::task::Poll::Ready(Some(match header.ordinal {
1986                0x3e6610e78471238 => {
1987                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1988                    let mut req = fidl::new_empty!(RebootMethodsWatcherRegisterRegisterWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1989                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RebootMethodsWatcherRegisterRegisterWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
1990                    let control_handle = RebootMethodsWatcherRegisterControlHandle {
1991                        inner: this.inner.clone(),
1992                    };
1993                    Ok(RebootMethodsWatcherRegisterRequest::RegisterWatcher {watcher: req.watcher,
1994
1995                        responder: RebootMethodsWatcherRegisterRegisterWatcherResponder {
1996                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1997                            tx_id: header.tx_id,
1998                        },
1999                    })
2000                }
2001                _ => Err(fidl::Error::UnknownOrdinal {
2002                    ordinal: header.ordinal,
2003                    protocol_name: <RebootMethodsWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2004                }),
2005            }))
2006            },
2007        )
2008    }
2009}
2010
2011/// Allows components to register a callback that will be executed when a Reboot
2012/// method is called. The main purpose of this protocol is to be able to track
2013/// reboot reasons. Consider relying on Component Framework's orderly shutdown
2014/// if you're looking at using this protocol.
2015#[derive(Debug)]
2016pub enum RebootMethodsWatcherRegisterRequest {
2017    /// Registers a watcher to be notified when a Reboot method is called.
2018    ///
2019    /// Once the watcher has been successfully registered with the server, then
2020    /// the request will be completed and the RebootMethodsWatcherRegister
2021    /// channel will be left open (though a client is free to close it at this
2022    /// time).
2023    ///
2024    /// If there is an error in registering the watcher, then the
2025    /// RebootMethodsWatcherRegister channel will be closed without completing
2026    /// the request.
2027    ///
2028    /// The provided `watcher` channel will be used at most once to notify the
2029    /// watcher of an impending reboot and allow it the chance to respond.
2030    ///
2031    /// Watchers can unregister by closing their `RebootWatcher` channel.
2032    RegisterWatcher {
2033        watcher: fidl::endpoints::ClientEnd<RebootWatcherMarker>,
2034        responder: RebootMethodsWatcherRegisterRegisterWatcherResponder,
2035    },
2036}
2037
2038impl RebootMethodsWatcherRegisterRequest {
2039    #[allow(irrefutable_let_patterns)]
2040    pub fn into_register_watcher(
2041        self,
2042    ) -> Option<(
2043        fidl::endpoints::ClientEnd<RebootWatcherMarker>,
2044        RebootMethodsWatcherRegisterRegisterWatcherResponder,
2045    )> {
2046        if let RebootMethodsWatcherRegisterRequest::RegisterWatcher { watcher, responder } = self {
2047            Some((watcher, responder))
2048        } else {
2049            None
2050        }
2051    }
2052
2053    /// Name of the method defined in FIDL
2054    pub fn method_name(&self) -> &'static str {
2055        match *self {
2056            RebootMethodsWatcherRegisterRequest::RegisterWatcher { .. } => "register_watcher",
2057        }
2058    }
2059}
2060
2061#[derive(Debug, Clone)]
2062pub struct RebootMethodsWatcherRegisterControlHandle {
2063    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2064}
2065
2066impl fidl::endpoints::ControlHandle for RebootMethodsWatcherRegisterControlHandle {
2067    fn shutdown(&self) {
2068        self.inner.shutdown()
2069    }
2070
2071    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2072        self.inner.shutdown_with_epitaph(status)
2073    }
2074
2075    fn is_closed(&self) -> bool {
2076        self.inner.channel().is_closed()
2077    }
2078    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2079        self.inner.channel().on_closed()
2080    }
2081
2082    #[cfg(target_os = "fuchsia")]
2083    fn signal_peer(
2084        &self,
2085        clear_mask: zx::Signals,
2086        set_mask: zx::Signals,
2087    ) -> Result<(), zx_status::Status> {
2088        use fidl::Peered;
2089        self.inner.channel().signal_peer(clear_mask, set_mask)
2090    }
2091}
2092
2093impl RebootMethodsWatcherRegisterControlHandle {}
2094
2095#[must_use = "FIDL methods require a response to be sent"]
2096#[derive(Debug)]
2097pub struct RebootMethodsWatcherRegisterRegisterWatcherResponder {
2098    control_handle: std::mem::ManuallyDrop<RebootMethodsWatcherRegisterControlHandle>,
2099    tx_id: u32,
2100}
2101
2102/// Set the the channel to be shutdown (see [`RebootMethodsWatcherRegisterControlHandle::shutdown`])
2103/// if the responder is dropped without sending a response, so that the client
2104/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2105impl std::ops::Drop for RebootMethodsWatcherRegisterRegisterWatcherResponder {
2106    fn drop(&mut self) {
2107        self.control_handle.shutdown();
2108        // Safety: drops once, never accessed again
2109        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2110    }
2111}
2112
2113impl fidl::endpoints::Responder for RebootMethodsWatcherRegisterRegisterWatcherResponder {
2114    type ControlHandle = RebootMethodsWatcherRegisterControlHandle;
2115
2116    fn control_handle(&self) -> &RebootMethodsWatcherRegisterControlHandle {
2117        &self.control_handle
2118    }
2119
2120    fn drop_without_shutdown(mut self) {
2121        // Safety: drops once, never accessed again due to mem::forget
2122        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2123        // Prevent Drop from running (which would shut down the channel)
2124        std::mem::forget(self);
2125    }
2126}
2127
2128impl RebootMethodsWatcherRegisterRegisterWatcherResponder {
2129    /// Sends a response to the FIDL transaction.
2130    ///
2131    /// Sets the channel to shutdown if an error occurs.
2132    pub fn send(self) -> Result<(), fidl::Error> {
2133        let _result = self.send_raw();
2134        if _result.is_err() {
2135            self.control_handle.shutdown();
2136        }
2137        self.drop_without_shutdown();
2138        _result
2139    }
2140
2141    /// Similar to "send" but does not shutdown the channel if an error occurs.
2142    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2143        let _result = self.send_raw();
2144        self.drop_without_shutdown();
2145        _result
2146    }
2147
2148    fn send_raw(&self) -> Result<(), fidl::Error> {
2149        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2150            (),
2151            self.tx_id,
2152            0x3e6610e78471238,
2153            fidl::encoding::DynamicFlags::empty(),
2154        )
2155    }
2156}
2157
2158#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2159pub struct RebootWatcherMarker;
2160
2161impl fidl::endpoints::ProtocolMarker for RebootWatcherMarker {
2162    type Proxy = RebootWatcherProxy;
2163    type RequestStream = RebootWatcherRequestStream;
2164    #[cfg(target_os = "fuchsia")]
2165    type SynchronousProxy = RebootWatcherSynchronousProxy;
2166
2167    const DEBUG_NAME: &'static str = "(anonymous) RebootWatcher";
2168}
2169
2170pub trait RebootWatcherProxyInterface: Send + Sync {
2171    type OnRebootResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2172    fn r#on_reboot(&self, options: &RebootOptions) -> Self::OnRebootResponseFut;
2173}
2174#[derive(Debug)]
2175#[cfg(target_os = "fuchsia")]
2176pub struct RebootWatcherSynchronousProxy {
2177    client: fidl::client::sync::Client,
2178}
2179
2180#[cfg(target_os = "fuchsia")]
2181impl fidl::endpoints::SynchronousProxy for RebootWatcherSynchronousProxy {
2182    type Proxy = RebootWatcherProxy;
2183    type Protocol = RebootWatcherMarker;
2184
2185    fn from_channel(inner: fidl::Channel) -> Self {
2186        Self::new(inner)
2187    }
2188
2189    fn into_channel(self) -> fidl::Channel {
2190        self.client.into_channel()
2191    }
2192
2193    fn as_channel(&self) -> &fidl::Channel {
2194        self.client.as_channel()
2195    }
2196}
2197
2198#[cfg(target_os = "fuchsia")]
2199impl RebootWatcherSynchronousProxy {
2200    pub fn new(channel: fidl::Channel) -> Self {
2201        let protocol_name = <RebootWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2202        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2203    }
2204
2205    pub fn into_channel(self) -> fidl::Channel {
2206        self.client.into_channel()
2207    }
2208
2209    /// Waits until an event arrives and returns it. It is safe for other
2210    /// threads to make concurrent requests while waiting for an event.
2211    pub fn wait_for_event(
2212        &self,
2213        deadline: zx::MonotonicInstant,
2214    ) -> Result<RebootWatcherEvent, fidl::Error> {
2215        RebootWatcherEvent::decode(self.client.wait_for_event(deadline)?)
2216    }
2217
2218    pub fn r#on_reboot(
2219        &self,
2220        mut options: &RebootOptions,
2221        ___deadline: zx::MonotonicInstant,
2222    ) -> Result<(), fidl::Error> {
2223        let _response =
2224            self.client.send_query::<RebootWatcherOnRebootRequest, fidl::encoding::EmptyPayload>(
2225                (options,),
2226                0x5334bbbe774f13c3,
2227                fidl::encoding::DynamicFlags::empty(),
2228                ___deadline,
2229            )?;
2230        Ok(_response)
2231    }
2232}
2233
2234#[cfg(target_os = "fuchsia")]
2235impl From<RebootWatcherSynchronousProxy> for zx::NullableHandle {
2236    fn from(value: RebootWatcherSynchronousProxy) -> Self {
2237        value.into_channel().into()
2238    }
2239}
2240
2241#[cfg(target_os = "fuchsia")]
2242impl From<fidl::Channel> for RebootWatcherSynchronousProxy {
2243    fn from(value: fidl::Channel) -> Self {
2244        Self::new(value)
2245    }
2246}
2247
2248#[cfg(target_os = "fuchsia")]
2249impl fidl::endpoints::FromClient for RebootWatcherSynchronousProxy {
2250    type Protocol = RebootWatcherMarker;
2251
2252    fn from_client(value: fidl::endpoints::ClientEnd<RebootWatcherMarker>) -> Self {
2253        Self::new(value.into_channel())
2254    }
2255}
2256
2257#[derive(Debug, Clone)]
2258pub struct RebootWatcherProxy {
2259    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2260}
2261
2262impl fidl::endpoints::Proxy for RebootWatcherProxy {
2263    type Protocol = RebootWatcherMarker;
2264
2265    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2266        Self::new(inner)
2267    }
2268
2269    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2270        self.client.into_channel().map_err(|client| Self { client })
2271    }
2272
2273    fn as_channel(&self) -> &::fidl::AsyncChannel {
2274        self.client.as_channel()
2275    }
2276}
2277
2278impl RebootWatcherProxy {
2279    /// Create a new Proxy for fuchsia.hardware.power.statecontrol/RebootWatcher.
2280    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2281        let protocol_name = <RebootWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2282        Self { client: fidl::client::Client::new(channel, protocol_name) }
2283    }
2284
2285    /// Get a Stream of events from the remote end of the protocol.
2286    ///
2287    /// # Panics
2288    ///
2289    /// Panics if the event stream was already taken.
2290    pub fn take_event_stream(&self) -> RebootWatcherEventStream {
2291        RebootWatcherEventStream { event_receiver: self.client.take_event_receiver() }
2292    }
2293
2294    pub fn r#on_reboot(
2295        &self,
2296        mut options: &RebootOptions,
2297    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2298        RebootWatcherProxyInterface::r#on_reboot(self, options)
2299    }
2300}
2301
2302impl RebootWatcherProxyInterface for RebootWatcherProxy {
2303    type OnRebootResponseFut =
2304        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2305    fn r#on_reboot(&self, mut options: &RebootOptions) -> Self::OnRebootResponseFut {
2306        fn _decode(
2307            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2308        ) -> Result<(), fidl::Error> {
2309            let _response = fidl::client::decode_transaction_body::<
2310                fidl::encoding::EmptyPayload,
2311                fidl::encoding::DefaultFuchsiaResourceDialect,
2312                0x5334bbbe774f13c3,
2313            >(_buf?)?;
2314            Ok(_response)
2315        }
2316        self.client.send_query_and_decode::<RebootWatcherOnRebootRequest, ()>(
2317            (options,),
2318            0x5334bbbe774f13c3,
2319            fidl::encoding::DynamicFlags::empty(),
2320            _decode,
2321        )
2322    }
2323}
2324
2325pub struct RebootWatcherEventStream {
2326    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2327}
2328
2329impl std::marker::Unpin for RebootWatcherEventStream {}
2330
2331impl futures::stream::FusedStream for RebootWatcherEventStream {
2332    fn is_terminated(&self) -> bool {
2333        self.event_receiver.is_terminated()
2334    }
2335}
2336
2337impl futures::Stream for RebootWatcherEventStream {
2338    type Item = Result<RebootWatcherEvent, fidl::Error>;
2339
2340    fn poll_next(
2341        mut self: std::pin::Pin<&mut Self>,
2342        cx: &mut std::task::Context<'_>,
2343    ) -> std::task::Poll<Option<Self::Item>> {
2344        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2345            &mut self.event_receiver,
2346            cx
2347        )?) {
2348            Some(buf) => std::task::Poll::Ready(Some(RebootWatcherEvent::decode(buf))),
2349            None => std::task::Poll::Ready(None),
2350        }
2351    }
2352}
2353
2354#[derive(Debug)]
2355pub enum RebootWatcherEvent {}
2356
2357impl RebootWatcherEvent {
2358    /// Decodes a message buffer as a [`RebootWatcherEvent`].
2359    fn decode(
2360        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2361    ) -> Result<RebootWatcherEvent, fidl::Error> {
2362        let (bytes, _handles) = buf.split_mut();
2363        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2364        debug_assert_eq!(tx_header.tx_id, 0);
2365        match tx_header.ordinal {
2366            _ => Err(fidl::Error::UnknownOrdinal {
2367                ordinal: tx_header.ordinal,
2368                protocol_name: <RebootWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2369            }),
2370        }
2371    }
2372}
2373
2374/// A Stream of incoming requests for fuchsia.hardware.power.statecontrol/RebootWatcher.
2375pub struct RebootWatcherRequestStream {
2376    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2377    is_terminated: bool,
2378}
2379
2380impl std::marker::Unpin for RebootWatcherRequestStream {}
2381
2382impl futures::stream::FusedStream for RebootWatcherRequestStream {
2383    fn is_terminated(&self) -> bool {
2384        self.is_terminated
2385    }
2386}
2387
2388impl fidl::endpoints::RequestStream for RebootWatcherRequestStream {
2389    type Protocol = RebootWatcherMarker;
2390    type ControlHandle = RebootWatcherControlHandle;
2391
2392    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2393        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2394    }
2395
2396    fn control_handle(&self) -> Self::ControlHandle {
2397        RebootWatcherControlHandle { inner: self.inner.clone() }
2398    }
2399
2400    fn into_inner(
2401        self,
2402    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2403    {
2404        (self.inner, self.is_terminated)
2405    }
2406
2407    fn from_inner(
2408        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2409        is_terminated: bool,
2410    ) -> Self {
2411        Self { inner, is_terminated }
2412    }
2413}
2414
2415impl futures::Stream for RebootWatcherRequestStream {
2416    type Item = Result<RebootWatcherRequest, fidl::Error>;
2417
2418    fn poll_next(
2419        mut self: std::pin::Pin<&mut Self>,
2420        cx: &mut std::task::Context<'_>,
2421    ) -> std::task::Poll<Option<Self::Item>> {
2422        let this = &mut *self;
2423        if this.inner.check_shutdown(cx) {
2424            this.is_terminated = true;
2425            return std::task::Poll::Ready(None);
2426        }
2427        if this.is_terminated {
2428            panic!("polled RebootWatcherRequestStream after completion");
2429        }
2430        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2431            |bytes, handles| {
2432                match this.inner.channel().read_etc(cx, bytes, handles) {
2433                    std::task::Poll::Ready(Ok(())) => {}
2434                    std::task::Poll::Pending => return std::task::Poll::Pending,
2435                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2436                        this.is_terminated = true;
2437                        return std::task::Poll::Ready(None);
2438                    }
2439                    std::task::Poll::Ready(Err(e)) => {
2440                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2441                            e.into(),
2442                        ))));
2443                    }
2444                }
2445
2446                // A message has been received from the channel
2447                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2448
2449                std::task::Poll::Ready(Some(match header.ordinal {
2450                    0x5334bbbe774f13c3 => {
2451                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2452                        let mut req = fidl::new_empty!(
2453                            RebootWatcherOnRebootRequest,
2454                            fidl::encoding::DefaultFuchsiaResourceDialect
2455                        );
2456                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RebootWatcherOnRebootRequest>(&header, _body_bytes, handles, &mut req)?;
2457                        let control_handle =
2458                            RebootWatcherControlHandle { inner: this.inner.clone() };
2459                        Ok(RebootWatcherRequest::OnReboot {
2460                            options: req.options,
2461
2462                            responder: RebootWatcherOnRebootResponder {
2463                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2464                                tx_id: header.tx_id,
2465                            },
2466                        })
2467                    }
2468                    _ => Err(fidl::Error::UnknownOrdinal {
2469                        ordinal: header.ordinal,
2470                        protocol_name:
2471                            <RebootWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2472                    }),
2473                }))
2474            },
2475        )
2476    }
2477}
2478
2479/// Allows components to be notified when Reboot related methods are called.
2480/// Watchers will be given 'MAX_REBOOT_WATCHER_RESPONSE_TIME_SECONDS' to return
2481/// before the system power state is changed. The channel will be used once to
2482/// send a notification to the watcher. Once the watcher responds or the timeout
2483/// expires, the channel will be closed by the client of RebootWatcher.
2484#[derive(Debug)]
2485pub enum RebootWatcherRequest {
2486    OnReboot { options: RebootOptions, responder: RebootWatcherOnRebootResponder },
2487}
2488
2489impl RebootWatcherRequest {
2490    #[allow(irrefutable_let_patterns)]
2491    pub fn into_on_reboot(self) -> Option<(RebootOptions, RebootWatcherOnRebootResponder)> {
2492        if let RebootWatcherRequest::OnReboot { options, responder } = self {
2493            Some((options, responder))
2494        } else {
2495            None
2496        }
2497    }
2498
2499    /// Name of the method defined in FIDL
2500    pub fn method_name(&self) -> &'static str {
2501        match *self {
2502            RebootWatcherRequest::OnReboot { .. } => "on_reboot",
2503        }
2504    }
2505}
2506
2507#[derive(Debug, Clone)]
2508pub struct RebootWatcherControlHandle {
2509    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2510}
2511
2512impl fidl::endpoints::ControlHandle for RebootWatcherControlHandle {
2513    fn shutdown(&self) {
2514        self.inner.shutdown()
2515    }
2516
2517    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2518        self.inner.shutdown_with_epitaph(status)
2519    }
2520
2521    fn is_closed(&self) -> bool {
2522        self.inner.channel().is_closed()
2523    }
2524    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2525        self.inner.channel().on_closed()
2526    }
2527
2528    #[cfg(target_os = "fuchsia")]
2529    fn signal_peer(
2530        &self,
2531        clear_mask: zx::Signals,
2532        set_mask: zx::Signals,
2533    ) -> Result<(), zx_status::Status> {
2534        use fidl::Peered;
2535        self.inner.channel().signal_peer(clear_mask, set_mask)
2536    }
2537}
2538
2539impl RebootWatcherControlHandle {}
2540
2541#[must_use = "FIDL methods require a response to be sent"]
2542#[derive(Debug)]
2543pub struct RebootWatcherOnRebootResponder {
2544    control_handle: std::mem::ManuallyDrop<RebootWatcherControlHandle>,
2545    tx_id: u32,
2546}
2547
2548/// Set the the channel to be shutdown (see [`RebootWatcherControlHandle::shutdown`])
2549/// if the responder is dropped without sending a response, so that the client
2550/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2551impl std::ops::Drop for RebootWatcherOnRebootResponder {
2552    fn drop(&mut self) {
2553        self.control_handle.shutdown();
2554        // Safety: drops once, never accessed again
2555        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2556    }
2557}
2558
2559impl fidl::endpoints::Responder for RebootWatcherOnRebootResponder {
2560    type ControlHandle = RebootWatcherControlHandle;
2561
2562    fn control_handle(&self) -> &RebootWatcherControlHandle {
2563        &self.control_handle
2564    }
2565
2566    fn drop_without_shutdown(mut self) {
2567        // Safety: drops once, never accessed again due to mem::forget
2568        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2569        // Prevent Drop from running (which would shut down the channel)
2570        std::mem::forget(self);
2571    }
2572}
2573
2574impl RebootWatcherOnRebootResponder {
2575    /// Sends a response to the FIDL transaction.
2576    ///
2577    /// Sets the channel to shutdown if an error occurs.
2578    pub fn send(self) -> Result<(), fidl::Error> {
2579        let _result = self.send_raw();
2580        if _result.is_err() {
2581            self.control_handle.shutdown();
2582        }
2583        self.drop_without_shutdown();
2584        _result
2585    }
2586
2587    /// Similar to "send" but does not shutdown the channel if an error occurs.
2588    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2589        let _result = self.send_raw();
2590        self.drop_without_shutdown();
2591        _result
2592    }
2593
2594    fn send_raw(&self) -> Result<(), fidl::Error> {
2595        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2596            (),
2597            self.tx_id,
2598            0x5334bbbe774f13c3,
2599            fidl::encoding::DynamicFlags::empty(),
2600        )
2601    }
2602}
2603
2604#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2605pub struct ShutdownWatcherMarker;
2606
2607impl fidl::endpoints::ProtocolMarker for ShutdownWatcherMarker {
2608    type Proxy = ShutdownWatcherProxy;
2609    type RequestStream = ShutdownWatcherRequestStream;
2610    #[cfg(target_os = "fuchsia")]
2611    type SynchronousProxy = ShutdownWatcherSynchronousProxy;
2612
2613    const DEBUG_NAME: &'static str = "(anonymous) ShutdownWatcher";
2614}
2615
2616pub trait ShutdownWatcherProxyInterface: Send + Sync {
2617    type OnShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2618    fn r#on_shutdown(&self, options: &ShutdownOptions) -> Self::OnShutdownResponseFut;
2619}
2620#[derive(Debug)]
2621#[cfg(target_os = "fuchsia")]
2622pub struct ShutdownWatcherSynchronousProxy {
2623    client: fidl::client::sync::Client,
2624}
2625
2626#[cfg(target_os = "fuchsia")]
2627impl fidl::endpoints::SynchronousProxy for ShutdownWatcherSynchronousProxy {
2628    type Proxy = ShutdownWatcherProxy;
2629    type Protocol = ShutdownWatcherMarker;
2630
2631    fn from_channel(inner: fidl::Channel) -> Self {
2632        Self::new(inner)
2633    }
2634
2635    fn into_channel(self) -> fidl::Channel {
2636        self.client.into_channel()
2637    }
2638
2639    fn as_channel(&self) -> &fidl::Channel {
2640        self.client.as_channel()
2641    }
2642}
2643
2644#[cfg(target_os = "fuchsia")]
2645impl ShutdownWatcherSynchronousProxy {
2646    pub fn new(channel: fidl::Channel) -> Self {
2647        let protocol_name = <ShutdownWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2648        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2649    }
2650
2651    pub fn into_channel(self) -> fidl::Channel {
2652        self.client.into_channel()
2653    }
2654
2655    /// Waits until an event arrives and returns it. It is safe for other
2656    /// threads to make concurrent requests while waiting for an event.
2657    pub fn wait_for_event(
2658        &self,
2659        deadline: zx::MonotonicInstant,
2660    ) -> Result<ShutdownWatcherEvent, fidl::Error> {
2661        ShutdownWatcherEvent::decode(self.client.wait_for_event(deadline)?)
2662    }
2663
2664    pub fn r#on_shutdown(
2665        &self,
2666        mut options: &ShutdownOptions,
2667        ___deadline: zx::MonotonicInstant,
2668    ) -> Result<(), fidl::Error> {
2669        let _response = self.client.send_query::<
2670            ShutdownWatcherOnShutdownRequest,
2671            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2672        >(
2673            (options,),
2674            0x1d9467990d7dc6db,
2675            fidl::encoding::DynamicFlags::FLEXIBLE,
2676            ___deadline,
2677        )?
2678        .into_result::<ShutdownWatcherMarker>("on_shutdown")?;
2679        Ok(_response)
2680    }
2681}
2682
2683#[cfg(target_os = "fuchsia")]
2684impl From<ShutdownWatcherSynchronousProxy> for zx::NullableHandle {
2685    fn from(value: ShutdownWatcherSynchronousProxy) -> Self {
2686        value.into_channel().into()
2687    }
2688}
2689
2690#[cfg(target_os = "fuchsia")]
2691impl From<fidl::Channel> for ShutdownWatcherSynchronousProxy {
2692    fn from(value: fidl::Channel) -> Self {
2693        Self::new(value)
2694    }
2695}
2696
2697#[cfg(target_os = "fuchsia")]
2698impl fidl::endpoints::FromClient for ShutdownWatcherSynchronousProxy {
2699    type Protocol = ShutdownWatcherMarker;
2700
2701    fn from_client(value: fidl::endpoints::ClientEnd<ShutdownWatcherMarker>) -> Self {
2702        Self::new(value.into_channel())
2703    }
2704}
2705
2706#[derive(Debug, Clone)]
2707pub struct ShutdownWatcherProxy {
2708    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2709}
2710
2711impl fidl::endpoints::Proxy for ShutdownWatcherProxy {
2712    type Protocol = ShutdownWatcherMarker;
2713
2714    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2715        Self::new(inner)
2716    }
2717
2718    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2719        self.client.into_channel().map_err(|client| Self { client })
2720    }
2721
2722    fn as_channel(&self) -> &::fidl::AsyncChannel {
2723        self.client.as_channel()
2724    }
2725}
2726
2727impl ShutdownWatcherProxy {
2728    /// Create a new Proxy for fuchsia.hardware.power.statecontrol/ShutdownWatcher.
2729    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2730        let protocol_name = <ShutdownWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2731        Self { client: fidl::client::Client::new(channel, protocol_name) }
2732    }
2733
2734    /// Get a Stream of events from the remote end of the protocol.
2735    ///
2736    /// # Panics
2737    ///
2738    /// Panics if the event stream was already taken.
2739    pub fn take_event_stream(&self) -> ShutdownWatcherEventStream {
2740        ShutdownWatcherEventStream { event_receiver: self.client.take_event_receiver() }
2741    }
2742
2743    pub fn r#on_shutdown(
2744        &self,
2745        mut options: &ShutdownOptions,
2746    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2747        ShutdownWatcherProxyInterface::r#on_shutdown(self, options)
2748    }
2749}
2750
2751impl ShutdownWatcherProxyInterface for ShutdownWatcherProxy {
2752    type OnShutdownResponseFut =
2753        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2754    fn r#on_shutdown(&self, mut options: &ShutdownOptions) -> Self::OnShutdownResponseFut {
2755        fn _decode(
2756            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2757        ) -> Result<(), fidl::Error> {
2758            let _response = fidl::client::decode_transaction_body::<
2759                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2760                fidl::encoding::DefaultFuchsiaResourceDialect,
2761                0x1d9467990d7dc6db,
2762            >(_buf?)?
2763            .into_result::<ShutdownWatcherMarker>("on_shutdown")?;
2764            Ok(_response)
2765        }
2766        self.client.send_query_and_decode::<ShutdownWatcherOnShutdownRequest, ()>(
2767            (options,),
2768            0x1d9467990d7dc6db,
2769            fidl::encoding::DynamicFlags::FLEXIBLE,
2770            _decode,
2771        )
2772    }
2773}
2774
2775pub struct ShutdownWatcherEventStream {
2776    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2777}
2778
2779impl std::marker::Unpin for ShutdownWatcherEventStream {}
2780
2781impl futures::stream::FusedStream for ShutdownWatcherEventStream {
2782    fn is_terminated(&self) -> bool {
2783        self.event_receiver.is_terminated()
2784    }
2785}
2786
2787impl futures::Stream for ShutdownWatcherEventStream {
2788    type Item = Result<ShutdownWatcherEvent, fidl::Error>;
2789
2790    fn poll_next(
2791        mut self: std::pin::Pin<&mut Self>,
2792        cx: &mut std::task::Context<'_>,
2793    ) -> std::task::Poll<Option<Self::Item>> {
2794        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2795            &mut self.event_receiver,
2796            cx
2797        )?) {
2798            Some(buf) => std::task::Poll::Ready(Some(ShutdownWatcherEvent::decode(buf))),
2799            None => std::task::Poll::Ready(None),
2800        }
2801    }
2802}
2803
2804#[derive(Debug)]
2805pub enum ShutdownWatcherEvent {
2806    #[non_exhaustive]
2807    _UnknownEvent {
2808        /// Ordinal of the event that was sent.
2809        ordinal: u64,
2810    },
2811}
2812
2813impl ShutdownWatcherEvent {
2814    /// Decodes a message buffer as a [`ShutdownWatcherEvent`].
2815    fn decode(
2816        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2817    ) -> Result<ShutdownWatcherEvent, fidl::Error> {
2818        let (bytes, _handles) = buf.split_mut();
2819        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2820        debug_assert_eq!(tx_header.tx_id, 0);
2821        match tx_header.ordinal {
2822            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2823                Ok(ShutdownWatcherEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2824            }
2825            _ => Err(fidl::Error::UnknownOrdinal {
2826                ordinal: tx_header.ordinal,
2827                protocol_name:
2828                    <ShutdownWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2829            }),
2830        }
2831    }
2832}
2833
2834/// A Stream of incoming requests for fuchsia.hardware.power.statecontrol/ShutdownWatcher.
2835pub struct ShutdownWatcherRequestStream {
2836    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2837    is_terminated: bool,
2838}
2839
2840impl std::marker::Unpin for ShutdownWatcherRequestStream {}
2841
2842impl futures::stream::FusedStream for ShutdownWatcherRequestStream {
2843    fn is_terminated(&self) -> bool {
2844        self.is_terminated
2845    }
2846}
2847
2848impl fidl::endpoints::RequestStream for ShutdownWatcherRequestStream {
2849    type Protocol = ShutdownWatcherMarker;
2850    type ControlHandle = ShutdownWatcherControlHandle;
2851
2852    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2853        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2854    }
2855
2856    fn control_handle(&self) -> Self::ControlHandle {
2857        ShutdownWatcherControlHandle { inner: self.inner.clone() }
2858    }
2859
2860    fn into_inner(
2861        self,
2862    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2863    {
2864        (self.inner, self.is_terminated)
2865    }
2866
2867    fn from_inner(
2868        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2869        is_terminated: bool,
2870    ) -> Self {
2871        Self { inner, is_terminated }
2872    }
2873}
2874
2875impl futures::Stream for ShutdownWatcherRequestStream {
2876    type Item = Result<ShutdownWatcherRequest, fidl::Error>;
2877
2878    fn poll_next(
2879        mut self: std::pin::Pin<&mut Self>,
2880        cx: &mut std::task::Context<'_>,
2881    ) -> std::task::Poll<Option<Self::Item>> {
2882        let this = &mut *self;
2883        if this.inner.check_shutdown(cx) {
2884            this.is_terminated = true;
2885            return std::task::Poll::Ready(None);
2886        }
2887        if this.is_terminated {
2888            panic!("polled ShutdownWatcherRequestStream after completion");
2889        }
2890        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2891            |bytes, handles| {
2892                match this.inner.channel().read_etc(cx, bytes, handles) {
2893                    std::task::Poll::Ready(Ok(())) => {}
2894                    std::task::Poll::Pending => return std::task::Poll::Pending,
2895                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2896                        this.is_terminated = true;
2897                        return std::task::Poll::Ready(None);
2898                    }
2899                    std::task::Poll::Ready(Err(e)) => {
2900                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2901                            e.into(),
2902                        ))));
2903                    }
2904                }
2905
2906                // A message has been received from the channel
2907                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2908
2909                std::task::Poll::Ready(Some(match header.ordinal {
2910                    0x1d9467990d7dc6db => {
2911                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2912                        let mut req = fidl::new_empty!(
2913                            ShutdownWatcherOnShutdownRequest,
2914                            fidl::encoding::DefaultFuchsiaResourceDialect
2915                        );
2916                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ShutdownWatcherOnShutdownRequest>(&header, _body_bytes, handles, &mut req)?;
2917                        let control_handle =
2918                            ShutdownWatcherControlHandle { inner: this.inner.clone() };
2919                        Ok(ShutdownWatcherRequest::OnShutdown {
2920                            options: req.options,
2921
2922                            responder: ShutdownWatcherOnShutdownResponder {
2923                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2924                                tx_id: header.tx_id,
2925                            },
2926                        })
2927                    }
2928                    _ if header.tx_id == 0
2929                        && header
2930                            .dynamic_flags()
2931                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2932                    {
2933                        Ok(ShutdownWatcherRequest::_UnknownMethod {
2934                            ordinal: header.ordinal,
2935                            control_handle: ShutdownWatcherControlHandle {
2936                                inner: this.inner.clone(),
2937                            },
2938                            method_type: fidl::MethodType::OneWay,
2939                        })
2940                    }
2941                    _ if header
2942                        .dynamic_flags()
2943                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2944                    {
2945                        this.inner.send_framework_err(
2946                            fidl::encoding::FrameworkErr::UnknownMethod,
2947                            header.tx_id,
2948                            header.ordinal,
2949                            header.dynamic_flags(),
2950                            (bytes, handles),
2951                        )?;
2952                        Ok(ShutdownWatcherRequest::_UnknownMethod {
2953                            ordinal: header.ordinal,
2954                            control_handle: ShutdownWatcherControlHandle {
2955                                inner: this.inner.clone(),
2956                            },
2957                            method_type: fidl::MethodType::TwoWay,
2958                        })
2959                    }
2960                    _ => Err(fidl::Error::UnknownOrdinal {
2961                        ordinal: header.ordinal,
2962                        protocol_name:
2963                            <ShutdownWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2964                    }),
2965                }))
2966            },
2967        )
2968    }
2969}
2970
2971/// Allows components to be notified when the Shutdown method is called.
2972/// Watchers will be given 'MAX_SHUTDOWN_WATCHER_RESPONSE_TIME_SECONDS' to return
2973/// before the system power state is changed. The channel will be used once to
2974/// send a notification to the watcher. Once the watcher responds or the timeout
2975/// expires, the channel will be closed by the client of ShutdownWatcher.
2976#[derive(Debug)]
2977pub enum ShutdownWatcherRequest {
2978    OnShutdown {
2979        options: ShutdownOptions,
2980        responder: ShutdownWatcherOnShutdownResponder,
2981    },
2982    /// An interaction was received which does not match any known method.
2983    #[non_exhaustive]
2984    _UnknownMethod {
2985        /// Ordinal of the method that was called.
2986        ordinal: u64,
2987        control_handle: ShutdownWatcherControlHandle,
2988        method_type: fidl::MethodType,
2989    },
2990}
2991
2992impl ShutdownWatcherRequest {
2993    #[allow(irrefutable_let_patterns)]
2994    pub fn into_on_shutdown(self) -> Option<(ShutdownOptions, ShutdownWatcherOnShutdownResponder)> {
2995        if let ShutdownWatcherRequest::OnShutdown { options, responder } = self {
2996            Some((options, responder))
2997        } else {
2998            None
2999        }
3000    }
3001
3002    /// Name of the method defined in FIDL
3003    pub fn method_name(&self) -> &'static str {
3004        match *self {
3005            ShutdownWatcherRequest::OnShutdown { .. } => "on_shutdown",
3006            ShutdownWatcherRequest::_UnknownMethod {
3007                method_type: fidl::MethodType::OneWay,
3008                ..
3009            } => "unknown one-way method",
3010            ShutdownWatcherRequest::_UnknownMethod {
3011                method_type: fidl::MethodType::TwoWay,
3012                ..
3013            } => "unknown two-way method",
3014        }
3015    }
3016}
3017
3018#[derive(Debug, Clone)]
3019pub struct ShutdownWatcherControlHandle {
3020    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3021}
3022
3023impl fidl::endpoints::ControlHandle for ShutdownWatcherControlHandle {
3024    fn shutdown(&self) {
3025        self.inner.shutdown()
3026    }
3027
3028    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3029        self.inner.shutdown_with_epitaph(status)
3030    }
3031
3032    fn is_closed(&self) -> bool {
3033        self.inner.channel().is_closed()
3034    }
3035    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3036        self.inner.channel().on_closed()
3037    }
3038
3039    #[cfg(target_os = "fuchsia")]
3040    fn signal_peer(
3041        &self,
3042        clear_mask: zx::Signals,
3043        set_mask: zx::Signals,
3044    ) -> Result<(), zx_status::Status> {
3045        use fidl::Peered;
3046        self.inner.channel().signal_peer(clear_mask, set_mask)
3047    }
3048}
3049
3050impl ShutdownWatcherControlHandle {}
3051
3052#[must_use = "FIDL methods require a response to be sent"]
3053#[derive(Debug)]
3054pub struct ShutdownWatcherOnShutdownResponder {
3055    control_handle: std::mem::ManuallyDrop<ShutdownWatcherControlHandle>,
3056    tx_id: u32,
3057}
3058
3059/// Set the the channel to be shutdown (see [`ShutdownWatcherControlHandle::shutdown`])
3060/// if the responder is dropped without sending a response, so that the client
3061/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3062impl std::ops::Drop for ShutdownWatcherOnShutdownResponder {
3063    fn drop(&mut self) {
3064        self.control_handle.shutdown();
3065        // Safety: drops once, never accessed again
3066        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3067    }
3068}
3069
3070impl fidl::endpoints::Responder for ShutdownWatcherOnShutdownResponder {
3071    type ControlHandle = ShutdownWatcherControlHandle;
3072
3073    fn control_handle(&self) -> &ShutdownWatcherControlHandle {
3074        &self.control_handle
3075    }
3076
3077    fn drop_without_shutdown(mut self) {
3078        // Safety: drops once, never accessed again due to mem::forget
3079        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3080        // Prevent Drop from running (which would shut down the channel)
3081        std::mem::forget(self);
3082    }
3083}
3084
3085impl ShutdownWatcherOnShutdownResponder {
3086    /// Sends a response to the FIDL transaction.
3087    ///
3088    /// Sets the channel to shutdown if an error occurs.
3089    pub fn send(self) -> Result<(), fidl::Error> {
3090        let _result = self.send_raw();
3091        if _result.is_err() {
3092            self.control_handle.shutdown();
3093        }
3094        self.drop_without_shutdown();
3095        _result
3096    }
3097
3098    /// Similar to "send" but does not shutdown the channel if an error occurs.
3099    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3100        let _result = self.send_raw();
3101        self.drop_without_shutdown();
3102        _result
3103    }
3104
3105    fn send_raw(&self) -> Result<(), fidl::Error> {
3106        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3107            fidl::encoding::Flexible::new(()),
3108            self.tx_id,
3109            0x1d9467990d7dc6db,
3110            fidl::encoding::DynamicFlags::FLEXIBLE,
3111        )
3112    }
3113}
3114
3115#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3116pub struct ShutdownWatcherRegisterMarker;
3117
3118impl fidl::endpoints::ProtocolMarker for ShutdownWatcherRegisterMarker {
3119    type Proxy = ShutdownWatcherRegisterProxy;
3120    type RequestStream = ShutdownWatcherRegisterRequestStream;
3121    #[cfg(target_os = "fuchsia")]
3122    type SynchronousProxy = ShutdownWatcherRegisterSynchronousProxy;
3123
3124    const DEBUG_NAME: &'static str = "fuchsia.hardware.power.statecontrol.ShutdownWatcherRegister";
3125}
3126impl fidl::endpoints::DiscoverableProtocolMarker for ShutdownWatcherRegisterMarker {}
3127
3128pub trait ShutdownWatcherRegisterProxyInterface: Send + Sync {
3129    type RegisterWatcherResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3130    fn r#register_watcher(
3131        &self,
3132        watcher: fidl::endpoints::ClientEnd<ShutdownWatcherMarker>,
3133    ) -> Self::RegisterWatcherResponseFut;
3134}
3135#[derive(Debug)]
3136#[cfg(target_os = "fuchsia")]
3137pub struct ShutdownWatcherRegisterSynchronousProxy {
3138    client: fidl::client::sync::Client,
3139}
3140
3141#[cfg(target_os = "fuchsia")]
3142impl fidl::endpoints::SynchronousProxy for ShutdownWatcherRegisterSynchronousProxy {
3143    type Proxy = ShutdownWatcherRegisterProxy;
3144    type Protocol = ShutdownWatcherRegisterMarker;
3145
3146    fn from_channel(inner: fidl::Channel) -> Self {
3147        Self::new(inner)
3148    }
3149
3150    fn into_channel(self) -> fidl::Channel {
3151        self.client.into_channel()
3152    }
3153
3154    fn as_channel(&self) -> &fidl::Channel {
3155        self.client.as_channel()
3156    }
3157}
3158
3159#[cfg(target_os = "fuchsia")]
3160impl ShutdownWatcherRegisterSynchronousProxy {
3161    pub fn new(channel: fidl::Channel) -> Self {
3162        let protocol_name =
3163            <ShutdownWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3164        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3165    }
3166
3167    pub fn into_channel(self) -> fidl::Channel {
3168        self.client.into_channel()
3169    }
3170
3171    /// Waits until an event arrives and returns it. It is safe for other
3172    /// threads to make concurrent requests while waiting for an event.
3173    pub fn wait_for_event(
3174        &self,
3175        deadline: zx::MonotonicInstant,
3176    ) -> Result<ShutdownWatcherRegisterEvent, fidl::Error> {
3177        ShutdownWatcherRegisterEvent::decode(self.client.wait_for_event(deadline)?)
3178    }
3179
3180    /// Registers a watcher to be notified when the Shutdown method is called.
3181    ///
3182    /// Once the watcher has been successfully registered with the server, then
3183    /// the request will be completed and the ShutdownWatcherRegister
3184    /// channel will be left open (though a client is free to close it at this
3185    /// time).
3186    ///
3187    /// If there is an error in registering the watcher, then the
3188    /// ShutdownWatcherRegister channel will be closed without completing
3189    /// the request.
3190    ///
3191    /// The provided `watcher` channel will be used at most once to notify the
3192    /// watcher of an impending shutdown and allow it the chance to respond.
3193    ///
3194    /// Watchers can unregister by closing their `ShutdownWatcher` channel.
3195    pub fn r#register_watcher(
3196        &self,
3197        mut watcher: fidl::endpoints::ClientEnd<ShutdownWatcherMarker>,
3198        ___deadline: zx::MonotonicInstant,
3199    ) -> Result<(), fidl::Error> {
3200        let _response = self.client.send_query::<
3201            ShutdownWatcherRegisterRegisterWatcherRequest,
3202            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3203        >(
3204            (watcher,),
3205            0x3db6ce5d34810aff,
3206            fidl::encoding::DynamicFlags::FLEXIBLE,
3207            ___deadline,
3208        )?
3209        .into_result::<ShutdownWatcherRegisterMarker>("register_watcher")?;
3210        Ok(_response)
3211    }
3212}
3213
3214#[cfg(target_os = "fuchsia")]
3215impl From<ShutdownWatcherRegisterSynchronousProxy> for zx::NullableHandle {
3216    fn from(value: ShutdownWatcherRegisterSynchronousProxy) -> Self {
3217        value.into_channel().into()
3218    }
3219}
3220
3221#[cfg(target_os = "fuchsia")]
3222impl From<fidl::Channel> for ShutdownWatcherRegisterSynchronousProxy {
3223    fn from(value: fidl::Channel) -> Self {
3224        Self::new(value)
3225    }
3226}
3227
3228#[cfg(target_os = "fuchsia")]
3229impl fidl::endpoints::FromClient for ShutdownWatcherRegisterSynchronousProxy {
3230    type Protocol = ShutdownWatcherRegisterMarker;
3231
3232    fn from_client(value: fidl::endpoints::ClientEnd<ShutdownWatcherRegisterMarker>) -> Self {
3233        Self::new(value.into_channel())
3234    }
3235}
3236
3237#[derive(Debug, Clone)]
3238pub struct ShutdownWatcherRegisterProxy {
3239    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3240}
3241
3242impl fidl::endpoints::Proxy for ShutdownWatcherRegisterProxy {
3243    type Protocol = ShutdownWatcherRegisterMarker;
3244
3245    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3246        Self::new(inner)
3247    }
3248
3249    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3250        self.client.into_channel().map_err(|client| Self { client })
3251    }
3252
3253    fn as_channel(&self) -> &::fidl::AsyncChannel {
3254        self.client.as_channel()
3255    }
3256}
3257
3258impl ShutdownWatcherRegisterProxy {
3259    /// Create a new Proxy for fuchsia.hardware.power.statecontrol/ShutdownWatcherRegister.
3260    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3261        let protocol_name =
3262            <ShutdownWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3263        Self { client: fidl::client::Client::new(channel, protocol_name) }
3264    }
3265
3266    /// Get a Stream of events from the remote end of the protocol.
3267    ///
3268    /// # Panics
3269    ///
3270    /// Panics if the event stream was already taken.
3271    pub fn take_event_stream(&self) -> ShutdownWatcherRegisterEventStream {
3272        ShutdownWatcherRegisterEventStream { event_receiver: self.client.take_event_receiver() }
3273    }
3274
3275    /// Registers a watcher to be notified when the Shutdown method is called.
3276    ///
3277    /// Once the watcher has been successfully registered with the server, then
3278    /// the request will be completed and the ShutdownWatcherRegister
3279    /// channel will be left open (though a client is free to close it at this
3280    /// time).
3281    ///
3282    /// If there is an error in registering the watcher, then the
3283    /// ShutdownWatcherRegister channel will be closed without completing
3284    /// the request.
3285    ///
3286    /// The provided `watcher` channel will be used at most once to notify the
3287    /// watcher of an impending shutdown and allow it the chance to respond.
3288    ///
3289    /// Watchers can unregister by closing their `ShutdownWatcher` channel.
3290    pub fn r#register_watcher(
3291        &self,
3292        mut watcher: fidl::endpoints::ClientEnd<ShutdownWatcherMarker>,
3293    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3294        ShutdownWatcherRegisterProxyInterface::r#register_watcher(self, watcher)
3295    }
3296}
3297
3298impl ShutdownWatcherRegisterProxyInterface for ShutdownWatcherRegisterProxy {
3299    type RegisterWatcherResponseFut =
3300        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3301    fn r#register_watcher(
3302        &self,
3303        mut watcher: fidl::endpoints::ClientEnd<ShutdownWatcherMarker>,
3304    ) -> Self::RegisterWatcherResponseFut {
3305        fn _decode(
3306            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3307        ) -> Result<(), fidl::Error> {
3308            let _response = fidl::client::decode_transaction_body::<
3309                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3310                fidl::encoding::DefaultFuchsiaResourceDialect,
3311                0x3db6ce5d34810aff,
3312            >(_buf?)?
3313            .into_result::<ShutdownWatcherRegisterMarker>("register_watcher")?;
3314            Ok(_response)
3315        }
3316        self.client.send_query_and_decode::<ShutdownWatcherRegisterRegisterWatcherRequest, ()>(
3317            (watcher,),
3318            0x3db6ce5d34810aff,
3319            fidl::encoding::DynamicFlags::FLEXIBLE,
3320            _decode,
3321        )
3322    }
3323}
3324
3325pub struct ShutdownWatcherRegisterEventStream {
3326    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3327}
3328
3329impl std::marker::Unpin for ShutdownWatcherRegisterEventStream {}
3330
3331impl futures::stream::FusedStream for ShutdownWatcherRegisterEventStream {
3332    fn is_terminated(&self) -> bool {
3333        self.event_receiver.is_terminated()
3334    }
3335}
3336
3337impl futures::Stream for ShutdownWatcherRegisterEventStream {
3338    type Item = Result<ShutdownWatcherRegisterEvent, fidl::Error>;
3339
3340    fn poll_next(
3341        mut self: std::pin::Pin<&mut Self>,
3342        cx: &mut std::task::Context<'_>,
3343    ) -> std::task::Poll<Option<Self::Item>> {
3344        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3345            &mut self.event_receiver,
3346            cx
3347        )?) {
3348            Some(buf) => std::task::Poll::Ready(Some(ShutdownWatcherRegisterEvent::decode(buf))),
3349            None => std::task::Poll::Ready(None),
3350        }
3351    }
3352}
3353
3354#[derive(Debug)]
3355pub enum ShutdownWatcherRegisterEvent {
3356    #[non_exhaustive]
3357    _UnknownEvent {
3358        /// Ordinal of the event that was sent.
3359        ordinal: u64,
3360    },
3361}
3362
3363impl ShutdownWatcherRegisterEvent {
3364    /// Decodes a message buffer as a [`ShutdownWatcherRegisterEvent`].
3365    fn decode(
3366        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3367    ) -> Result<ShutdownWatcherRegisterEvent, fidl::Error> {
3368        let (bytes, _handles) = buf.split_mut();
3369        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3370        debug_assert_eq!(tx_header.tx_id, 0);
3371        match tx_header.ordinal {
3372            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3373                Ok(ShutdownWatcherRegisterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3374            }
3375            _ => Err(fidl::Error::UnknownOrdinal {
3376                ordinal: tx_header.ordinal,
3377                protocol_name:
3378                    <ShutdownWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3379            }),
3380        }
3381    }
3382}
3383
3384/// A Stream of incoming requests for fuchsia.hardware.power.statecontrol/ShutdownWatcherRegister.
3385pub struct ShutdownWatcherRegisterRequestStream {
3386    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3387    is_terminated: bool,
3388}
3389
3390impl std::marker::Unpin for ShutdownWatcherRegisterRequestStream {}
3391
3392impl futures::stream::FusedStream for ShutdownWatcherRegisterRequestStream {
3393    fn is_terminated(&self) -> bool {
3394        self.is_terminated
3395    }
3396}
3397
3398impl fidl::endpoints::RequestStream for ShutdownWatcherRegisterRequestStream {
3399    type Protocol = ShutdownWatcherRegisterMarker;
3400    type ControlHandle = ShutdownWatcherRegisterControlHandle;
3401
3402    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3403        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3404    }
3405
3406    fn control_handle(&self) -> Self::ControlHandle {
3407        ShutdownWatcherRegisterControlHandle { inner: self.inner.clone() }
3408    }
3409
3410    fn into_inner(
3411        self,
3412    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3413    {
3414        (self.inner, self.is_terminated)
3415    }
3416
3417    fn from_inner(
3418        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3419        is_terminated: bool,
3420    ) -> Self {
3421        Self { inner, is_terminated }
3422    }
3423}
3424
3425impl futures::Stream for ShutdownWatcherRegisterRequestStream {
3426    type Item = Result<ShutdownWatcherRegisterRequest, fidl::Error>;
3427
3428    fn poll_next(
3429        mut self: std::pin::Pin<&mut Self>,
3430        cx: &mut std::task::Context<'_>,
3431    ) -> std::task::Poll<Option<Self::Item>> {
3432        let this = &mut *self;
3433        if this.inner.check_shutdown(cx) {
3434            this.is_terminated = true;
3435            return std::task::Poll::Ready(None);
3436        }
3437        if this.is_terminated {
3438            panic!("polled ShutdownWatcherRegisterRequestStream after completion");
3439        }
3440        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3441            |bytes, handles| {
3442                match this.inner.channel().read_etc(cx, bytes, handles) {
3443                    std::task::Poll::Ready(Ok(())) => {}
3444                    std::task::Poll::Pending => return std::task::Poll::Pending,
3445                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3446                        this.is_terminated = true;
3447                        return std::task::Poll::Ready(None);
3448                    }
3449                    std::task::Poll::Ready(Err(e)) => {
3450                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3451                            e.into(),
3452                        ))));
3453                    }
3454                }
3455
3456                // A message has been received from the channel
3457                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3458
3459                std::task::Poll::Ready(Some(match header.ordinal {
3460                0x3db6ce5d34810aff => {
3461                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3462                    let mut req = fidl::new_empty!(ShutdownWatcherRegisterRegisterWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
3463                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ShutdownWatcherRegisterRegisterWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
3464                    let control_handle = ShutdownWatcherRegisterControlHandle {
3465                        inner: this.inner.clone(),
3466                    };
3467                    Ok(ShutdownWatcherRegisterRequest::RegisterWatcher {watcher: req.watcher,
3468
3469                        responder: ShutdownWatcherRegisterRegisterWatcherResponder {
3470                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3471                            tx_id: header.tx_id,
3472                        },
3473                    })
3474                }
3475                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3476                    Ok(ShutdownWatcherRegisterRequest::_UnknownMethod {
3477                        ordinal: header.ordinal,
3478                        control_handle: ShutdownWatcherRegisterControlHandle { inner: this.inner.clone() },
3479                        method_type: fidl::MethodType::OneWay,
3480                    })
3481                }
3482                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3483                    this.inner.send_framework_err(
3484                        fidl::encoding::FrameworkErr::UnknownMethod,
3485                        header.tx_id,
3486                        header.ordinal,
3487                        header.dynamic_flags(),
3488                        (bytes, handles),
3489                    )?;
3490                    Ok(ShutdownWatcherRegisterRequest::_UnknownMethod {
3491                        ordinal: header.ordinal,
3492                        control_handle: ShutdownWatcherRegisterControlHandle { inner: this.inner.clone() },
3493                        method_type: fidl::MethodType::TwoWay,
3494                    })
3495                }
3496                _ => Err(fidl::Error::UnknownOrdinal {
3497                    ordinal: header.ordinal,
3498                    protocol_name: <ShutdownWatcherRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3499                }),
3500            }))
3501            },
3502        )
3503    }
3504}
3505
3506/// Allows components to register a callback that will be executed when the Shutdown
3507/// method is called. The main purpose of this protocol is to be able to track
3508/// shutdown reasons. Consider relying on Component Framework's orderly shutdown
3509/// if you're looking at using this protocol.
3510#[derive(Debug)]
3511pub enum ShutdownWatcherRegisterRequest {
3512    /// Registers a watcher to be notified when the Shutdown method is called.
3513    ///
3514    /// Once the watcher has been successfully registered with the server, then
3515    /// the request will be completed and the ShutdownWatcherRegister
3516    /// channel will be left open (though a client is free to close it at this
3517    /// time).
3518    ///
3519    /// If there is an error in registering the watcher, then the
3520    /// ShutdownWatcherRegister channel will be closed without completing
3521    /// the request.
3522    ///
3523    /// The provided `watcher` channel will be used at most once to notify the
3524    /// watcher of an impending shutdown and allow it the chance to respond.
3525    ///
3526    /// Watchers can unregister by closing their `ShutdownWatcher` channel.
3527    RegisterWatcher {
3528        watcher: fidl::endpoints::ClientEnd<ShutdownWatcherMarker>,
3529        responder: ShutdownWatcherRegisterRegisterWatcherResponder,
3530    },
3531    /// An interaction was received which does not match any known method.
3532    #[non_exhaustive]
3533    _UnknownMethod {
3534        /// Ordinal of the method that was called.
3535        ordinal: u64,
3536        control_handle: ShutdownWatcherRegisterControlHandle,
3537        method_type: fidl::MethodType,
3538    },
3539}
3540
3541impl ShutdownWatcherRegisterRequest {
3542    #[allow(irrefutable_let_patterns)]
3543    pub fn into_register_watcher(
3544        self,
3545    ) -> Option<(
3546        fidl::endpoints::ClientEnd<ShutdownWatcherMarker>,
3547        ShutdownWatcherRegisterRegisterWatcherResponder,
3548    )> {
3549        if let ShutdownWatcherRegisterRequest::RegisterWatcher { watcher, responder } = self {
3550            Some((watcher, responder))
3551        } else {
3552            None
3553        }
3554    }
3555
3556    /// Name of the method defined in FIDL
3557    pub fn method_name(&self) -> &'static str {
3558        match *self {
3559            ShutdownWatcherRegisterRequest::RegisterWatcher { .. } => "register_watcher",
3560            ShutdownWatcherRegisterRequest::_UnknownMethod {
3561                method_type: fidl::MethodType::OneWay,
3562                ..
3563            } => "unknown one-way method",
3564            ShutdownWatcherRegisterRequest::_UnknownMethod {
3565                method_type: fidl::MethodType::TwoWay,
3566                ..
3567            } => "unknown two-way method",
3568        }
3569    }
3570}
3571
3572#[derive(Debug, Clone)]
3573pub struct ShutdownWatcherRegisterControlHandle {
3574    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3575}
3576
3577impl fidl::endpoints::ControlHandle for ShutdownWatcherRegisterControlHandle {
3578    fn shutdown(&self) {
3579        self.inner.shutdown()
3580    }
3581
3582    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3583        self.inner.shutdown_with_epitaph(status)
3584    }
3585
3586    fn is_closed(&self) -> bool {
3587        self.inner.channel().is_closed()
3588    }
3589    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3590        self.inner.channel().on_closed()
3591    }
3592
3593    #[cfg(target_os = "fuchsia")]
3594    fn signal_peer(
3595        &self,
3596        clear_mask: zx::Signals,
3597        set_mask: zx::Signals,
3598    ) -> Result<(), zx_status::Status> {
3599        use fidl::Peered;
3600        self.inner.channel().signal_peer(clear_mask, set_mask)
3601    }
3602}
3603
3604impl ShutdownWatcherRegisterControlHandle {}
3605
3606#[must_use = "FIDL methods require a response to be sent"]
3607#[derive(Debug)]
3608pub struct ShutdownWatcherRegisterRegisterWatcherResponder {
3609    control_handle: std::mem::ManuallyDrop<ShutdownWatcherRegisterControlHandle>,
3610    tx_id: u32,
3611}
3612
3613/// Set the the channel to be shutdown (see [`ShutdownWatcherRegisterControlHandle::shutdown`])
3614/// if the responder is dropped without sending a response, so that the client
3615/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3616impl std::ops::Drop for ShutdownWatcherRegisterRegisterWatcherResponder {
3617    fn drop(&mut self) {
3618        self.control_handle.shutdown();
3619        // Safety: drops once, never accessed again
3620        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3621    }
3622}
3623
3624impl fidl::endpoints::Responder for ShutdownWatcherRegisterRegisterWatcherResponder {
3625    type ControlHandle = ShutdownWatcherRegisterControlHandle;
3626
3627    fn control_handle(&self) -> &ShutdownWatcherRegisterControlHandle {
3628        &self.control_handle
3629    }
3630
3631    fn drop_without_shutdown(mut self) {
3632        // Safety: drops once, never accessed again due to mem::forget
3633        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3634        // Prevent Drop from running (which would shut down the channel)
3635        std::mem::forget(self);
3636    }
3637}
3638
3639impl ShutdownWatcherRegisterRegisterWatcherResponder {
3640    /// Sends a response to the FIDL transaction.
3641    ///
3642    /// Sets the channel to shutdown if an error occurs.
3643    pub fn send(self) -> Result<(), fidl::Error> {
3644        let _result = self.send_raw();
3645        if _result.is_err() {
3646            self.control_handle.shutdown();
3647        }
3648        self.drop_without_shutdown();
3649        _result
3650    }
3651
3652    /// Similar to "send" but does not shutdown the channel if an error occurs.
3653    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3654        let _result = self.send_raw();
3655        self.drop_without_shutdown();
3656        _result
3657    }
3658
3659    fn send_raw(&self) -> Result<(), fidl::Error> {
3660        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3661            fidl::encoding::Flexible::new(()),
3662            self.tx_id,
3663            0x3db6ce5d34810aff,
3664            fidl::encoding::DynamicFlags::FLEXIBLE,
3665        )
3666    }
3667}
3668
3669mod internal {
3670    use super::*;
3671
3672    impl fidl::encoding::ResourceTypeMarker for AdminMexecRequest {
3673        type Borrowed<'a> = &'a mut Self;
3674        fn take_or_borrow<'a>(
3675            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3676        ) -> Self::Borrowed<'a> {
3677            value
3678        }
3679    }
3680
3681    unsafe impl fidl::encoding::TypeMarker for AdminMexecRequest {
3682        type Owned = Self;
3683
3684        #[inline(always)]
3685        fn inline_align(_context: fidl::encoding::Context) -> usize {
3686            4
3687        }
3688
3689        #[inline(always)]
3690        fn inline_size(_context: fidl::encoding::Context) -> usize {
3691            8
3692        }
3693    }
3694
3695    unsafe impl
3696        fidl::encoding::Encode<AdminMexecRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3697        for &mut AdminMexecRequest
3698    {
3699        #[inline]
3700        unsafe fn encode(
3701            self,
3702            encoder: &mut fidl::encoding::Encoder<
3703                '_,
3704                fidl::encoding::DefaultFuchsiaResourceDialect,
3705            >,
3706            offset: usize,
3707            _depth: fidl::encoding::Depth,
3708        ) -> fidl::Result<()> {
3709            encoder.debug_check_bounds::<AdminMexecRequest>(offset);
3710            // Delegate to tuple encoding.
3711            fidl::encoding::Encode::<AdminMexecRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3712                (
3713                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.kernel_zbi),
3714                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.data_zbi),
3715                ),
3716                encoder, offset, _depth
3717            )
3718        }
3719    }
3720    unsafe impl<
3721        T0: fidl::encoding::Encode<
3722                fidl::encoding::HandleType<
3723                    fidl::Vmo,
3724                    { fidl::ObjectType::VMO.into_raw() },
3725                    2147483648,
3726                >,
3727                fidl::encoding::DefaultFuchsiaResourceDialect,
3728            >,
3729        T1: fidl::encoding::Encode<
3730                fidl::encoding::HandleType<
3731                    fidl::Vmo,
3732                    { fidl::ObjectType::VMO.into_raw() },
3733                    2147483648,
3734                >,
3735                fidl::encoding::DefaultFuchsiaResourceDialect,
3736            >,
3737    > fidl::encoding::Encode<AdminMexecRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3738        for (T0, T1)
3739    {
3740        #[inline]
3741        unsafe fn encode(
3742            self,
3743            encoder: &mut fidl::encoding::Encoder<
3744                '_,
3745                fidl::encoding::DefaultFuchsiaResourceDialect,
3746            >,
3747            offset: usize,
3748            depth: fidl::encoding::Depth,
3749        ) -> fidl::Result<()> {
3750            encoder.debug_check_bounds::<AdminMexecRequest>(offset);
3751            // Zero out padding regions. There's no need to apply masks
3752            // because the unmasked parts will be overwritten by fields.
3753            // Write the fields.
3754            self.0.encode(encoder, offset + 0, depth)?;
3755            self.1.encode(encoder, offset + 4, depth)?;
3756            Ok(())
3757        }
3758    }
3759
3760    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3761        for AdminMexecRequest
3762    {
3763        #[inline(always)]
3764        fn new_empty() -> Self {
3765            Self {
3766                kernel_zbi: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3767                data_zbi: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3768            }
3769        }
3770
3771        #[inline]
3772        unsafe fn decode(
3773            &mut self,
3774            decoder: &mut fidl::encoding::Decoder<
3775                '_,
3776                fidl::encoding::DefaultFuchsiaResourceDialect,
3777            >,
3778            offset: usize,
3779            _depth: fidl::encoding::Depth,
3780        ) -> fidl::Result<()> {
3781            decoder.debug_check_bounds::<Self>(offset);
3782            // Verify that padding bytes are zero.
3783            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.kernel_zbi, decoder, offset + 0, _depth)?;
3784            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.data_zbi, decoder, offset + 4, _depth)?;
3785            Ok(())
3786        }
3787    }
3788
3789    impl fidl::encoding::ResourceTypeMarker for RebootMethodsWatcherRegisterRegisterWatcherRequest {
3790        type Borrowed<'a> = &'a mut Self;
3791        fn take_or_borrow<'a>(
3792            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3793        ) -> Self::Borrowed<'a> {
3794            value
3795        }
3796    }
3797
3798    unsafe impl fidl::encoding::TypeMarker for RebootMethodsWatcherRegisterRegisterWatcherRequest {
3799        type Owned = Self;
3800
3801        #[inline(always)]
3802        fn inline_align(_context: fidl::encoding::Context) -> usize {
3803            4
3804        }
3805
3806        #[inline(always)]
3807        fn inline_size(_context: fidl::encoding::Context) -> usize {
3808            4
3809        }
3810    }
3811
3812    unsafe impl
3813        fidl::encoding::Encode<
3814            RebootMethodsWatcherRegisterRegisterWatcherRequest,
3815            fidl::encoding::DefaultFuchsiaResourceDialect,
3816        > for &mut RebootMethodsWatcherRegisterRegisterWatcherRequest
3817    {
3818        #[inline]
3819        unsafe fn encode(
3820            self,
3821            encoder: &mut fidl::encoding::Encoder<
3822                '_,
3823                fidl::encoding::DefaultFuchsiaResourceDialect,
3824            >,
3825            offset: usize,
3826            _depth: fidl::encoding::Depth,
3827        ) -> fidl::Result<()> {
3828            encoder
3829                .debug_check_bounds::<RebootMethodsWatcherRegisterRegisterWatcherRequest>(offset);
3830            // Delegate to tuple encoding.
3831            fidl::encoding::Encode::<RebootMethodsWatcherRegisterRegisterWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3832                (
3833                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RebootWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
3834                ),
3835                encoder, offset, _depth
3836            )
3837        }
3838    }
3839    unsafe impl<
3840        T0: fidl::encoding::Encode<
3841                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RebootWatcherMarker>>,
3842                fidl::encoding::DefaultFuchsiaResourceDialect,
3843            >,
3844    >
3845        fidl::encoding::Encode<
3846            RebootMethodsWatcherRegisterRegisterWatcherRequest,
3847            fidl::encoding::DefaultFuchsiaResourceDialect,
3848        > for (T0,)
3849    {
3850        #[inline]
3851        unsafe fn encode(
3852            self,
3853            encoder: &mut fidl::encoding::Encoder<
3854                '_,
3855                fidl::encoding::DefaultFuchsiaResourceDialect,
3856            >,
3857            offset: usize,
3858            depth: fidl::encoding::Depth,
3859        ) -> fidl::Result<()> {
3860            encoder
3861                .debug_check_bounds::<RebootMethodsWatcherRegisterRegisterWatcherRequest>(offset);
3862            // Zero out padding regions. There's no need to apply masks
3863            // because the unmasked parts will be overwritten by fields.
3864            // Write the fields.
3865            self.0.encode(encoder, offset + 0, depth)?;
3866            Ok(())
3867        }
3868    }
3869
3870    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3871        for RebootMethodsWatcherRegisterRegisterWatcherRequest
3872    {
3873        #[inline(always)]
3874        fn new_empty() -> Self {
3875            Self {
3876                watcher: fidl::new_empty!(
3877                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RebootWatcherMarker>>,
3878                    fidl::encoding::DefaultFuchsiaResourceDialect
3879                ),
3880            }
3881        }
3882
3883        #[inline]
3884        unsafe fn decode(
3885            &mut self,
3886            decoder: &mut fidl::encoding::Decoder<
3887                '_,
3888                fidl::encoding::DefaultFuchsiaResourceDialect,
3889            >,
3890            offset: usize,
3891            _depth: fidl::encoding::Depth,
3892        ) -> fidl::Result<()> {
3893            decoder.debug_check_bounds::<Self>(offset);
3894            // Verify that padding bytes are zero.
3895            fidl::decode!(
3896                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<RebootWatcherMarker>>,
3897                fidl::encoding::DefaultFuchsiaResourceDialect,
3898                &mut self.watcher,
3899                decoder,
3900                offset + 0,
3901                _depth
3902            )?;
3903            Ok(())
3904        }
3905    }
3906
3907    impl fidl::encoding::ResourceTypeMarker for ShutdownWatcherRegisterRegisterWatcherRequest {
3908        type Borrowed<'a> = &'a mut Self;
3909        fn take_or_borrow<'a>(
3910            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3911        ) -> Self::Borrowed<'a> {
3912            value
3913        }
3914    }
3915
3916    unsafe impl fidl::encoding::TypeMarker for ShutdownWatcherRegisterRegisterWatcherRequest {
3917        type Owned = Self;
3918
3919        #[inline(always)]
3920        fn inline_align(_context: fidl::encoding::Context) -> usize {
3921            4
3922        }
3923
3924        #[inline(always)]
3925        fn inline_size(_context: fidl::encoding::Context) -> usize {
3926            4
3927        }
3928    }
3929
3930    unsafe impl
3931        fidl::encoding::Encode<
3932            ShutdownWatcherRegisterRegisterWatcherRequest,
3933            fidl::encoding::DefaultFuchsiaResourceDialect,
3934        > for &mut ShutdownWatcherRegisterRegisterWatcherRequest
3935    {
3936        #[inline]
3937        unsafe fn encode(
3938            self,
3939            encoder: &mut fidl::encoding::Encoder<
3940                '_,
3941                fidl::encoding::DefaultFuchsiaResourceDialect,
3942            >,
3943            offset: usize,
3944            _depth: fidl::encoding::Depth,
3945        ) -> fidl::Result<()> {
3946            encoder.debug_check_bounds::<ShutdownWatcherRegisterRegisterWatcherRequest>(offset);
3947            // Delegate to tuple encoding.
3948            fidl::encoding::Encode::<ShutdownWatcherRegisterRegisterWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3949                (
3950                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ShutdownWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
3951                ),
3952                encoder, offset, _depth
3953            )
3954        }
3955    }
3956    unsafe impl<
3957        T0: fidl::encoding::Encode<
3958                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ShutdownWatcherMarker>>,
3959                fidl::encoding::DefaultFuchsiaResourceDialect,
3960            >,
3961    >
3962        fidl::encoding::Encode<
3963            ShutdownWatcherRegisterRegisterWatcherRequest,
3964            fidl::encoding::DefaultFuchsiaResourceDialect,
3965        > for (T0,)
3966    {
3967        #[inline]
3968        unsafe fn encode(
3969            self,
3970            encoder: &mut fidl::encoding::Encoder<
3971                '_,
3972                fidl::encoding::DefaultFuchsiaResourceDialect,
3973            >,
3974            offset: usize,
3975            depth: fidl::encoding::Depth,
3976        ) -> fidl::Result<()> {
3977            encoder.debug_check_bounds::<ShutdownWatcherRegisterRegisterWatcherRequest>(offset);
3978            // Zero out padding regions. There's no need to apply masks
3979            // because the unmasked parts will be overwritten by fields.
3980            // Write the fields.
3981            self.0.encode(encoder, offset + 0, depth)?;
3982            Ok(())
3983        }
3984    }
3985
3986    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3987        for ShutdownWatcherRegisterRegisterWatcherRequest
3988    {
3989        #[inline(always)]
3990        fn new_empty() -> Self {
3991            Self {
3992                watcher: fidl::new_empty!(
3993                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ShutdownWatcherMarker>>,
3994                    fidl::encoding::DefaultFuchsiaResourceDialect
3995                ),
3996            }
3997        }
3998
3999        #[inline]
4000        unsafe fn decode(
4001            &mut self,
4002            decoder: &mut fidl::encoding::Decoder<
4003                '_,
4004                fidl::encoding::DefaultFuchsiaResourceDialect,
4005            >,
4006            offset: usize,
4007            _depth: fidl::encoding::Depth,
4008        ) -> fidl::Result<()> {
4009            decoder.debug_check_bounds::<Self>(offset);
4010            // Verify that padding bytes are zero.
4011            fidl::decode!(
4012                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ShutdownWatcherMarker>>,
4013                fidl::encoding::DefaultFuchsiaResourceDialect,
4014                &mut self.watcher,
4015                decoder,
4016                offset + 0,
4017                _depth
4018            )?;
4019            Ok(())
4020        }
4021    }
4022}