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