fidl_fuchsia_hardware_power_statecontrol/
fidl_fuchsia_hardware_power_statecontrol.rs

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