fidl_fuchsia_hardware_power_statecontrol/
fidl_fuchsia_hardware_power_statecontrol.rs

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