fidl_fuchsia_power_internal/
fidl_fuchsia_power_internal.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_power_internal__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct CollaborativeRebootSchedulerScheduleRebootRequest {
16    pub reason: CollaborativeRebootReason,
17    pub cancel: Option<fidl::EventPair>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for CollaborativeRebootSchedulerScheduleRebootRequest
22{
23}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct CollaborativeRebootSchedulerMarker;
27
28impl fidl::endpoints::ProtocolMarker for CollaborativeRebootSchedulerMarker {
29    type Proxy = CollaborativeRebootSchedulerProxy;
30    type RequestStream = CollaborativeRebootSchedulerRequestStream;
31    #[cfg(target_os = "fuchsia")]
32    type SynchronousProxy = CollaborativeRebootSchedulerSynchronousProxy;
33
34    const DEBUG_NAME: &'static str = "fuchsia.power.internal.CollaborativeRebootScheduler";
35}
36impl fidl::endpoints::DiscoverableProtocolMarker for CollaborativeRebootSchedulerMarker {}
37
38pub trait CollaborativeRebootSchedulerProxyInterface: Send + Sync {
39    type ScheduleRebootResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
40    fn r#schedule_reboot(
41        &self,
42        reason: CollaborativeRebootReason,
43        cancel: Option<fidl::EventPair>,
44    ) -> Self::ScheduleRebootResponseFut;
45}
46#[derive(Debug)]
47#[cfg(target_os = "fuchsia")]
48pub struct CollaborativeRebootSchedulerSynchronousProxy {
49    client: fidl::client::sync::Client,
50}
51
52#[cfg(target_os = "fuchsia")]
53impl fidl::endpoints::SynchronousProxy for CollaborativeRebootSchedulerSynchronousProxy {
54    type Proxy = CollaborativeRebootSchedulerProxy;
55    type Protocol = CollaborativeRebootSchedulerMarker;
56
57    fn from_channel(inner: fidl::Channel) -> Self {
58        Self::new(inner)
59    }
60
61    fn into_channel(self) -> fidl::Channel {
62        self.client.into_channel()
63    }
64
65    fn as_channel(&self) -> &fidl::Channel {
66        self.client.as_channel()
67    }
68}
69
70#[cfg(target_os = "fuchsia")]
71impl CollaborativeRebootSchedulerSynchronousProxy {
72    pub fn new(channel: fidl::Channel) -> Self {
73        let protocol_name =
74            <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
75        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
76    }
77
78    pub fn into_channel(self) -> fidl::Channel {
79        self.client.into_channel()
80    }
81
82    /// Waits until an event arrives and returns it. It is safe for other
83    /// threads to make concurrent requests while waiting for an event.
84    pub fn wait_for_event(
85        &self,
86        deadline: zx::MonotonicInstant,
87    ) -> Result<CollaborativeRebootSchedulerEvent, fidl::Error> {
88        CollaborativeRebootSchedulerEvent::decode(self.client.wait_for_event(deadline)?)
89    }
90
91    /// Schedules a collaborative reboot.
92    ///
93    /// Notifies the server of a new reason to perform collaborative reboot.
94    /// This method may be called multiple times, by multiple actors for a
95    /// single collaborative reboot.
96    ///
97    /// The server will not respond to the method until the request has been
98    /// scheduled.
99    ///
100    /// Arguments:
101    ///  - reason: The reason for requesting the collaborative reboot.
102    ///  - cancel: An optional Zircon Eventpair. If provided, the caller may
103    ///            cancel their request by signaling the event's peer. A
104    ///            canceled request will not cause a future call to
105    ///            [`CollaborativeRebootInitiator.PerformPendingReboot`]
106    ///            to initiate a reboot.
107    ///            Any `ZX_USER_SIGNAL_*` can be used to cancel the request.
108    ///            If the server observes `ZX_OBJECT_PEER_CLOSED` (i.e. because
109    ///            the client dropped the event pair), it will be interpretted
110    ///            as a cancellation.
111    pub fn r#schedule_reboot(
112        &self,
113        mut reason: CollaborativeRebootReason,
114        mut cancel: Option<fidl::EventPair>,
115        ___deadline: zx::MonotonicInstant,
116    ) -> Result<(), fidl::Error> {
117        let _response = self.client.send_query::<
118            CollaborativeRebootSchedulerScheduleRebootRequest,
119            fidl::encoding::EmptyPayload,
120        >(
121            (reason, cancel,),
122            0x439c89c2c4b101ab,
123            fidl::encoding::DynamicFlags::empty(),
124            ___deadline,
125        )?;
126        Ok(_response)
127    }
128}
129
130#[cfg(target_os = "fuchsia")]
131impl From<CollaborativeRebootSchedulerSynchronousProxy> for zx::NullableHandle {
132    fn from(value: CollaborativeRebootSchedulerSynchronousProxy) -> Self {
133        value.into_channel().into()
134    }
135}
136
137#[cfg(target_os = "fuchsia")]
138impl From<fidl::Channel> for CollaborativeRebootSchedulerSynchronousProxy {
139    fn from(value: fidl::Channel) -> Self {
140        Self::new(value)
141    }
142}
143
144#[cfg(target_os = "fuchsia")]
145impl fidl::endpoints::FromClient for CollaborativeRebootSchedulerSynchronousProxy {
146    type Protocol = CollaborativeRebootSchedulerMarker;
147
148    fn from_client(value: fidl::endpoints::ClientEnd<CollaborativeRebootSchedulerMarker>) -> Self {
149        Self::new(value.into_channel())
150    }
151}
152
153#[derive(Debug, Clone)]
154pub struct CollaborativeRebootSchedulerProxy {
155    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
156}
157
158impl fidl::endpoints::Proxy for CollaborativeRebootSchedulerProxy {
159    type Protocol = CollaborativeRebootSchedulerMarker;
160
161    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
162        Self::new(inner)
163    }
164
165    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
166        self.client.into_channel().map_err(|client| Self { client })
167    }
168
169    fn as_channel(&self) -> &::fidl::AsyncChannel {
170        self.client.as_channel()
171    }
172}
173
174impl CollaborativeRebootSchedulerProxy {
175    /// Create a new Proxy for fuchsia.power.internal/CollaborativeRebootScheduler.
176    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
177        let protocol_name =
178            <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
179        Self { client: fidl::client::Client::new(channel, protocol_name) }
180    }
181
182    /// Get a Stream of events from the remote end of the protocol.
183    ///
184    /// # Panics
185    ///
186    /// Panics if the event stream was already taken.
187    pub fn take_event_stream(&self) -> CollaborativeRebootSchedulerEventStream {
188        CollaborativeRebootSchedulerEventStream {
189            event_receiver: self.client.take_event_receiver(),
190        }
191    }
192
193    /// Schedules a collaborative reboot.
194    ///
195    /// Notifies the server of a new reason to perform collaborative reboot.
196    /// This method may be called multiple times, by multiple actors for a
197    /// single collaborative reboot.
198    ///
199    /// The server will not respond to the method until the request has been
200    /// scheduled.
201    ///
202    /// Arguments:
203    ///  - reason: The reason for requesting the collaborative reboot.
204    ///  - cancel: An optional Zircon Eventpair. If provided, the caller may
205    ///            cancel their request by signaling the event's peer. A
206    ///            canceled request will not cause a future call to
207    ///            [`CollaborativeRebootInitiator.PerformPendingReboot`]
208    ///            to initiate a reboot.
209    ///            Any `ZX_USER_SIGNAL_*` can be used to cancel the request.
210    ///            If the server observes `ZX_OBJECT_PEER_CLOSED` (i.e. because
211    ///            the client dropped the event pair), it will be interpretted
212    ///            as a cancellation.
213    pub fn r#schedule_reboot(
214        &self,
215        mut reason: CollaborativeRebootReason,
216        mut cancel: Option<fidl::EventPair>,
217    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
218        CollaborativeRebootSchedulerProxyInterface::r#schedule_reboot(self, reason, cancel)
219    }
220}
221
222impl CollaborativeRebootSchedulerProxyInterface for CollaborativeRebootSchedulerProxy {
223    type ScheduleRebootResponseFut =
224        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
225    fn r#schedule_reboot(
226        &self,
227        mut reason: CollaborativeRebootReason,
228        mut cancel: Option<fidl::EventPair>,
229    ) -> Self::ScheduleRebootResponseFut {
230        fn _decode(
231            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
232        ) -> Result<(), fidl::Error> {
233            let _response = fidl::client::decode_transaction_body::<
234                fidl::encoding::EmptyPayload,
235                fidl::encoding::DefaultFuchsiaResourceDialect,
236                0x439c89c2c4b101ab,
237            >(_buf?)?;
238            Ok(_response)
239        }
240        self.client.send_query_and_decode::<CollaborativeRebootSchedulerScheduleRebootRequest, ()>(
241            (reason, cancel),
242            0x439c89c2c4b101ab,
243            fidl::encoding::DynamicFlags::empty(),
244            _decode,
245        )
246    }
247}
248
249pub struct CollaborativeRebootSchedulerEventStream {
250    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
251}
252
253impl std::marker::Unpin for CollaborativeRebootSchedulerEventStream {}
254
255impl futures::stream::FusedStream for CollaborativeRebootSchedulerEventStream {
256    fn is_terminated(&self) -> bool {
257        self.event_receiver.is_terminated()
258    }
259}
260
261impl futures::Stream for CollaborativeRebootSchedulerEventStream {
262    type Item = Result<CollaborativeRebootSchedulerEvent, fidl::Error>;
263
264    fn poll_next(
265        mut self: std::pin::Pin<&mut Self>,
266        cx: &mut std::task::Context<'_>,
267    ) -> std::task::Poll<Option<Self::Item>> {
268        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
269            &mut self.event_receiver,
270            cx
271        )?) {
272            Some(buf) => {
273                std::task::Poll::Ready(Some(CollaborativeRebootSchedulerEvent::decode(buf)))
274            }
275            None => std::task::Poll::Ready(None),
276        }
277    }
278}
279
280#[derive(Debug)]
281pub enum CollaborativeRebootSchedulerEvent {}
282
283impl CollaborativeRebootSchedulerEvent {
284    /// Decodes a message buffer as a [`CollaborativeRebootSchedulerEvent`].
285    fn decode(
286        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
287    ) -> Result<CollaborativeRebootSchedulerEvent, fidl::Error> {
288        let (bytes, _handles) = buf.split_mut();
289        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
290        debug_assert_eq!(tx_header.tx_id, 0);
291        match tx_header.ordinal {
292            _ => Err(fidl::Error::UnknownOrdinal {
293                ordinal: tx_header.ordinal,
294                protocol_name: <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
295            })
296        }
297    }
298}
299
300/// A Stream of incoming requests for fuchsia.power.internal/CollaborativeRebootScheduler.
301pub struct CollaborativeRebootSchedulerRequestStream {
302    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
303    is_terminated: bool,
304}
305
306impl std::marker::Unpin for CollaborativeRebootSchedulerRequestStream {}
307
308impl futures::stream::FusedStream for CollaborativeRebootSchedulerRequestStream {
309    fn is_terminated(&self) -> bool {
310        self.is_terminated
311    }
312}
313
314impl fidl::endpoints::RequestStream for CollaborativeRebootSchedulerRequestStream {
315    type Protocol = CollaborativeRebootSchedulerMarker;
316    type ControlHandle = CollaborativeRebootSchedulerControlHandle;
317
318    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
319        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
320    }
321
322    fn control_handle(&self) -> Self::ControlHandle {
323        CollaborativeRebootSchedulerControlHandle { inner: self.inner.clone() }
324    }
325
326    fn into_inner(
327        self,
328    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
329    {
330        (self.inner, self.is_terminated)
331    }
332
333    fn from_inner(
334        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
335        is_terminated: bool,
336    ) -> Self {
337        Self { inner, is_terminated }
338    }
339}
340
341impl futures::Stream for CollaborativeRebootSchedulerRequestStream {
342    type Item = Result<CollaborativeRebootSchedulerRequest, fidl::Error>;
343
344    fn poll_next(
345        mut self: std::pin::Pin<&mut Self>,
346        cx: &mut std::task::Context<'_>,
347    ) -> std::task::Poll<Option<Self::Item>> {
348        let this = &mut *self;
349        if this.inner.check_shutdown(cx) {
350            this.is_terminated = true;
351            return std::task::Poll::Ready(None);
352        }
353        if this.is_terminated {
354            panic!("polled CollaborativeRebootSchedulerRequestStream after completion");
355        }
356        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
357            |bytes, handles| {
358                match this.inner.channel().read_etc(cx, bytes, handles) {
359                    std::task::Poll::Ready(Ok(())) => {}
360                    std::task::Poll::Pending => return std::task::Poll::Pending,
361                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
362                        this.is_terminated = true;
363                        return std::task::Poll::Ready(None);
364                    }
365                    std::task::Poll::Ready(Err(e)) => {
366                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
367                            e.into(),
368                        ))));
369                    }
370                }
371
372                // A message has been received from the channel
373                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
374
375                std::task::Poll::Ready(Some(match header.ordinal {
376                0x439c89c2c4b101ab => {
377                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
378                    let mut req = fidl::new_empty!(CollaborativeRebootSchedulerScheduleRebootRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
379                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CollaborativeRebootSchedulerScheduleRebootRequest>(&header, _body_bytes, handles, &mut req)?;
380                    let control_handle = CollaborativeRebootSchedulerControlHandle {
381                        inner: this.inner.clone(),
382                    };
383                    Ok(CollaborativeRebootSchedulerRequest::ScheduleReboot {reason: req.reason,
384cancel: req.cancel,
385
386                        responder: CollaborativeRebootSchedulerScheduleRebootResponder {
387                            control_handle: std::mem::ManuallyDrop::new(control_handle),
388                            tx_id: header.tx_id,
389                        },
390                    })
391                }
392                _ => Err(fidl::Error::UnknownOrdinal {
393                    ordinal: header.ordinal,
394                    protocol_name: <CollaborativeRebootSchedulerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
395                }),
396            }))
397            },
398        )
399    }
400}
401
402/// A scheduler of collaborative device reboots.
403///
404/// Collaborative reboot is a mechanism that allows multiple actors to work
405/// together to schedule a device reboot at a time that avoids user disruption.
406/// Actors fulfill one of two roles: Scheduler or Initiator. The scheduler
407/// registers the desire to reboot the device at a later point in time, while
408/// the initiator identifies appropriate times to perform a reboot and actuates
409/// any scheduled requests. This protocol fulfills the scheduler role. For the
410/// initiator role's protocol, see
411/// [`fuchsia.power/CollaborativeRebootInitiator`].
412///
413/// Collaborative reboot can be used when the platform is configured to let the
414/// product drive reboot scheduling.
415///
416/// As a concrete example, this mechanism can be used to drive software updates.
417/// When the platform identifies that there is an outstanding software update to
418/// apply, it can download the update, and schedule a collaborative reboot.
419/// Later, when the product identifies that it is an appropriate time for the
420/// device to reboot (say, after it's observed a sufficient period of user
421/// inactivity), it can initate the collaborative reboot.
422#[derive(Debug)]
423pub enum CollaborativeRebootSchedulerRequest {
424    /// Schedules a collaborative reboot.
425    ///
426    /// Notifies the server of a new reason to perform collaborative reboot.
427    /// This method may be called multiple times, by multiple actors for a
428    /// single collaborative reboot.
429    ///
430    /// The server will not respond to the method until the request has been
431    /// scheduled.
432    ///
433    /// Arguments:
434    ///  - reason: The reason for requesting the collaborative reboot.
435    ///  - cancel: An optional Zircon Eventpair. If provided, the caller may
436    ///            cancel their request by signaling the event's peer. A
437    ///            canceled request will not cause a future call to
438    ///            [`CollaborativeRebootInitiator.PerformPendingReboot`]
439    ///            to initiate a reboot.
440    ///            Any `ZX_USER_SIGNAL_*` can be used to cancel the request.
441    ///            If the server observes `ZX_OBJECT_PEER_CLOSED` (i.e. because
442    ///            the client dropped the event pair), it will be interpretted
443    ///            as a cancellation.
444    ScheduleReboot {
445        reason: CollaborativeRebootReason,
446        cancel: Option<fidl::EventPair>,
447        responder: CollaborativeRebootSchedulerScheduleRebootResponder,
448    },
449}
450
451impl CollaborativeRebootSchedulerRequest {
452    #[allow(irrefutable_let_patterns)]
453    pub fn into_schedule_reboot(
454        self,
455    ) -> Option<(
456        CollaborativeRebootReason,
457        Option<fidl::EventPair>,
458        CollaborativeRebootSchedulerScheduleRebootResponder,
459    )> {
460        if let CollaborativeRebootSchedulerRequest::ScheduleReboot { reason, cancel, responder } =
461            self
462        {
463            Some((reason, cancel, responder))
464        } else {
465            None
466        }
467    }
468
469    /// Name of the method defined in FIDL
470    pub fn method_name(&self) -> &'static str {
471        match *self {
472            CollaborativeRebootSchedulerRequest::ScheduleReboot { .. } => "schedule_reboot",
473        }
474    }
475}
476
477#[derive(Debug, Clone)]
478pub struct CollaborativeRebootSchedulerControlHandle {
479    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
480}
481
482impl fidl::endpoints::ControlHandle for CollaborativeRebootSchedulerControlHandle {
483    fn shutdown(&self) {
484        self.inner.shutdown()
485    }
486
487    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
488        self.inner.shutdown_with_epitaph(status)
489    }
490
491    fn is_closed(&self) -> bool {
492        self.inner.channel().is_closed()
493    }
494    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
495        self.inner.channel().on_closed()
496    }
497
498    #[cfg(target_os = "fuchsia")]
499    fn signal_peer(
500        &self,
501        clear_mask: zx::Signals,
502        set_mask: zx::Signals,
503    ) -> Result<(), zx_status::Status> {
504        use fidl::Peered;
505        self.inner.channel().signal_peer(clear_mask, set_mask)
506    }
507}
508
509impl CollaborativeRebootSchedulerControlHandle {}
510
511#[must_use = "FIDL methods require a response to be sent"]
512#[derive(Debug)]
513pub struct CollaborativeRebootSchedulerScheduleRebootResponder {
514    control_handle: std::mem::ManuallyDrop<CollaborativeRebootSchedulerControlHandle>,
515    tx_id: u32,
516}
517
518/// Set the the channel to be shutdown (see [`CollaborativeRebootSchedulerControlHandle::shutdown`])
519/// if the responder is dropped without sending a response, so that the client
520/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
521impl std::ops::Drop for CollaborativeRebootSchedulerScheduleRebootResponder {
522    fn drop(&mut self) {
523        self.control_handle.shutdown();
524        // Safety: drops once, never accessed again
525        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
526    }
527}
528
529impl fidl::endpoints::Responder for CollaborativeRebootSchedulerScheduleRebootResponder {
530    type ControlHandle = CollaborativeRebootSchedulerControlHandle;
531
532    fn control_handle(&self) -> &CollaborativeRebootSchedulerControlHandle {
533        &self.control_handle
534    }
535
536    fn drop_without_shutdown(mut self) {
537        // Safety: drops once, never accessed again due to mem::forget
538        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
539        // Prevent Drop from running (which would shut down the channel)
540        std::mem::forget(self);
541    }
542}
543
544impl CollaborativeRebootSchedulerScheduleRebootResponder {
545    /// Sends a response to the FIDL transaction.
546    ///
547    /// Sets the channel to shutdown if an error occurs.
548    pub fn send(self) -> Result<(), fidl::Error> {
549        let _result = self.send_raw();
550        if _result.is_err() {
551            self.control_handle.shutdown();
552        }
553        self.drop_without_shutdown();
554        _result
555    }
556
557    /// Similar to "send" but does not shutdown the channel if an error occurs.
558    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
559        let _result = self.send_raw();
560        self.drop_without_shutdown();
561        _result
562    }
563
564    fn send_raw(&self) -> Result<(), fidl::Error> {
565        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
566            (),
567            self.tx_id,
568            0x439c89c2c4b101ab,
569            fidl::encoding::DynamicFlags::empty(),
570        )
571    }
572}
573
574mod internal {
575    use super::*;
576
577    impl fidl::encoding::ResourceTypeMarker for CollaborativeRebootSchedulerScheduleRebootRequest {
578        type Borrowed<'a> = &'a mut Self;
579        fn take_or_borrow<'a>(
580            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
581        ) -> Self::Borrowed<'a> {
582            value
583        }
584    }
585
586    unsafe impl fidl::encoding::TypeMarker for CollaborativeRebootSchedulerScheduleRebootRequest {
587        type Owned = Self;
588
589        #[inline(always)]
590        fn inline_align(_context: fidl::encoding::Context) -> usize {
591            4
592        }
593
594        #[inline(always)]
595        fn inline_size(_context: fidl::encoding::Context) -> usize {
596            8
597        }
598    }
599
600    unsafe impl
601        fidl::encoding::Encode<
602            CollaborativeRebootSchedulerScheduleRebootRequest,
603            fidl::encoding::DefaultFuchsiaResourceDialect,
604        > for &mut CollaborativeRebootSchedulerScheduleRebootRequest
605    {
606        #[inline]
607        unsafe fn encode(
608            self,
609            encoder: &mut fidl::encoding::Encoder<
610                '_,
611                fidl::encoding::DefaultFuchsiaResourceDialect,
612            >,
613            offset: usize,
614            _depth: fidl::encoding::Depth,
615        ) -> fidl::Result<()> {
616            encoder.debug_check_bounds::<CollaborativeRebootSchedulerScheduleRebootRequest>(offset);
617            // Delegate to tuple encoding.
618            fidl::encoding::Encode::<
619                CollaborativeRebootSchedulerScheduleRebootRequest,
620                fidl::encoding::DefaultFuchsiaResourceDialect,
621            >::encode(
622                (
623                    <CollaborativeRebootReason as fidl::encoding::ValueTypeMarker>::borrow(
624                        &self.reason,
625                    ),
626                    <fidl::encoding::Optional<
627                        fidl::encoding::HandleType<
628                            fidl::EventPair,
629                            { fidl::ObjectType::EVENTPAIR.into_raw() },
630                            16384,
631                        >,
632                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
633                        &mut self.cancel
634                    ),
635                ),
636                encoder,
637                offset,
638                _depth,
639            )
640        }
641    }
642    unsafe impl<
643        T0: fidl::encoding::Encode<
644                CollaborativeRebootReason,
645                fidl::encoding::DefaultFuchsiaResourceDialect,
646            >,
647        T1: fidl::encoding::Encode<
648                fidl::encoding::Optional<
649                    fidl::encoding::HandleType<
650                        fidl::EventPair,
651                        { fidl::ObjectType::EVENTPAIR.into_raw() },
652                        16384,
653                    >,
654                >,
655                fidl::encoding::DefaultFuchsiaResourceDialect,
656            >,
657    >
658        fidl::encoding::Encode<
659            CollaborativeRebootSchedulerScheduleRebootRequest,
660            fidl::encoding::DefaultFuchsiaResourceDialect,
661        > for (T0, T1)
662    {
663        #[inline]
664        unsafe fn encode(
665            self,
666            encoder: &mut fidl::encoding::Encoder<
667                '_,
668                fidl::encoding::DefaultFuchsiaResourceDialect,
669            >,
670            offset: usize,
671            depth: fidl::encoding::Depth,
672        ) -> fidl::Result<()> {
673            encoder.debug_check_bounds::<CollaborativeRebootSchedulerScheduleRebootRequest>(offset);
674            // Zero out padding regions. There's no need to apply masks
675            // because the unmasked parts will be overwritten by fields.
676            // Write the fields.
677            self.0.encode(encoder, offset + 0, depth)?;
678            self.1.encode(encoder, offset + 4, depth)?;
679            Ok(())
680        }
681    }
682
683    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
684        for CollaborativeRebootSchedulerScheduleRebootRequest
685    {
686        #[inline(always)]
687        fn new_empty() -> Self {
688            Self {
689                reason: fidl::new_empty!(
690                    CollaborativeRebootReason,
691                    fidl::encoding::DefaultFuchsiaResourceDialect
692                ),
693                cancel: fidl::new_empty!(
694                    fidl::encoding::Optional<
695                        fidl::encoding::HandleType<
696                            fidl::EventPair,
697                            { fidl::ObjectType::EVENTPAIR.into_raw() },
698                            16384,
699                        >,
700                    >,
701                    fidl::encoding::DefaultFuchsiaResourceDialect
702                ),
703            }
704        }
705
706        #[inline]
707        unsafe fn decode(
708            &mut self,
709            decoder: &mut fidl::encoding::Decoder<
710                '_,
711                fidl::encoding::DefaultFuchsiaResourceDialect,
712            >,
713            offset: usize,
714            _depth: fidl::encoding::Depth,
715        ) -> fidl::Result<()> {
716            decoder.debug_check_bounds::<Self>(offset);
717            // Verify that padding bytes are zero.
718            fidl::decode!(
719                CollaborativeRebootReason,
720                fidl::encoding::DefaultFuchsiaResourceDialect,
721                &mut self.reason,
722                decoder,
723                offset + 0,
724                _depth
725            )?;
726            fidl::decode!(
727                fidl::encoding::Optional<
728                    fidl::encoding::HandleType<
729                        fidl::EventPair,
730                        { fidl::ObjectType::EVENTPAIR.into_raw() },
731                        16384,
732                    >,
733                >,
734                fidl::encoding::DefaultFuchsiaResourceDialect,
735                &mut self.cancel,
736                decoder,
737                offset + 4,
738                _depth
739            )?;
740            Ok(())
741        }
742    }
743}